diff --git a/README.md b/README.md index 5200140c..a3457156 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,9 @@ ``` > app build.gradle -[$SDK_VERSION][5] +[$SDK-VERSION][5] ```gradle - implementation 'com.github.iamport:iamport-android:$SDK_VERSION' + implementation 'com.github.iamport:iamport-android:$SDK-VERSION' ``` [5]: https://github.com/iamport/iamport-android/releases @@ -45,6 +45,31 @@ ### KOTLIN usage > 필수구현 사항 +```kotlin + + // 일반적인 경우 + // 사용하시는 안드로이드 어플리케이션 클래스에 추가하세요 + class BaseApplication : Application() { + override fun onCreate() { + .. + Iamport.create(this) + } + } + + // DI 로 koin 을 사용하시는 경우 + // 생성된 koinApplication 을 파라미터로 넘겨주셔야 합니다 + class BaseApplication : Application() { + override fun onCreate() { + .. + val koinApp = startKoin { .. } + Iamport.create(this, koinApp) + } + + // KoinApplication 이 필요한 경우 + Iamport.getKoinApplition() +} + +``` ```kotlin // SDK 초기화 @@ -139,16 +164,41 @@ Iamport.isPolling()?.observe 에서 true 전달 받을 시점에, 직접 포그 ### JAVA usage > 자바 프로젝트에선 app build.gradle 에서 kotin-stblib 추가가 필요합니다 -[$코틀린_버전][4] +[$코틀린-버전][4] ```gradle - implementation "org.jetbrains.kotlin:kotlin-stdlib:$코틀린_버전" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$코틀린-버전" ``` > 필수구현 사항. SDK 제공 api 별 설명은 위의 [KOTLIN usage][6] 를 참고하세요. [6]:https://github.com/iamport/iamport-android#kotlin-usage +```java + // 일반적인 경우 + // 사용하시는 안드로이드 어플리케이션 클래스에 추가하세요 + public class BaseApplication extends Application { + @Override + public void onCreate() { + .. + Iamport.INSTANCE.create(this, null); + } + } + + // DI 로 koin 을 사용하시는 경우 + // 생성된 koinApplication 을 파라미터로 넘겨주셔야 합니다 + public class BaseApplication extends Application { + @Override + public void onCreate() { + .. + KoinApplication koinApp = .. + Iamport.INSTANCE.create(this, koinApp); + } + } + +``` + + ```java @Override @@ -237,6 +287,24 @@ Iamport.isPolling()?.observe 에서 true 전달 받을 시점에, 직접 포그 --- +[BaseApplication.kt (SDK 생성)](./app/src/main/java/com/iamport/sampleapp/BaseApplication.kt) + +```kotlin + override fun onCreate() { + super.onCreate() + Iamport.create(this) + + /** + * DI 로 KOIN 사용시 아래와 같이 사용 + val koinApp = startKoin { + logger(AndroidLogger(Level.DEBUG)) + androidContext(this@BaseApplication) + } + Iamport.create(this, koinApp) + */ + } +``` + [PaymentFragment.kt (결제 화면)](./app/src/main/java/com/iamport/sampleapp/ui/PaymentFragment.kt) ```kotlin diff --git a/app/build.gradle b/app/build.gradle index 7c67e9e9..0e38354b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -67,7 +67,7 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0' - implementation "com.google.android.material:material:1.3.0-beta01" + implementation "com.google.android.material:material:1.3.0-rc01" // multidex implementation 'androidx.multidex:multidex:2.0.1' @@ -78,8 +78,18 @@ dependencies { // Logger implementation 'com.orhanobut:logger:2.2.0' -// implementation project(':sdk') - implementation 'com.github.iamport:iamport-android:0.0.3-dev01' + implementation "org.koin:koin-androidx-scope:$koin_version" +// Koin AndroidX ViewModel features + implementation "org.koin:koin-androidx-viewmodel:$koin_version" +// Koin AndroidX Fragment features + implementation "org.koin:koin-androidx-fragment:$koin_version" +// Koin AndroidX WorkManager + implementation "org.koin:koin-androidx-workmanager:$koin_version" +// Koin AndroidX Jetpack Compose + implementation "org.koin:koin-androidx-compose:$koin_version" +// Koin AndroidX Experimental features + implementation "org.koin:koin-androidx-ext:$koin_version" + // implementation 'com.github.iamport:iamport-android:dev-SNAPSHOT' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 54200e5e..89fbd1d1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,6 +7,7 @@ diff --git a/sdk/src/main/java/com/iamport/sdk/data/chai/response/UserData.kt b/sdk/src/main/java/com/iamport/sdk/data/chai/response/UserData.kt index 5b517a17..247a9bc5 100644 --- a/sdk/src/main/java/com/iamport/sdk/data/chai/response/UserData.kt +++ b/sdk/src/main/java/com/iamport/sdk/data/chai/response/UserData.kt @@ -5,6 +5,6 @@ import com.iamport.sdk.data.sdk.PG data class UserData( val pg_provider: PG?, // TODO: 2020-12-15 015 nullable 로 오는데.. 확인필요.. val pg_id: String, - val sandbox: Boolean, + val sandbox: Boolean?, val type: String, ) \ No newline at end of file diff --git a/sdk/src/main/java/com/iamport/sdk/domain/JsNativeInterface.kt b/sdk/src/main/java/com/iamport/sdk/domain/JsNativeInterface.kt index 4b6cc237..8089f2f6 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/JsNativeInterface.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/JsNativeInterface.kt @@ -4,14 +4,14 @@ import android.webkit.JavascriptInterface import com.google.gson.Gson import com.iamport.sdk.data.sdk.IamPortResponse import com.iamport.sdk.data.sdk.Payment +import com.iamport.sdk.domain.di.IamportKoinComponent import com.iamport.sdk.domain.utils.Event import com.iamport.sdk.domain.utils.WebViewLiveDataEventBus import com.orhanobut.logger.Logger import org.koin.core.component.KoinApiExtension -import org.koin.core.component.KoinComponent @KoinApiExtension -class JsNativeInterface(val payment: Payment, val gson: Gson, private val bus: WebViewLiveDataEventBus) : KoinComponent { +class JsNativeInterface(val payment: Payment, val gson: Gson, private val bus: WebViewLiveDataEventBus) : IamportKoinComponent { /** * 아임포트 JS SDK 에게 유저코드 전달§ diff --git a/sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt b/sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt index 78205e1d..69f96808 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt @@ -1,22 +1,40 @@ package com.iamport.sdk.domain.core +import android.app.Application +import android.util.Log import androidx.activity.ComponentActivity import androidx.activity.result.ActivityResultLauncher import androidx.annotation.MainThread import androidx.fragment.app.Fragment import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData +import com.iamport.sdk.BuildConfig.DEBUG import com.iamport.sdk.data.sdk.IamPortApprove import com.iamport.sdk.data.sdk.IamPortRequest import com.iamport.sdk.data.sdk.IamPortResponse import com.iamport.sdk.data.sdk.Payment +import com.iamport.sdk.domain.di.IamportKoinContext +import com.iamport.sdk.domain.di.IamportKoinContext.koinApp +import com.iamport.sdk.domain.di.apiModule +import com.iamport.sdk.domain.di.appModule +import com.iamport.sdk.domain.di.httpClientModule import com.iamport.sdk.domain.service.ChaiService -import com.iamport.sdk.domain.utils.PreventOverlapRun +import com.iamport.sdk.domain.utils.CONST import com.iamport.sdk.domain.utils.Event +import com.iamport.sdk.domain.utils.Foreground +import com.iamport.sdk.domain.utils.PreventOverlapRun import com.iamport.sdk.presentation.activity.IamportSdk import com.iamport.sdk.presentation.contract.WebViewActivityContract +import com.orhanobut.logger.AndroidLogAdapter +import com.orhanobut.logger.Logger import com.orhanobut.logger.Logger.d +import com.orhanobut.logger.PrettyFormatStrategy +import org.koin.android.ext.koin.androidContext +import org.koin.android.logger.AndroidLogger +import org.koin.core.KoinApplication import org.koin.core.component.KoinApiExtension +import org.koin.core.context.startKoin +import org.koin.core.logger.Level object Iamport { @@ -32,10 +50,12 @@ object Iamport { private var close = MutableLiveData>() private var finish = MutableLiveData>() - var activity: ComponentActivity? = null + private var activity: ComponentActivity? = null private var fragment: Fragment? = null private var preventOverlapRun: PreventOverlapRun? = null + private var isCreated = false + private fun clear() { fragment = null activity = null @@ -49,12 +69,63 @@ object Iamport { this.preventOverlapRun = PreventOverlapRun() } + private fun iamportCreated(): Boolean { + if (!isCreated) { + Log.e(CONST.IAMPORT_LOG, "IAMPORT SDK was not created. Please initialize it in Application class") + } + return isCreated + } + + fun getKoinApplition(): KoinApplication? { + return koinApp + } + + /** + * Application instance 를 통해 SDK 생명주기 감지, DI 초기화 + */ + fun create(app: Application, koinApp: KoinApplication? = null) { + + IamportKoinContext.koinApp = koinApp + ?: startKoin { + logger(AndroidLogger(Level.DEBUG)) + androidContext(app) + modules(httpClientModule, apiModule, appModule) + } + + Foreground.init(app) + + val logBuilder = PrettyFormatStrategy.newBuilder() + val formatStrategy: PrettyFormatStrategy = if (DEBUG) { + logBuilder + .methodCount(3) + .tag(CONST.IAMPORT_LOG) + .build() + } else { + logBuilder + .showThreadInfo(false) // (Optional) Whether to show thread info or not. Default true + .methodCount(0) // (Optional) How many method line to show. Default 2 + .methodOffset(5) // (Optional) Hides internal method calls up to offset. Default 5 + .tag(CONST.IAMPORT_LOG) + .build() + } + Logger.addLogAdapter(AndroidLogAdapter(formatStrategy)) + + isCreated = true + d("Create IAMPORT SDK") + } + /** * SDK Activity 열기 위한 Contract for Activity * @param componentActivity : Host Activity */ fun init(componentActivity: ComponentActivity) { - d("init") + + if (!iamportCreated()) { + return + } + + d("INITIALIZE IAMPORT SDK for activity") + clear() createInitialData() @@ -78,7 +149,13 @@ object Iamport { * @param fragment : Host Fragment */ fun init(fragment: Fragment) { - d("init") + + if (!iamportCreated()) { + return + } + + d("INITIALIZE IAMPORT SDK for fragment") + clear() createInitialData() diff --git a/sdk/src/main/java/com/iamport/sdk/domain/di/IamportKoinComponent.kt b/sdk/src/main/java/com/iamport/sdk/domain/di/IamportKoinComponent.kt new file mode 100644 index 00000000..9cc52399 --- /dev/null +++ b/sdk/src/main/java/com/iamport/sdk/domain/di/IamportKoinComponent.kt @@ -0,0 +1,14 @@ +package com.iamport.sdk.domain.di + +import org.koin.core.Koin +import org.koin.core.KoinApplication +import org.koin.core.component.KoinComponent + +// lib module +object IamportKoinContext { + var koinApp: KoinApplication? = null +} + +interface IamportKoinComponent : KoinComponent { + override fun getKoin(): Koin = IamportKoinContext.koinApp?.koin!! +} diff --git a/sdk/src/main/java/com/iamport/sdk/domain/repository/StrategyRepository.kt b/sdk/src/main/java/com/iamport/sdk/domain/repository/StrategyRepository.kt index 595913b5..196eac66 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/repository/StrategyRepository.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/repository/StrategyRepository.kt @@ -4,6 +4,7 @@ import android.webkit.WebViewClient import com.iamport.sdk.data.sdk.PG import com.iamport.sdk.data.sdk.PayMethod import com.iamport.sdk.data.sdk.Payment +import com.iamport.sdk.domain.di.IamportKoinComponent import com.iamport.sdk.domain.strategy.base.IStrategy import com.iamport.sdk.domain.strategy.base.JudgeStrategy import com.iamport.sdk.domain.strategy.chai.ChaiStrategy @@ -11,11 +12,10 @@ import com.iamport.sdk.domain.strategy.webview.NiceTransWebViewStrategy import com.iamport.sdk.domain.strategy.webview.WebViewStrategy import com.orhanobut.logger.Logger import org.koin.core.component.KoinApiExtension -import org.koin.core.component.KoinComponent import org.koin.core.component.inject @KoinApiExtension -class StrategyRepository : KoinComponent { +class StrategyRepository : IamportKoinComponent { val judgeStrategy: JudgeStrategy by inject() // 결제 중 BG 폴링하는 차이 전략 val chaiStrategy: ChaiStrategy by inject() // 결제 중 BG 폴링하는 차이 전략 diff --git a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseStrategy.kt b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseStrategy.kt index 094d387b..0cd12f84 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseStrategy.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseStrategy.kt @@ -3,15 +3,15 @@ package com.iamport.sdk.domain.strategy.base import com.google.gson.Gson import com.iamport.sdk.data.sdk.IamPortResponse import com.iamport.sdk.data.sdk.Payment +import com.iamport.sdk.domain.di.IamportKoinComponent import com.iamport.sdk.domain.utils.Event import com.iamport.sdk.domain.utils.NativeLiveDataEventBus import kotlinx.coroutines.CancellationException import org.koin.core.component.KoinApiExtension -import org.koin.core.component.KoinComponent import org.koin.core.component.inject @KoinApiExtension -abstract class BaseStrategy : IStrategy, KoinComponent { +abstract class BaseStrategy : IStrategy, IamportKoinComponent { protected val gson: Gson by inject() protected val bus: NativeLiveDataEventBus by inject() diff --git a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseWebViewStrategy.kt b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseWebViewStrategy.kt index 28ea4c72..04c52af4 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseWebViewStrategy.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseWebViewStrategy.kt @@ -8,16 +8,16 @@ import androidx.annotation.RequiresApi import com.google.gson.Gson import com.iamport.sdk.data.sdk.IamPortResponse import com.iamport.sdk.data.sdk.Payment +import com.iamport.sdk.domain.di.IamportKoinComponent import com.iamport.sdk.domain.utils.CONST import com.iamport.sdk.domain.utils.Event import com.iamport.sdk.domain.utils.WebViewLiveDataEventBus import com.orhanobut.logger.Logger.d import org.koin.core.component.KoinApiExtension -import org.koin.core.component.KoinComponent import org.koin.core.component.inject @KoinApiExtension -open class BaseWebViewStrategy : WebViewClient(), IStrategy, KoinComponent { +open class BaseWebViewStrategy : WebViewClient(), IStrategy, IamportKoinComponent { protected val gson: Gson by inject() protected val bus: WebViewLiveDataEventBus by inject() diff --git a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/JudgeStrategy.kt b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/JudgeStrategy.kt index 2c0f333b..88311390 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/JudgeStrategy.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/JudgeStrategy.kt @@ -7,14 +7,14 @@ import com.iamport.sdk.data.remote.IamportApi import com.iamport.sdk.data.remote.ResultWrapper import com.iamport.sdk.data.sdk.PG import com.iamport.sdk.data.sdk.Payment +import com.iamport.sdk.domain.di.IamportKoinComponent import com.orhanobut.logger.Logger import kotlinx.coroutines.Dispatchers import org.koin.core.component.KoinApiExtension -import org.koin.core.component.KoinComponent import org.koin.core.component.inject @KoinApiExtension -class JudgeStrategy : BaseStrategy(), KoinComponent { +class JudgeStrategy : BaseStrategy(), IamportKoinComponent { // 유저 정보 판단 결과 타입 enum class JudgeKinds { @@ -67,8 +67,17 @@ class JudgeStrategy : BaseStrategy(), KoinComponent { } Logger.d("userDataList :: $userDataList") - val myPg = payment.iamPortRequest.pg.split(".")[0] - return when (val user = userDataList.find { it.pg_provider?.getPgSting() == myPg }) { + val split = payment.iamPortRequest.pg.split(".") + val myPg = split[0] + val user = userDataList.find { + if (split.size > 1) { + it.pg_provider?.getPgSting() == myPg && it.pg_id == split[1] + } else { + it.pg_provider?.getPgSting() == myPg + } + } + + return when (user) { null -> defUser.let { getPgTriple(it, replacePG(it.pg_provider!!, payment)) } // user 를 찾지 못하면 디폴트 값 사용 else -> getPgTriple(user, payment) diff --git a/sdk/src/main/java/com/iamport/sdk/domain/strategy/webview/WebViewStrategy.kt b/sdk/src/main/java/com/iamport/sdk/domain/strategy/webview/WebViewStrategy.kt index 29e5c618..3e6ef2cc 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/strategy/webview/WebViewStrategy.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/strategy/webview/WebViewStrategy.kt @@ -1,6 +1,8 @@ package com.iamport.sdk.domain.strategy.webview +import android.net.Uri import android.os.Build +import android.webkit.WebResourceError import android.webkit.WebResourceRequest import android.webkit.WebView import androidx.annotation.RequiresApi @@ -21,6 +23,19 @@ open class WebViewStrategy : BaseWebViewStrategy() { bus.openWebView.postValue(Event(payment)) } + @RequiresApi(Build.VERSION_CODES.M) + override fun onReceivedError(view: WebView?, request: WebResourceRequest?, error: WebResourceError?) { + request?.url?.let { + if (isPaymentOver(it)) { + paymentOver(it) + } else { + super.onReceivedError(view, request, error) + } + } ?: run { + super.onReceivedError(view, request, error) + } + } + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean { @@ -33,13 +48,20 @@ open class WebViewStrategy : BaseWebViewStrategy() { } if (isPaymentOver(it)) { - val response = Util.getQueryStringToImpResponse(it, gson) - d("paymentOver :: $response") - sdkFinish(response) + paymentOver(it) return true } } return super.shouldOverrideUrlLoading(view, request) } + + @RequiresApi(Build.VERSION_CODES.KITKAT) + fun paymentOver(uri: Uri) { + val response = Util.getQueryStringToImpResponse(uri, gson) + d("paymentOver :: $response") + sdkFinish(response) + } + + } \ No newline at end of file diff --git a/sdk/src/main/java/com/iamport/sdk/presentation/App.kt b/sdk/src/main/java/com/iamport/sdk/presentation/App.kt deleted file mode 100644 index 068140d7..00000000 --- a/sdk/src/main/java/com/iamport/sdk/presentation/App.kt +++ /dev/null @@ -1,47 +0,0 @@ -package com.iamport.sdk.presentation - -import android.app.Application -import com.iamport.sdk.BuildConfig.DEBUG -import com.iamport.sdk.domain.di.apiModule -import com.iamport.sdk.domain.di.appModule -import com.iamport.sdk.domain.di.httpClientModule -import com.iamport.sdk.domain.utils.CONST -import com.iamport.sdk.domain.utils.Foreground -import com.orhanobut.logger.AndroidLogAdapter -import com.orhanobut.logger.Logger -import com.orhanobut.logger.PrettyFormatStrategy -import org.koin.android.ext.koin.androidContext -import org.koin.android.logger.AndroidLogger -import org.koin.core.context.startKoin -import org.koin.core.logger.Level - -class App : Application() { - - override fun onCreate() { - super.onCreate() - - Foreground.init(this) - - val formatStrategy: PrettyFormatStrategy = if (DEBUG) { - PrettyFormatStrategy.newBuilder() - .methodCount(3) - .tag(CONST.IAMPORT_LOG) - .build() - } else { - PrettyFormatStrategy.newBuilder() - .showThreadInfo(false) // (Optional) Whether to show thread info or not. Default true - .methodCount(0) // (Optional) How many method line to show. Default 2 - .methodOffset(5) // (Optional) Hides internal method calls up to offset. Default 5 - .tag(CONST.IAMPORT_LOG) - .build() - } - Logger.addLogAdapter(AndroidLogAdapter(formatStrategy)) - - startKoin { - logger(AndroidLogger(Level.DEBUG)) - androidContext(this@App) - modules(httpClientModule, apiModule, appModule) - } - - } -} \ No newline at end of file diff --git a/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamportSdk.kt b/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamportSdk.kt index 43517942..e4e75985 100644 --- a/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamportSdk.kt +++ b/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamportSdk.kt @@ -14,6 +14,7 @@ import com.iamport.sdk.data.sdk.IamPortResponse import com.iamport.sdk.data.sdk.Payment import com.iamport.sdk.data.sdk.ProvidePgPkg import com.iamport.sdk.domain.core.IamportReceiver +import com.iamport.sdk.domain.di.IamportKoinComponent import com.iamport.sdk.domain.service.ChaiService import com.iamport.sdk.domain.utils.* import com.iamport.sdk.domain.utils.Util.observeAlways @@ -22,7 +23,6 @@ import com.iamport.sdk.presentation.viewmodel.MainViewModel import com.orhanobut.logger.Logger.* import org.koin.androidx.viewmodel.compat.ViewModelCompat.viewModel import org.koin.core.component.KoinApiExtension -import org.koin.core.component.KoinComponent import org.koin.core.component.inject import java.util.* @@ -35,7 +35,7 @@ internal class IamportSdk( val approvePayment: LiveData>, val close: LiveData>, val finish: LiveData>, -) : KoinComponent { +) : IamportKoinComponent { private val hostHelper: HostHelper = HostHelper(activity, fragment) diff --git a/sdk/src/main/java/com/iamport/sdk/presentation/activity/WebViewActivity.kt b/sdk/src/main/java/com/iamport/sdk/presentation/activity/WebViewActivity.kt index dacd76ba..8d584a6d 100644 --- a/sdk/src/main/java/com/iamport/sdk/presentation/activity/WebViewActivity.kt +++ b/sdk/src/main/java/com/iamport/sdk/presentation/activity/WebViewActivity.kt @@ -13,6 +13,7 @@ import com.iamport.sdk.data.sdk.ProvidePgPkg import com.iamport.sdk.databinding.WebviewActivityBinding import com.iamport.sdk.domain.IamportWebChromeClient import com.iamport.sdk.domain.JsNativeInterface +import com.iamport.sdk.domain.di.IamportKoinComponent import com.iamport.sdk.domain.utils.CONST import com.iamport.sdk.domain.utils.EventObserver import com.iamport.sdk.domain.utils.Util @@ -22,11 +23,10 @@ import com.orhanobut.logger.Logger.* import org.koin.android.ext.android.get import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.component.KoinApiExtension -import org.koin.core.component.KoinComponent @KoinApiExtension -class WebViewActivity : BaseActivity(), KoinComponent { +class WebViewActivity : BaseActivity(), IamportKoinComponent { override val layoutResourceId: Int = R.layout.webview_activity override val viewModel: WebViewModel by viewModel() diff --git a/sdk/src/main/java/com/iamport/sdk/presentation/viewmodel/MainViewModel.kt b/sdk/src/main/java/com/iamport/sdk/presentation/viewmodel/MainViewModel.kt index 06e37f26..85980538 100644 --- a/sdk/src/main/java/com/iamport/sdk/presentation/viewmodel/MainViewModel.kt +++ b/sdk/src/main/java/com/iamport/sdk/presentation/viewmodel/MainViewModel.kt @@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope import com.iamport.sdk.data.sdk.IamPortApprove import com.iamport.sdk.data.sdk.IamPortResponse import com.iamport.sdk.data.sdk.Payment +import com.iamport.sdk.domain.di.IamportKoinComponent import com.iamport.sdk.domain.repository.StrategyRepository import com.iamport.sdk.domain.strategy.base.JudgeStrategy import com.iamport.sdk.domain.utils.Event @@ -15,10 +16,9 @@ import com.orhanobut.logger.Logger.i import kotlinx.coroutines.Job import kotlinx.coroutines.launch import org.koin.core.component.KoinApiExtension -import org.koin.core.component.KoinComponent @KoinApiExtension -class MainViewModel(private val bus: NativeLiveDataEventBus, private val repository: StrategyRepository) : BaseViewModel(), KoinComponent { +class MainViewModel(private val bus: NativeLiveDataEventBus, private val repository: StrategyRepository) : BaseViewModel(), IamportKoinComponent { private var job = Job() get() { diff --git a/sdk/src/main/java/com/iamport/sdk/presentation/viewmodel/WebViewModel.kt b/sdk/src/main/java/com/iamport/sdk/presentation/viewmodel/WebViewModel.kt index 36d09f36..5d328ad3 100644 --- a/sdk/src/main/java/com/iamport/sdk/presentation/viewmodel/WebViewModel.kt +++ b/sdk/src/main/java/com/iamport/sdk/presentation/viewmodel/WebViewModel.kt @@ -6,17 +6,16 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.viewModelScope import com.iamport.sdk.data.sdk.IamPortResponse import com.iamport.sdk.data.sdk.Payment +import com.iamport.sdk.domain.di.IamportKoinComponent import com.iamport.sdk.domain.repository.StrategyRepository import com.iamport.sdk.domain.utils.Event import com.iamport.sdk.domain.utils.WebViewLiveDataEventBus import com.orhanobut.logger.Logger.d import kotlinx.coroutines.launch import org.koin.core.component.KoinApiExtension -import org.koin.core.component.KoinComponent -import org.koin.core.component.inject @KoinApiExtension -class WebViewModel(private val bus: WebViewLiveDataEventBus, private val repository: StrategyRepository) : BaseViewModel(), KoinComponent { +class WebViewModel(private val bus: WebViewLiveDataEventBus, private val repository: StrategyRepository) : BaseViewModel(), IamportKoinComponent { override fun onCleared() { d("onCleared")