diff --git a/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/GrowthRecipeActivity.kt b/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/GrowthRecipeActivity.kt index 0f08b41..c280d11 100644 --- a/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/GrowthRecipeActivity.kt +++ b/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/GrowthRecipeActivity.kt @@ -5,7 +5,6 @@ import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import com.syaroful.agrilinkvocpro.growth_recipe_feature.di.appModule -import com.syaroful.agrilinkvocpro.growth_recipe_feature.di.clusterNetworkModule import com.syaroful.agrilinkvocpro.growth_recipe_feature.di.networkModule import com.syaroful.agrilinkvocpro.growth_recipe_feature.di.viewModelModule import com.syaroful.agrilinkvocpro.growth_recipe_feature.naviagtion.SetupNavigation @@ -17,18 +16,17 @@ class GrowthRecipeActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - loadKoinModules(listOf(appModule, networkModule, clusterNetworkModule, viewModelModule)) + loadKoinModules(listOf(appModule, networkModule, viewModelModule)) enableEdgeToEdge() setContent { AgrilinkVocproTheme { SetupNavigation() } - } } override fun onDestroy() { super.onDestroy() - unloadKoinModules(listOf(appModule, networkModule, clusterNetworkModule, viewModelModule)) + unloadKoinModules(listOf(appModule, networkModule, viewModelModule)) } } \ No newline at end of file diff --git a/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/di/ClusterNetwotkModule.kt b/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/di/ClusterNetwotkModule.kt deleted file mode 100644 index 052b95c..0000000 --- a/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/di/ClusterNetwotkModule.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.syaroful.agrilinkvocpro.growth_recipe_feature.di - -import com.syaroful.agrilinkvocpro.growth_recipe_feature.data.network.ClusteringService -import okhttp3.OkHttpClient -import org.koin.dsl.module -import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory -import java.util.concurrent.TimeUnit - -val clusterNetworkModule = module { - single { - OkHttpClient.Builder() - .connectTimeout(5, TimeUnit.SECONDS) - .build() - } - - single { - Retrofit.Builder() - .baseUrl("http://labai.polinema.ac.id:5050/") - .client(get()) - .addConverterFactory(GsonConverterFactory.create()) - .build() - } - - single { get().create(ClusteringService::class.java) } -} \ No newline at end of file diff --git a/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/di/NetworkModule.kt b/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/di/NetworkModule.kt index 2d85b5e..8baf570 100644 --- a/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/di/NetworkModule.kt +++ b/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/di/NetworkModule.kt @@ -1,26 +1,57 @@ package com.syaroful.agrilinkvocpro.growth_recipe_feature.di +import com.syaroful.agrilinkvocpro.growth_recipe_feature.data.network.ClusteringService import com.syaroful.agrilinkvocpro.growth_recipe_feature.data.network.GrowthRecipeService import okhttp3.OkHttpClient +import org.koin.core.qualifier.named import org.koin.dsl.module import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import java.util.concurrent.TimeUnit +val CLUSTER_CLIENT = named("CLUSTER_CLIENT") +val CLUSTER_RETROFIT = named("CLUSTER_RETROFIT") + +val RECIPE_CLIENT = named("RECIPE_CLIENT") +val RECIPE_RETROFIT = named("RECIPE_RETROFIT") + val networkModule = module { - single { + + // Cluster client and retrofit + single(CLUSTER_CLIENT) { + OkHttpClient.Builder() + .connectTimeout(5, TimeUnit.SECONDS) + .build() + } + + single(CLUSTER_RETROFIT) { + Retrofit.Builder() + .baseUrl("http://labai.polinema.ac.id:5050/") + .client(get(CLUSTER_CLIENT)) + .addConverterFactory(GsonConverterFactory.create()) + .build() + } + + single { + get(CLUSTER_RETROFIT).create(ClusteringService::class.java) + } + + // Growth Recipe client and retrofit + single(RECIPE_CLIENT) { OkHttpClient.Builder() .connectTimeout(2, TimeUnit.SECONDS) .build() } - single { + single(RECIPE_RETROFIT) { Retrofit.Builder() .baseUrl("http://labai.polinema.ac.id:3042/") - .client(get()) + .client(get(RECIPE_CLIENT)) .addConverterFactory(GsonConverterFactory.create()) .build() } - single { get().create(GrowthRecipeService::class.java) } + single { + get(RECIPE_RETROFIT).create(GrowthRecipeService::class.java) + } } \ No newline at end of file diff --git a/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/presentation/recipe/GrowthRecipeScreen.kt b/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/presentation/recipe/GrowthRecipeScreen.kt index cac9172..c766dd0 100644 --- a/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/presentation/recipe/GrowthRecipeScreen.kt +++ b/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/presentation/recipe/GrowthRecipeScreen.kt @@ -137,7 +137,6 @@ fun GrowthRecipeScreen( } when (graphicState) { is ResultState.Loading -> { - isRefreshing.value = true Row { Box( modifier = Modifier diff --git a/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/presentation/recipe/GrowthRecipeViewModel.kt b/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/presentation/recipe/GrowthRecipeViewModel.kt index 70c54ea..87f4bb1 100644 --- a/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/presentation/recipe/GrowthRecipeViewModel.kt +++ b/agrilinkvocpro/growth_recipe_feature/src/main/java/com/syaroful/agrilinkvocpro/growth_recipe_feature/presentation/recipe/GrowthRecipeViewModel.kt @@ -18,6 +18,7 @@ import java.util.Date private const val TAG = "GrowthRecipeViewModel" + class GrowthRecipeViewModel( private val userPreferences: UserPreferences, private val growthRecipeRepository: GraphicDataRepository @@ -25,7 +26,8 @@ class GrowthRecipeViewModel( private val _getGraphicState = MutableStateFlow>(ResultState.Idle) - val getGraphicState: StateFlow> = _getGraphicState.asStateFlow() + val getGraphicState: StateFlow> = + _getGraphicState.asStateFlow() private val today = Date() private val tenDaysAgo = Date(today.time - 9 * 24 * 60 * 60 * 1000)