Bug 843557: Revert part of 7547bf5fe166 (bug 843313). [r=kats]

This commit is contained in:
Sriram Ramasubramanian 2013-02-21 15:02:22 -08:00
parent 3f2a3ef563
commit c18fe71662
3 changed files with 22 additions and 7 deletions

View File

@ -18,12 +18,17 @@ public class GeckoMenuItem implements MenuItem, View.OnClickListener {
private static final String LOGTAG = "GeckoMenuItem";
public static interface Layout {
public void setId(int id);
public void setIcon(Drawable icon);
public void setIcon(int iconRes);
public void setTitle(CharSequence title);
public void setEnabled(boolean enabled);
public void setCheckable(boolean checkable);
public void setChecked(boolean checked);
public void setOnClickListener(View.OnClickListener listener);
public void setSubMenuIndicator(boolean hasSubMenu);
public void setVisibility(int visible);
public View getView();
}
public static interface OnShowAsActionChangedListener {
@ -38,7 +43,7 @@ public class GeckoMenuItem implements MenuItem, View.OnClickListener {
private Context mContext;
private int mId;
private int mOrder;
private GeckoMenuItem.Layout mLayout;
private Layout mLayout;
private boolean mActionItem;
private CharSequence mTitle;
private CharSequence mTitleCondensed;
@ -57,7 +62,7 @@ public class GeckoMenuItem implements MenuItem, View.OnClickListener {
public GeckoMenuItem(Context context, int id) {
mContext = context;
mLayout = (MenuItemDefault) LayoutInflater.from(mContext).inflate(R.layout.menu_item, null);
((View) mLayout).setId(id);
mLayout.setId(id);
mId = id;
mOrder = 0;
@ -127,7 +132,7 @@ public class GeckoMenuItem implements MenuItem, View.OnClickListener {
}
public View getLayout() {
return (View) mLayout;
return mLayout.getView();
}
public void setMenu(GeckoMenu menu) {
@ -231,7 +236,7 @@ public class GeckoMenuItem implements MenuItem, View.OnClickListener {
@Override
public MenuItem setEnabled(boolean enabled) {
mEnabled = enabled;
((View) mLayout).setEnabled(enabled);
mLayout.setEnabled(enabled);
return this;
}
@ -296,8 +301,8 @@ public class GeckoMenuItem implements MenuItem, View.OnClickListener {
mActionItem = (actionEnum > 0);
((View) mLayout).setId(mId);
((View) mLayout).setOnClickListener(this);
mLayout.setId(mId);
mLayout.setOnClickListener(this);
setTitle(mTitle);
setVisible(mVisible);
@ -347,7 +352,7 @@ public class GeckoMenuItem implements MenuItem, View.OnClickListener {
@Override
public MenuItem setVisible(boolean visible) {
mVisible = visible;
((View) mLayout).setVisibility(visible ? View.VISIBLE : View.GONE);
mLayout.setVisibility(visible ? View.VISIBLE : View.GONE);
if (mVisibilityChangedListener != null)
mVisibilityChangedListener.onVisibilityChanged(this, visible);

View File

@ -28,6 +28,11 @@ public class MenuItemActionBar extends ImageButton
setScaleType(ImageView.ScaleType.FIT_CENTER);
}
@Override
public View getView() {
return this;
}
@Override
public void setIcon(Drawable icon) {
if (icon != null) {

View File

@ -61,6 +61,11 @@ public class MenuItemDefault extends TextView
return drawableState;
}
@Override
public View getView() {
return this;
}
@Override
public void setIcon(Drawable icon) {
mIcon = icon;