From 986aaa445eeb3044fd86b8e22a82a3dbd2a9ad4e Mon Sep 17 00:00:00 2001 From: AnasNaouchi Date: Tue, 31 Oct 2023 13:05:58 +0700 Subject: [PATCH] Extract logic to private functions --- .../android/ui/AuthorizingPaymentActivity.kt | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/sdk/src/main/java/co/omise/android/ui/AuthorizingPaymentActivity.kt b/sdk/src/main/java/co/omise/android/ui/AuthorizingPaymentActivity.kt index 837b724ab..59712b18e 100644 --- a/sdk/src/main/java/co/omise/android/ui/AuthorizingPaymentActivity.kt +++ b/sdk/src/main/java/co/omise/android/ui/AuthorizingPaymentActivity.kt @@ -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 @@ -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) {