Search in sources :

Example 1 with SgTraktInterceptor

use of com.battlelancer.seriesguide.traktapi.SgTraktInterceptor in project SeriesGuide by UweTrottmann.

the class HttpClientModule method provideOkHttpClient.

/**
     * Returns this apps {@link OkHttpClient} with enabled response cache. Should be used with API
     * calls.
     */
@Provides
@Singleton
OkHttpClient provideOkHttpClient(SgApp app, Cache cache) {
    OkHttpClient.Builder builder = new OkHttpClient.Builder();
    builder.connectTimeout(CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    builder.readTimeout(READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    builder.addInterceptor(new SgTmdbInterceptor());
    builder.addNetworkInterceptor(new SgTheTvdbInterceptor(app));
    builder.addNetworkInterceptor(new SgTraktInterceptor(app));
    builder.authenticator(new AllApisAuthenticator(app));
    builder.cache(cache);
    return builder.build();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) SgTmdbInterceptor(com.battlelancer.seriesguide.tmdbapi.SgTmdbInterceptor) SgTraktInterceptor(com.battlelancer.seriesguide.traktapi.SgTraktInterceptor) SgTheTvdbInterceptor(com.battlelancer.seriesguide.thetvdbapi.SgTheTvdbInterceptor) AllApisAuthenticator(com.battlelancer.seriesguide.util.AllApisAuthenticator) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Aggregations

SgTheTvdbInterceptor (com.battlelancer.seriesguide.thetvdbapi.SgTheTvdbInterceptor)1 SgTmdbInterceptor (com.battlelancer.seriesguide.tmdbapi.SgTmdbInterceptor)1 SgTraktInterceptor (com.battlelancer.seriesguide.traktapi.SgTraktInterceptor)1 AllApisAuthenticator (com.battlelancer.seriesguide.util.AllApisAuthenticator)1 Provides (dagger.Provides)1 Singleton (javax.inject.Singleton)1 OkHttpClient (okhttp3.OkHttpClient)1