From da6b68fd2ef0976e388b0031161feab9e56cecf3 Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Tue, 27 Oct 2020 21:30:26 +0100 Subject: [PATCH] Use a different retrofit builder for each service --- .../main/java/com/readrops/api/ApiModule.kt | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/api/src/main/java/com/readrops/api/ApiModule.kt b/api/src/main/java/com/readrops/api/ApiModule.kt index 81d9b800..677dc8ad 100644 --- a/api/src/main/java/com/readrops/api/ApiModule.kt +++ b/api/src/main/java/com/readrops/api/ApiModule.kt @@ -23,6 +23,8 @@ import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory import retrofit2.converter.moshi.MoshiConverterFactory import java.util.concurrent.TimeUnit +const val BASE_URL = "https://baseurl.com" + val apiModule = module { single(createdAtStart = true) { @@ -38,7 +40,7 @@ val apiModule = module { //region freshrss single { - FreshRSSDataSource(get()) + FreshRSSDataSource(get()) } single { @@ -47,7 +49,10 @@ val apiModule = module { } single(named("freshrssRetrofit")) { - get() + Retrofit.Builder() // url will be set dynamically in an interceptor + .baseUrl(BASE_URL) + .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) + .client(get()) .addConverterFactory(MoshiConverterFactory.create(get(named("freshrssMoshi")))) .build() } @@ -65,7 +70,7 @@ val apiModule = module { //region nextcloud news single { - NextNewsDataSource(get()) + NextNewsDataSource(get()) } single { @@ -74,7 +79,10 @@ val apiModule = module { } single(named("nextcloudNewsRetrofit")) { - get() + Retrofit.Builder() // url will be set dynamically in an interceptor + .baseUrl(BASE_URL) + .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) + .client(get()) .addConverterFactory(MoshiConverterFactory.create(get(named("nextcloudNewsMoshi")))) .build() } @@ -89,13 +97,6 @@ val apiModule = module { //endregion nextcloud news - single { - Retrofit.Builder() // url will be set dynamically in an interceptor - .baseUrl("https://baseurl.com") - .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) - .client(get()) - } - single { AuthInterceptor() }