use of com.facebook.stetho.okhttp.StethoInterceptor in project Rutgers-Course-Tracker by tevjef.
the class RutgersCTModule method providesOkHttpClient.
@Provides
@Singleton
public OkHttpClient providesOkHttpClient(Context context) {
OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
client.setReadTimeout(READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
client.networkInterceptors().add(new StethoInterceptor());
File httpCacheDir = new File(context.getCacheDir(), context.getString(R.string.application_name));
// 50 MiB
long httpCacheSize = 50 * 1024 * 1024;
Cache cache = new Cache(httpCacheDir, httpCacheSize);
client.setCache(cache);
if (BuildConfig.DEBUG) {
try {
cache.evictAll();
} catch (IOException e) {
e.printStackTrace();
}
}
return client;
}
Aggregations