use of app.main.wangliwei.enablehands.http.interceptor.CacheInterceptor in project EnableHands by LeviWGG.
the class ServiceFactory method getOkhttpClient.
public OkHttpClient getOkhttpClient() {
OkHttpClient.Builder builder = new OkHttpClient().newBuilder();
File cachefile = new File(MyApplication.getMyContext().getExternalCacheDir(), "");
Cache cache = new Cache(cachefile, 1024 * 1024 * 30);
builder.cache(cache);
HttpLogInterceptor httpLogInterceptor = new HttpLogInterceptor();
builder.addInterceptor(httpLogInterceptor);
CacheInterceptor cacheInterceptor = new CacheInterceptor();
builder.addInterceptor(cacheInterceptor);
builder.readTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS);
builder.writeTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS);
builder.connectTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS);
return builder.build();
}
Aggregations