Skip to content

Commit

Permalink
#79 App crash when setting androiddelay to -1 - reduced a bit of comp…
Browse files Browse the repository at this point in the history
…lexity
  • Loading branch information
EddyVerbruggen committed Nov 1, 2015
1 parent 22e3db4 commit dcd31f2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 34 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]> (https://github.com/EddyVerbruggen)",
"repo": "https://github.com/Telerik-Verified-Plugins/WKWebView.git",
"issue": "https://github.com/Telerik-Verified-Plugins/WKWebView/issues",
"keywords": [
Expand Down
54 changes: 20 additions & 34 deletions src/android/NativePageTransitions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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));
}
}
});
Expand Down Expand Up @@ -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));
}
}
});
Expand All @@ -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));
}
}
});
Expand All @@ -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));
}
}
});
Expand Down

0 comments on commit dcd31f2

Please sign in to comment.