You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by da...@apache.org on 2016/03/09 21:17:35 UTC

cordova-plugin-splashscreen git commit: CB-10692 Don't fade when plugin is forced to close

Repository: cordova-plugin-splashscreen
Updated Branches:
  refs/heads/master 03ea0a4e8 -> 617ad8109


CB-10692 Don't fade when plugin is forced to close

The fading logic exposed a race condition in an edge case when the
plugin was repeatedly reinitialized, e.g. when the WebView tries to load
a new URL. To address this, we add a flag to removeSplashScreen() that
allows the fade logic to be bypassed in certain circumstances --
specifically, when hiding the splashscreen due to onPause or onDestroy
events. By hiding it immediately in this scenario, we can avoid any race
conditions due to the fade delay.

github: close #86


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/commit/617ad810
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/tree/617ad810
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/diff/617ad810

Branch: refs/heads/master
Commit: 617ad8109055701214a1fdff5423a3742edc9f69
Parents: 03ea0a4
Author: Dan Polivy <da...@cellartracker.com>
Authored: Wed Feb 24 17:03:58 2016 -0800
Committer: daserge <v-...@microsoft.com>
Committed: Wed Mar 9 23:13:19 2016 +0300

----------------------------------------------------------------------
 src/android/SplashScreen.java | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/blob/617ad810/src/android/SplashScreen.java
----------------------------------------------------------------------
diff --git a/src/android/SplashScreen.java b/src/android/SplashScreen.java
index 6a077c0..d9ac66a 100644
--- a/src/android/SplashScreen.java
+++ b/src/android/SplashScreen.java
@@ -134,7 +134,7 @@ public class SplashScreen extends CordovaPlugin {
             return;
         }
         // hide the splash screen to avoid leaking a window
-        this.removeSplashScreen();
+        this.removeSplashScreen(true);
     }
 
     @Override
@@ -143,7 +143,7 @@ public class SplashScreen extends CordovaPlugin {
             return;
         }
         // hide the splash screen to avoid leaking a window
-        this.removeSplashScreen();
+        this.removeSplashScreen(true);
         // If we set this to true onDestroy, we lose track when we go from page to page!
         //firstShow = true;
     }
@@ -177,7 +177,7 @@ public class SplashScreen extends CordovaPlugin {
         }
         if ("splashscreen".equals(id)) {
             if ("hide".equals(data.toString())) {
-                this.removeSplashScreen();
+                this.removeSplashScreen(false);
             } else {
                 this.showSplashScreen(false);
             }
@@ -206,12 +206,13 @@ public class SplashScreen extends CordovaPlugin {
         }
     }
 
-    private void removeSplashScreen() {
+    private void removeSplashScreen(final boolean forceHideImmediately) {
         cordova.getActivity().runOnUiThread(new Runnable() {
             public void run() {
                 if (splashDialog != null && splashDialog.isShowing()) {
                     final int fadeSplashScreenDuration = getFadeDuration();
-                    if (fadeSplashScreenDuration > 0) {
+                    // CB-10692 If the plugin is being paused/destroyed, skip the fading and hide it immediately
+                    if (fadeSplashScreenDuration > 0 && forceHideImmediately == false) {
                         AlphaAnimation fadeOut = new AlphaAnimation(1, 0);
                         fadeOut.setInterpolator(new DecelerateInterpolator());
                         fadeOut.setDuration(fadeSplashScreenDuration);
@@ -319,7 +320,7 @@ public class SplashScreen extends CordovaPlugin {
                     handler.postDelayed(new Runnable() {
                         public void run() {
                             if (lastHideAfterDelay) {
-                                removeSplashScreen();
+                                removeSplashScreen(false);
                             }
                         }
                     }, effectiveSplashDuration);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org