Commit cbed9b96 by 罗翻

Api修改

parent e0fe8b56
......@@ -35,15 +35,17 @@ public class Api {
private static Retrofit downloadRetrofit;
/**
*普通retrofit.
* 普通retrofit.
*
* @return
*/
public static APIService getService() {
return getRetrofit().create(APIService.class);
public static <T> T getService(Class<T> cls) {
return getRetrofit().create(cls);
}
/**
* 下载的retrofit.
*
* @return
*/
public static APIService getDownloadService() {
......@@ -78,13 +80,13 @@ public class Api {
.writeTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS)
.connectTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS);
if ("download".equals(type)) {
build.addNetworkInterceptor(chain -> {
Response response = chain.proceed(chain.request());
return response
.newBuilder()
.body(new FileResponseBody(response.body()))//将自定义的ResposeBody设置给它
.build();
});
build.addNetworkInterceptor(chain -> {
Response response = chain.proceed(chain.request());
return response
.newBuilder()
.body(new FileResponseBody(response.body()))//将自定义的ResposeBody设置给它
.build();
});
}
return new Retrofit.Builder()
.client(build.build())
......@@ -111,7 +113,6 @@ public class Api {
.build();
}
}
// Log.d("request_header", request.headers().toString());
return chain.proceed(request);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment