Search in sources :

Example 1 with NetworkCacheInterceptor

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);
}
Also used : OkHttpClient(okhttp3.OkHttpClient) CacheInterceptor(com.mxt.anitrend.model.api.interceptor.CacheInterceptor) NetworkCacheInterceptor(com.mxt.anitrend.model.api.interceptor.NetworkCacheInterceptor) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) NetworkCacheInterceptor(com.mxt.anitrend.model.api.interceptor.NetworkCacheInterceptor)

Example 2 with NetworkCacheInterceptor

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);
}
Also used : OkHttpClient(okhttp3.OkHttpClient) CacheInterceptor(com.mxt.anitrend.model.api.interceptor.CacheInterceptor) NetworkCacheInterceptor(com.mxt.anitrend.model.api.interceptor.NetworkCacheInterceptor) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) NetworkCacheInterceptor(com.mxt.anitrend.model.api.interceptor.NetworkCacheInterceptor)

Aggregations

CacheInterceptor (com.mxt.anitrend.model.api.interceptor.CacheInterceptor)2 NetworkCacheInterceptor (com.mxt.anitrend.model.api.interceptor.NetworkCacheInterceptor)2 OkHttpClient (okhttp3.OkHttpClient)2 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)2