use of com.mxt.anitrend.model.api.interceptor.NetworkCacheInterceptor in project anitrend-app by AniTrend.
the class WebFactory method createCrunchyService.
public static EpisodeModel createCrunchyService(boolean feeds, Context context) {
if (mCrunchy == null) {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder().readTimeout(45, TimeUnit.SECONDS).connectTimeout(45, TimeUnit.SECONDS).addInterceptor(new CacheInterceptor(context, true)).addNetworkInterceptor(new NetworkCacheInterceptor(context, true)).cache(CompatUtil.cacheProvider(context));
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC);
httpClient.addInterceptor(httpLoggingInterceptor);
}
crunchyBuilder.client(httpClient.build());
}
mCrunchy = crunchyBuilder.baseUrl(feeds ? BuildConfig.FEEDS_LINK : BuildConfig.CRUNCHY_LINK).build();
return mCrunchy.create(EpisodeModel.class);
}
use of com.mxt.anitrend.model.api.interceptor.NetworkCacheInterceptor in project anitrend-app by AniTrend.
the class WebFactory method createGiphyService.
public static GiphyModel createGiphyService(Context context) {
if (mGiphy == null) {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder().readTimeout(35, TimeUnit.SECONDS).connectTimeout(35, TimeUnit.SECONDS).addInterceptor(new CacheInterceptor(context, true)).addNetworkInterceptor(new NetworkCacheInterceptor(context, true)).cache(CompatUtil.cacheProvider(context));
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC);
httpClient.addInterceptor(httpLoggingInterceptor);
}
mGiphy = giphyBuilder.client(httpClient.build()).build();
}
return mGiphy.create(GiphyModel.class);
}
Aggregations