diff --git a/app/coinLoreAPI/build.gradle b/app/coinLoreAPI/build.gradle index 3f9fcdc..ff23364 100644 --- a/app/coinLoreAPI/build.gradle +++ b/app/coinLoreAPI/build.gradle @@ -47,9 +47,12 @@ dependencies { api("com.squareup.okhttp3:okhttp") api("com.squareup.okhttp3:logging-interceptor") + // Koin main features for Android api "io.insert-koin:koin-android:$koin_version" - // Jetpack Compose - implementation "io.insert-koin:koin-androidx-compose:$koin_version" + // Java Compatibility + api "io.insert-koin:koin-android-compat:$koin_version" + + //gson api("com.squareup.retrofit2:converter-gson:$gson_version") //coroutines diff --git a/app/coinLoreAPI/src/main/java/com/example/coinloreapi/api/CoinLoreAPI.kt b/app/coinLoreAPI/src/main/java/com/example/coinloreapi/api/CoinLoreAPI.kt index 5b5c638..085ce1b 100644 --- a/app/coinLoreAPI/src/main/java/com/example/coinloreapi/api/CoinLoreAPI.kt +++ b/app/coinLoreAPI/src/main/java/com/example/coinloreapi/api/CoinLoreAPI.kt @@ -4,7 +4,8 @@ import com.example.coinloreapi.models.GlobalCoinResponse import retrofit2.Response import retrofit2.http.GET -interface CoinLoreAPI { + +interface CoinLoreAPI{ @GET("api/global/") suspend fun getGlobalCoinData():Response diff --git a/app/coinLoreAPI/src/main/java/com/example/coinloreapi/di/RepositoryModule.kt b/app/coinLoreAPI/src/main/java/com/example/coinloreapi/di/RepositoryModule.kt index a732b06..df23070 100644 --- a/app/coinLoreAPI/src/main/java/com/example/coinloreapi/di/RepositoryModule.kt +++ b/app/coinLoreAPI/src/main/java/com/example/coinloreapi/di/RepositoryModule.kt @@ -1,13 +1,12 @@ package com.example.coinloreapi.di -import com.example.coinloreapi.api.CoinLoreAPI import com.example.coinloreapi.repository.GlobalCoinRepository import org.koin.dsl.module val repositoryModule = module { - single { provideGlobalCoinRepository(get()) } + single { provideGlobalCoinRepository() } } -fun provideGlobalCoinRepository(coinLoreAPI: CoinLoreAPI):GlobalCoinRepository{ - return GlobalCoinRepository(coinLoreAPI) +fun provideGlobalCoinRepository():GlobalCoinRepository{ + return GlobalCoinRepository() } \ No newline at end of file diff --git a/app/coinLoreAPI/src/main/java/com/example/coinloreapi/repository/GlobalCoinRepository.kt b/app/coinLoreAPI/src/main/java/com/example/coinloreapi/repository/GlobalCoinRepository.kt index 8dbbf68..431f836 100644 --- a/app/coinLoreAPI/src/main/java/com/example/coinloreapi/repository/GlobalCoinRepository.kt +++ b/app/coinLoreAPI/src/main/java/com/example/coinloreapi/repository/GlobalCoinRepository.kt @@ -2,17 +2,19 @@ package com.example.coinloreapi.repository import android.util.Log import com.example.coinloreapi.api.CoinLoreAPI + import com.example.coinloreapi.models.GlobalCoinResponse import com.example.coinloreapi.utils.NetworkState import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.withContext +import org.koin.java.KoinJavaComponent.inject + import java.io.IOException -class GlobalCoinRepository( - private val coinLoreAPI: CoinLoreAPI -) { +class GlobalCoinRepository { + private val coinLoreAPI: CoinLoreAPI by inject(CoinLoreAPI::class.java) private val TAG = GlobalCoinRepository::class.java.name suspend fun getGlobalCoin(): NetworkState = withContext(Dispatchers.IO) {