Created
October 7, 2019 13:36
-
-
Save hafs-r/18bd6b7a222cfcedd1ea082c5ae2e26e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Provides | |
@Singleton | |
internal fun provideOkhttpClient( | |
cache: Cache, | |
networkMonitor:NetworkMonitor, | |
@ApplicationContext context: Context, | |
eventBus: RxEventBus, | |
deviceType: CurrentDeviceType): OkHttpClient { | |
val client = OkHttpClient.Builder() | |
.cache(cache) | |
.connectTimeout(CONNECTION_TIME_OUT.toLong(),TimeUnit.SECONDS) | |
.readTimeout(READ_TIME_OUT.toLong(), TimeUnit.SECONDS) | |
.addNetworkInterceptor(TimberLoggingInterceptor()) | |
.addInterceptor(FakeInterceptor(context)) | |
return client.build() | |
} | |
@Provides | |
@Singleton | |
internal fun provideRetrofit( | |
gson: Gson, | |
okHttpClient: OkHttpClient): Retrofit { | |
val restAdapterBuilder = Retrofit.Builder() | |
.client(okHttpClient) | |
.baseUrl(Constants.API_BASE_URL) | |
.addConverterFactory(GsonConverterFactory.create(gson)) | |
.addCallAdapterFactory(RxJavaCallAdapterFactory.create()) | |
return restAdapterBuilder.build() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment