Search in sources :

Example 1 with RequestInterceptor

use of com.bluestacks.bugzy.data.remote.RequestInterceptor in project bugzy by cpunq.

the class NetModule method provideFogBugzService.

@Provides
@Singleton
FogbugzApiService provideFogBugzService(Application application, PrefsHelper prefsHelper, Gson gson) {
    OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
    Retrofit.Builder builder = new Retrofit.Builder().baseUrl(mBaseUrl).addCallAdapterFactory(new LiveDataCallAdapterFactory(gson)).addConverterFactory(GsonConverterFactory.create(gson));
    Retrofit retrofit = builder.client(httpClient.addInterceptor(new ConnectivityInterceptor(application.getApplicationContext())).addInterceptor(new RequestInterceptor(prefsHelper)).build()).build();
    return retrofit.create(FogbugzApiService.class);
}
Also used : LiveDataCallAdapterFactory(com.bluestacks.bugzy.utils.LiveDataCallAdapterFactory) Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) GsonBuilder(com.google.gson.GsonBuilder) RequestInterceptor(com.bluestacks.bugzy.data.remote.RequestInterceptor) ConnectivityInterceptor(com.bluestacks.bugzy.data.remote.ConnectivityInterceptor) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Aggregations

ConnectivityInterceptor (com.bluestacks.bugzy.data.remote.ConnectivityInterceptor)1 RequestInterceptor (com.bluestacks.bugzy.data.remote.RequestInterceptor)1 LiveDataCallAdapterFactory (com.bluestacks.bugzy.utils.LiveDataCallAdapterFactory)1 GsonBuilder (com.google.gson.GsonBuilder)1 Provides (dagger.Provides)1 Singleton (javax.inject.Singleton)1 OkHttpClient (okhttp3.OkHttpClient)1 Retrofit (retrofit2.Retrofit)1