Skip to content

Instantly share code, notes, and snippets.

@raghunandankavi2010
Last active January 2, 2019 15:03
Show Gist options
  • Save raghunandankavi2010/ef947aeb7ecdd54b47657ff7b970fda1 to your computer and use it in GitHub Desktop.
Save raghunandankavi2010/ef947aeb7ecdd54b47657ff7b970fda1 to your computer and use it in GitHub Desktop.
koin
class class RetrofitDependency : RetrofitInterface {
override fun provideRetrofit(): Retrofit {
val logging = HttpLoggingInterceptor()
logging.level = HttpLoggingInterceptor.Level.BASIC
val okHttpClient = OkHttpClient.Builder()
.addInterceptor(logging)
.connectTimeout(10, TimeUnit.SECONDS)
.writeTimeout(10, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build()
val moshi = Moshi.Builder()
.add(KotlinJsonAdapterFactory())
.build()
return Retrofit.Builder()
.baseUrl(BuildConfig.BASE_URL)
.client(okHttpClient)
.addConverterFactory(MoshiConverterFactory.create(moshi))
.build()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment