From c9801e81d796746879cb585e348b1fb6b12282b1 Mon Sep 17 00:00:00 2001 From: pinpong Date: Wed, 26 Apr 2023 21:14:11 +0200 Subject: [PATCH] dismiss dialog on hot reload --- .../main/java/com/adyenreactnativesdk/action/ActionHandler.kt | 2 +- .../main/java/com/adyenreactnativesdk/component/BaseModule.kt | 4 ++++ .../component/googlepay/AdyenGooglePayComponent.kt | 4 ++++ .../component/instant/AdyenInstantComponent.kt | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/adyenreactnativesdk/action/ActionHandler.kt b/android/src/main/java/com/adyenreactnativesdk/action/ActionHandler.kt index 41b13d570..d8218a788 100644 --- a/android/src/main/java/com/adyenreactnativesdk/action/ActionHandler.kt +++ b/android/src/main/java/com/adyenreactnativesdk/action/ActionHandler.kt @@ -103,7 +103,7 @@ class ActionHandler( } } - fun hide(activity: FragmentActivity) { + fun hide() { dialog.get()?.dismiss() dialog.clear() loadedComponent = null diff --git a/android/src/main/java/com/adyenreactnativesdk/component/BaseModule.kt b/android/src/main/java/com/adyenreactnativesdk/component/BaseModule.kt index e9d0551b6..b8d97c7f4 100644 --- a/android/src/main/java/com/adyenreactnativesdk/component/BaseModule.kt +++ b/android/src/main/java/com/adyenreactnativesdk/component/BaseModule.kt @@ -24,6 +24,10 @@ abstract class BaseModule(context: ReactApplicationContext?) : ReactContextBaseJ protected var actionHandler: ActionHandler? = null + override fun onCatalystInstanceDestroy() { + actionHandler?.hide() + } + protected fun sendEvent(eventName: String, map: ReadableMap?) { reactApplicationContext .getJSModule(RCTDeviceEventEmitter::class.java) diff --git a/android/src/main/java/com/adyenreactnativesdk/component/googlepay/AdyenGooglePayComponent.kt b/android/src/main/java/com/adyenreactnativesdk/component/googlepay/AdyenGooglePayComponent.kt index df96e6bcc..586042405 100644 --- a/android/src/main/java/com/adyenreactnativesdk/component/googlepay/AdyenGooglePayComponent.kt +++ b/android/src/main/java/com/adyenreactnativesdk/component/googlepay/AdyenGooglePayComponent.kt @@ -31,6 +31,10 @@ class AdyenGooglePayComponent(context: ReactApplicationContext?) : BaseModule(co return COMPONENT_NAME } + override fun onCatalystInstanceDestroy() { + pendingPaymentDialogFragment?.dismiss() + } + @ReactMethod fun addListener(eventName: String?) { /* No JS events expected */ } diff --git a/android/src/main/java/com/adyenreactnativesdk/component/instant/AdyenInstantComponent.kt b/android/src/main/java/com/adyenreactnativesdk/component/instant/AdyenInstantComponent.kt index 221fa33f4..af356d888 100644 --- a/android/src/main/java/com/adyenreactnativesdk/component/instant/AdyenInstantComponent.kt +++ b/android/src/main/java/com/adyenreactnativesdk/component/instant/AdyenInstantComponent.kt @@ -77,7 +77,7 @@ class AdyenInstantComponent(context: ReactApplicationContext?) : BaseModule(cont @ReactMethod fun hide(success: Boolean?, message: ReadableMap?) { appCompatActivity.runOnUiThread { - actionHandler?.hide(appCompatActivity) + actionHandler?.hide() actionHandler = null AdyenCheckout.removeIntentHandler() }