Skip to content

Commit

Permalink
Extract logic to private functions
Browse files Browse the repository at this point in the history
  • Loading branch information
AnasNaouchi committed Oct 31, 2023
1 parent f6e5059 commit 986aaa4
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions sdk/src/main/java/co/omise/android/ui/AuthorizingPaymentActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,8 @@ class AuthorizingPaymentActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_authorizing_payment)

supportActionBar?.title = uiCustomization.uiCustomization.toolbarCustomization?.headerText
?: getString(R.string.title_authorizing_payment)

val authUrl = verifier.authorizedURLString
// check for legacy payments that require web view
if (authUrl.endsWith("/pay")) {
setupWebView()
} else {
// Check if the URL needs to be opened externally
if (verifier.verifyExternalURL(verifier.authorizedURL)) {
openDeepLink(verifier.authorizedURL)
}
observeData()
}
setupActionBarTitle()
handlePaymentAuthorization()
}

@TestOnly
Expand Down Expand Up @@ -185,6 +172,25 @@ class AuthorizingPaymentActivity : AppCompatActivity() {
}
}

private fun setupActionBarTitle() {
supportActionBar?.title = uiCustomization.uiCustomization.toolbarCustomization?.headerText
?: getString(R.string.title_authorizing_payment)
}

private fun handlePaymentAuthorization() {
val authUrlString = verifier.authorizedURLString
val authUrl=verifier.authorizedURL
// check for legacy payments that require web view
if (authUrlString.endsWith("/pay")) {
setupWebView()
} else {
// Check if the URL needs to be opened externally
if (verifier.verifyExternalURL(authUrl)) {
openDeepLink(authUrl)
}
observeData()
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == REQUEST_EXTERNAL_CODE) {
Expand Down

0 comments on commit 986aaa4

Please sign in to comment.