From e86a9cc7a407531f2f6a1fa37c6b0dcfd4d9a250 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Mon, 19 Jan 2015 13:39:55 -0500 Subject: [PATCH] CB-8280 android: Don't apply SplashScreenDelay when .show() is called explicitly --- src/android/SplashScreen.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/android/SplashScreen.java b/src/android/SplashScreen.java index c1fb809..ec3ad93 100644 --- a/src/android/SplashScreen.java +++ b/src/android/SplashScreen.java @@ -76,7 +76,7 @@ public class SplashScreen extends CordovaPlugin { firstShow = false; loadSpinner(); - showSplashScreen(); + showSplashScreen(true); } @Override @@ -139,7 +139,7 @@ public class SplashScreen extends CordovaPlugin { if ("hide".equals(data.toString())) { this.removeSplashScreen(); } else { - this.showSplashScreen(); + this.showSplashScreen(false); } } else if ("spinner".equals(id)) { if ("stop".equals(data.toString())) { @@ -167,7 +167,7 @@ public class SplashScreen extends CordovaPlugin { * Shows the splash screen over the full Activity */ @SuppressWarnings("deprecation") - private void showSplashScreen() { + private void showSplashScreen(final boolean hideAfterDelay) { final int splashscreenTime = preferences.getInteger("SplashScreenDelay", 3000); final int drawableId = preferences.getInteger("SplashDrawableId", 0); @@ -175,7 +175,7 @@ public class SplashScreen extends CordovaPlugin { if (this.splashDialog != null && splashDialog.isShowing()) { return; } - if (drawableId == 0 || splashscreenTime <= 0) { + if (drawableId == 0 || (splashscreenTime <= 0 && hideAfterDelay)) { return; } @@ -211,12 +211,14 @@ public class SplashScreen extends CordovaPlugin { splashDialog.show(); // Set Runnable to remove splash screen just in case - final Handler handler = new Handler(); - handler.postDelayed(new Runnable() { - public void run() { - removeSplashScreen(); - } - }, splashscreenTime); + if (hideAfterDelay) { + final Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + public void run() { + removeSplashScreen(); + } + }, splashscreenTime); + } } }); }