Bug 1116615 - Only update the GeckoMenuItem View if property setter changes a value r=rnewman
authorMark Finkle <mfinkle@mozilla.com>
Wed, 31 Dec 2014 01:37:37 -0500
changeset 247556 73b35d5c99166acf16a751d3f70f4f9ad1c76f7a
parent 247555 edccc126caae2f70cfd6b3ed8487d90383908ec0
child 247557 4a7b2b24738a75a4d0a06f28a7cf9473f6295157
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs1116615
milestone37.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 1116615 - Only update the GeckoMenuItem View if property setter changes a value r=rnewman
mobile/android/base/menu/GeckoMenuItem.java
--- a/mobile/android/base/menu/GeckoMenuItem.java
+++ b/mobile/android/base/menu/GeckoMenuItem.java
@@ -5,16 +5,17 @@
 package org.mozilla.gecko.menu;
 
 import org.mozilla.gecko.AppConstants.Versions;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.widget.GeckoActionProvider;
 
 import android.content.Intent;
 import android.graphics.drawable.Drawable;
+import android.text.TextUtils;
 import android.view.ActionProvider;
 import android.view.ContextMenu;
 import android.view.MenuItem;
 import android.view.SubMenu;
 import android.view.View;
 
 public class GeckoMenuItem implements MenuItem {
     public static final int SHOW_AS_ACTION_NEVER = 0;
@@ -239,46 +240,56 @@ public class GeckoMenuItem implements Me
 
     @Override
     public MenuItem setAlphabeticShortcut(char alphaChar) {
         return this;
     }
 
     @Override
     public MenuItem setCheckable(boolean checkable) {
-        mCheckable = checkable;
-        mMenu.onItemChanged(this);
+        if (mCheckable != checkable) {
+            mCheckable = checkable;
+            mMenu.onItemChanged(this);
+        }
         return this;
     }
 
     @Override
     public MenuItem setChecked(boolean checked) {
-        mChecked = checked;
-        mMenu.onItemChanged(this);
+        if (mChecked != checked) {
+            mChecked = checked;
+            mMenu.onItemChanged(this);
+        }
         return this;
     }
 
     @Override
     public MenuItem setEnabled(boolean enabled) {
-        mEnabled = enabled;
-        mMenu.onItemChanged(this);
+        if (mEnabled != enabled) {
+            mEnabled = enabled;
+            mMenu.onItemChanged(this);
+        }
         return this;
     }
 
     @Override
     public MenuItem setIcon(Drawable icon) {
-        mIcon = icon;
-        mMenu.onItemChanged(this);
+        if (mIcon != icon) {
+            mIcon = icon;
+            mMenu.onItemChanged(this);
+        }
         return this;
     }
 
     @Override
     public MenuItem setIcon(int iconRes) {
-        mIconRes = iconRes;
-        mMenu.onItemChanged(this);
+        if (mIconRes != iconRes) {
+            mIconRes = iconRes;
+            mMenu.onItemChanged(this);
+        }
         return this;
     }
 
     @Override
     public MenuItem setIntent(Intent intent) {
         return this;
     }
 
@@ -349,38 +360,41 @@ public class GeckoMenuItem implements Me
 
     public MenuItem setSubMenu(GeckoSubMenu subMenu) {
         mSubMenu = subMenu;
         return this;
     }
 
     @Override
     public MenuItem setTitle(CharSequence title) {
-        mTitle = title;
-        mMenu.onItemChanged(this);
+        if (!TextUtils.equals(mTitle, title)) {
+            mTitle = title;
+            mMenu.onItemChanged(this);
+        }
         return this;
     }
 
     @Override
     public MenuItem setTitle(int title) {
-        mTitle = mMenu.getResources().getString(title);
-        mMenu.onItemChanged(this);
-        return this;
+        CharSequence newTitle = mMenu.getResources().getString(title);
+        return setTitle(newTitle);
     }
 
     @Override
     public MenuItem setTitleCondensed(CharSequence title) {
         mTitleCondensed = title;
         return this;
     }
 
     @Override
     public MenuItem setVisible(boolean visible) {
-        mVisible = visible;
-        mMenu.onItemChanged(this);
+        if (mVisible != visible) {
+            mVisible = visible;
+            mMenu.onItemChanged(this);
+        }
         return this;
     }
 
     public boolean invoke() {
         if (mMenuItemClickListener != null)
             return mMenuItemClickListener.onMenuItemClick(this);
         else
             return false;