Bug 1248799 - Don't call method on potentially null tab Object. r=sebastian draft
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 16 Feb 2016 15:47:46 -0800
changeset 331380 50151230368767ce1c63169cdcc3504457e84dfa
parent 330839 5de4c2e4ddd4f04e4694f7a3b20a2432e4e5fa6c
child 514371 bdfb4af5c504cc7ed875e4d957317d335e29fad8
push id10972
push usermichael.l.comella@gmail.com
push dateTue, 16 Feb 2016 23:48:06 +0000
reviewerssebastian
bugs1248799
milestone47.0a1
Bug 1248799 - Don't call method on potentially null tab Object. r=sebastian MozReview-Commit-ID: 8SkJx0DsRWD
mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
@@ -24,16 +24,17 @@ import org.mozilla.gecko.toolbar.Browser
 import org.mozilla.gecko.util.ColorUtils;
 import org.mozilla.gecko.util.StringUtils;
 import org.mozilla.gecko.widget.themed.ThemedLinearLayout;
 import org.mozilla.gecko.widget.themed.ThemedTextView;
 
 import android.content.Context;
 import android.content.res.Resources;
 import android.os.SystemClock;
+import android.support.annotation.Nullable;
 import android.text.Spannable;
 import android.text.SpannableStringBuilder;
 import android.text.TextUtils;
 import android.text.style.ForegroundColorSpan;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -349,23 +350,23 @@ public class ToolbarDisplayLayout extend
             mSecurityImageLevel = imageLevel;
             mSiteSecurity.setImageLevel(mSecurityImageLevel);
             updatePageActions();
         }
 
         mTrackingProtectionEnabled = trackingMode == TrackingMode.TRACKING_CONTENT_BLOCKED;
     }
 
-    private void updateProgress(Tab tab) {
+    private void updateProgress(@Nullable Tab tab) {
         final boolean shouldShowThrobber = (tab != null &&
                                             tab.getState() == Tab.STATE_LOADING);
 
         updateUiMode(shouldShowThrobber ? UIMode.PROGRESS : UIMode.DISPLAY);
 
-        if (Tab.STATE_SUCCESS == tab.getState() && mTrackingProtectionEnabled) {
+        if (tab != null && Tab.STATE_SUCCESS == tab.getState() && mTrackingProtectionEnabled) {
             mActivity.showTrackingProtectionPromptIfApplicable();
         }
     }
 
     private void updateUiMode(UIMode uiMode) {
         if (mUiMode == uiMode) {
             return;
         }