Skip to content

Commit

Permalink
feat : divide new activity mode, webview mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kjh5833 committed Apr 5, 2021
1 parent 06ebe45 commit 7bc01b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 31 deletions.
32 changes: 5 additions & 27 deletions sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ internal class IamportSdk(
clearData()
}

// webview 모드임
// webview 사용 모드
fun setWebView(webview: WebView) {
this.webview = webview
}
Expand Down Expand Up @@ -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 모드
}
}

Expand Down

0 comments on commit 7bc01b1

Please sign in to comment.