/**
* 初始化OKHttpClient
*/
private static void initOkHttpClient() {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
if (mOkHttpClient == null) {
synchronized (RetrofitHelper.class) {
if (mOkHttpClient == null) {
//设置Http缓存
Cache cache = new Cache(new File(MoeQuestApp.getContext().getCacheDir(), "HttpCache"),
1024 * 1024 * 100);
mOkHttpClient = new OkHttpClient.Builder()
.cache(cache)
.addInterceptor(interceptor)
.addNetworkInterceptor(new StethoInterceptor())
.retryOnConnectionFailure(true)
.connectTimeout(20, TimeUnit.SECONDS)
.build();
}
}
}
}
RetrofitHelper.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:MoeQuest
作者:
评论列表
文章目录