Bug 854179 - Initialize splash screen in onCreate. r=mfinkle
authorWes Johnston <wjohnston@mozilla.com>
Thu, 09 May 2013 17:47:39 -0700
changeset 131446 8f2977671264601d89a3ef0a93bab91a8d3467b6
parent 131445 e358c97f4294117522bc90fed876507c3b25fb30
child 131447 73316004a0494bdd91752a0053fa3f6ac906f74a
push id27861
push userwjohnston@mozilla.com
push dateFri, 10 May 2013 00:48:11 +0000
treeherdermozilla-inbound@8f2977671264 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs854179
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 854179 - Initialize splash screen in onCreate. r=mfinkle
mobile/android/base/WebAppImpl.java
--- a/mobile/android/base/WebAppImpl.java
+++ b/mobile/android/base/WebAppImpl.java
@@ -27,30 +27,33 @@ import java.net.URL;
 import java.io.File;
 
 public class WebAppImpl extends GeckoApp {
     private static final String LOGTAG = "GeckoWebAppImpl";
 
     private URL mOrigin;
     private TextView mTitlebarText = null;
     private View mTitlebar = null;
-    private View mSplashscreen = null;
+
+    private View mSplashscreen;
 
     protected int getIndex() { return 0; }
 
     @Override
     public int getLayout() { return R.layout.web_app; }
 
     @Override
     public boolean hasTabsSideBar() { return false; }
 
     @Override
     public void onCreate(Bundle savedInstanceState)
     {
         super.onCreate(savedInstanceState);
+
+        mSplashscreen = (RelativeLayout) findViewById(R.id.splashscreen);
         if (!GeckoThread.checkLaunchState(GeckoThread.LaunchState.GeckoRunning)) {
             overridePendingTransition(R.anim.grow_fade_in_center, android.R.anim.fade_out);
             showSplash();
         }
 
         String action = getIntent().getAction();
         Bundle extras = getIntent().getExtras();
         String title = extras != null ? extras.getString(Intent.EXTRA_SHORTCUT_NAME) : null;
@@ -90,18 +93,16 @@ public class WebAppImpl extends GeckoApp
             startActivity(appIntent);
             finish();
         }
 
         super.initializeChrome(uri, isExternalURL);
     }
 
     private void showSplash() {
-        mSplashscreen = (RelativeLayout) findViewById(R.id.splashscreen);
-
         SharedPreferences prefs = getSharedPreferences("webapps", Context.MODE_PRIVATE | Context.MODE_MULTI_PROCESS);
 
         // get the favicon dominant color, stored when the app was installed
         int[] colors = new int[2];
         int dominantColor = prefs.getInt(WebAppAllocator.iconKey(getIndex()), -1);
 
         // now lighten it, to ensure that the icon stands out in the center
         float[] f = new float[3];
@@ -169,33 +170,33 @@ public class WebAppImpl extends GeckoApp
                         else
                             mTitlebar.setVisibility(View.VISIBLE);
                     } catch (java.net.MalformedURLException ex) {
                         Log.e(LOGTAG, "Unable to parse url: ", ex);
                     }
                 }
                 break;
             case LOADED:
-                if (mSplashscreen.getVisibility() == View.VISIBLE) {
+                if (mSplashscreen != null && mSplashscreen.getVisibility() == View.VISIBLE) {
                     Animation fadeout = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
                     fadeout.setAnimationListener(new Animation.AnimationListener() {
                         @Override
                         public void onAnimationEnd(Animation animation) {
                           mSplashscreen.setVisibility(View.GONE);
                         }
                         @Override
                         public void onAnimationRepeat(Animation animation) { }
                         @Override
                         public void onAnimationStart(Animation animation) { }
                     });
                     mSplashscreen.startAnimation(fadeout);
                 }
                 break;
             case START:
-                if (mSplashscreen.getVisibility() == View.VISIBLE) {
+                if (mSplashscreen != null && mSplashscreen.getVisibility() == View.VISIBLE) {
                     View area = findViewById(R.id.splashscreen_progress);
                     area.setVisibility(View.VISIBLE);
                     Animation fadein = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
                     fadein.setDuration(1000);
                     area.startAnimation(fadein);
                 }
                 break;
         }