From 7bc01b1c3f48d8adae0b7bb083e60995a059e35a Mon Sep 17 00:00:00 2001 From: bingbong Date: Mon, 5 Apr 2021 14:59:07 +0900 Subject: [PATCH] feat : divide new activity mode, webview mode --- .../com/iamport/sdk/domain/core/Iamport.kt | 32 +++---------------- .../sdk/presentation/activity/IamportSdk.kt | 9 +++--- 2 files changed, 10 insertions(+), 31 deletions(-) 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 80b25d05..468bdae0 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 @@ -161,34 +161,12 @@ object Iamport { } - // TODO 이거 쓰자 - fun init(componentActivity: ComponentActivity, webView: WebView) { - - if (!iamportCreated()) { - return - } - - d("INITIALIZE IAMPORT SDK for activity") - - clear() - createInitialData() - - // TODO 웹뷰 액티비티에 대한 응답 콜백이었음 -// webViewLauncher = componentActivity.registerForActivityResult(WebViewActivityContract()) { -// callback(it) -// } - - this.activity = componentActivity - this.iamportSdk = - IamportSdk( - activity = componentActivity, - webViewLauncher = webViewLauncher, - webView = webView, - close = close, - finish = finish - ) + // webview 사용 모드 + fun setWebView(webview : WebView) { + iamportSdk?.setWebView(webview) } + /** * SDK Activity 열기 위한 Contract for Fragment * @param fragment : Host Fragment @@ -254,7 +232,7 @@ object Iamport { return isPolling()?.value?.peekContent() ?: false } - private val callback = fun(iamPortResponse: IamPortResponse?) { + val callback = fun(iamPortResponse: IamPortResponse?) { // impCallbackImpl?.result(iamPortResponse) impCallbackFunction?.invoke(iamPortResponse) } 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 d7cb330e..33f6563d 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 @@ -85,7 +85,7 @@ internal class IamportSdk( clearData() } - // webview 모드임 + // webview 사용 모드 fun setWebView(webview: WebView) { this.webview = webview } @@ -311,14 +311,15 @@ internal class IamportSdk( private fun requestWebViewPayment(it: Payment) { d("requestWebViewPayment $it") clearData() - activity?.let { activity -> - webview?.let { webView -> + webview?.let { webView -> + hostHelper.activity?.let { activity -> IamPortWebView().initStart(activity, webView, it) // webview only 모드 } ?: run { + w("Cannot found activity, So running activity mode") webViewLauncher?.launch(it) // new activity 모드 } } ?: run { - e("Cannot found activity") + webViewLauncher?.launch(it) // new activity 모드 } }