Skip to content

Commit

Permalink
removed unnecessary parameter in main API class
Browse files Browse the repository at this point in the history
  • Loading branch information
iankang committed Mar 12, 2022
1 parent 2b69e13 commit 570030e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
7 changes: 5 additions & 2 deletions app/coinLoreAPI/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GlobalCoinResponse>
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<GlobalCoinResponse> = withContext(Dispatchers.IO) {
Expand Down

0 comments on commit 570030e

Please sign in to comment.