From dcd31f2f6fcfb1ac56cbe9309177e718deafabf0 Mon Sep 17 00:00:00 2001 From: EddyVerbruggen Date: Sun, 1 Nov 2015 17:02:29 +0100 Subject: [PATCH] #79 App crash when setting androiddelay to -1 - reduced a bit of complexity --- package.json | 1 + src/android/NativePageTransitions.java | 54 ++++++++++---------------- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 592d92f..ded4b14 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "cordova_name": "Native Page Transitions", "description": "Slide out the current page to reveal the next one. By a native transitions.", "license": "MIT", + "author": "Telerik / Eddy Verbruggen (https://github.com/EddyVerbruggen)", "repo": "https://github.com/Telerik-Verified-Plugins/WKWebView.git", "issue": "https://github.com/Telerik-Verified-Plugins/WKWebView/issues", "keywords": [ diff --git a/src/android/NativePageTransitions.java b/src/android/NativePageTransitions.java index 5072e5c..5fd89c3 100644 --- a/src/android/NativePageTransitions.java +++ b/src/android/NativePageTransitions.java @@ -61,24 +61,6 @@ public class NativePageTransitions extends CordovaPlugin { } } - public Object onMessage(String id, Object data) { - if ("onPageFinished".equalsIgnoreCase(id)) { - if (delay == -1) { - delay = 0; - } - if ("slide".equalsIgnoreCase(_action)) { - doSlideTransition(); - } else if ("fade".equalsIgnoreCase(_action)) { - doFadeTransition(); - } else if ("flip".equalsIgnoreCase(_action)) { - doFlipTransition(); - } else if ("drawer".equalsIgnoreCase(_action)) { - doDrawerTransition(); - } - } - return super.onMessage(id, data); - } - // Helper to be compile-time compatible with both Cordova 3.x and 4.x. private View cachedView; private View getView() { @@ -201,12 +183,13 @@ public void run() { if (href != null && !"null".equals(href)) { if (!href.startsWith("#") && href.contains(".html")) { webView.loadUrlIntoView(HREF_PREFIX + href, false); - } else if (delay > -1) { - // it's a #hash, which is handled in JS - doSlideTransition(); } - } else if (delay > -1) { + } + + if (delay > -1) { doSlideTransition(); + } else { + _callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK)); } } }); @@ -256,12 +239,13 @@ public void run() { if (href != null && !"null".equals(href)) { if (!href.startsWith("#") && href.contains(".html")) { webView.loadUrlIntoView(HREF_PREFIX + href, false); - } else if (delay > -1) { - // it's a #hash, which is handled in JS - doDrawerTransition(); } - } else if (delay > -1) { + } + + if (delay > -1) { doDrawerTransition(); + } else { + _callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK)); } } }); @@ -280,12 +264,13 @@ public void run() { if (href != null && !"null".equals(href)) { if (!href.startsWith("#") && href.contains(".html")) { webView.loadUrlIntoView(HREF_PREFIX + href, false); - } else if (delay > -1) { - // it's a #hash, which is handled in JS - doFadeTransition(); } - } else if (delay > -1) { + } + + if (delay > -1) { doFadeTransition(); + } else { + _callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK)); } } }); @@ -307,12 +292,13 @@ public void run() { if (href != null && !"null".equals(href)) { if (!href.startsWith("#") && href.contains(".html")) { webView.loadUrlIntoView(HREF_PREFIX + href, false); - } else if (delay > -1) { - // it's a #hash, which is handled in JS - doFlipTransition(); } - } else if (delay > -1) { + } + + if (delay > -1) { doFlipTransition(); + } else { + _callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK)); } } });