From 44db2c620341ed394ca8070f00876fd9c4e07089 Mon Sep 17 00:00:00 2001 From: Martin Donadieu Date: Tue, 19 Mar 2024 02:04:05 +0000 Subject: [PATCH] fix: close dialog better --- .../InAppBrowserPlugin.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java b/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java index df801292..926cacf8 100644 --- a/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +++ b/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java @@ -360,12 +360,12 @@ public void run() { @PluginMethod public void close(PluginCall call) { - if (webViewDialog != null) { - this.getActivity() - .runOnUiThread( - new Runnable() { - @Override - public void run() { + this.getActivity() + .runOnUiThread( + new Runnable() { + @Override + public void run() { + if (webViewDialog != null) { notifyListeners( "closeEvent", new JSObject().put("url", webViewDialog.getUrl()) @@ -373,18 +373,18 @@ public void run() { webViewDialog.dismiss(); webViewDialog.destroy(); webViewDialog = null; + } else { + Intent intent = new Intent( + getContext(), + getBridge().getActivity().getClass() + ); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + getContext().startActivity(intent); } + call.resolve(); } - ); - } else { - Intent intent = new Intent( - getContext(), - getBridge().getActivity().getClass() + } ); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - getContext().startActivity(intent); - } - call.resolve(); } private Bundle getHeaders(PluginCall pluginCall) {