use of com.example.networking.BaseUrlInterceptor in project Just-Another-Android-App by athkalia.
the class NetworkModule method provideOkHttpClient.
@Provides
@Singleton
public static OkHttpClient provideOkHttpClient(PropertiesManager propertiesManager, HttpLoggingInterceptor httpLoggingInterceptor, List<Interceptor> networkInterceptors, BaseUrlInterceptor baseUrlInterceptor) {
final OkHttpClient.Builder okHttpBuilder = new OkHttpClient.Builder();
// Logs network calls for debug builds
okHttpBuilder.addInterceptor(httpLoggingInterceptor);
// Adds authentication headers when required in network calls
okHttpBuilder.addInterceptor(new AuthenticationInterceptor(propertiesManager));
// Helps with changing base url of network calls in espresso tests to the MockWebServer base url.
okHttpBuilder.addInterceptor(baseUrlInterceptor);
// For release builds nothing is added, the list is empty. For debug builds Stetho interceptor is added.
for (Interceptor networkInterceptor : networkInterceptors) {
okHttpBuilder.addNetworkInterceptor(networkInterceptor);
}
return okHttpBuilder.build();
}
Aggregations