Merge "Fix bug 5394020 - Menus are pretty sluggish to bring up"

This commit is contained in:
Adam Powell
2011-10-12 18:03:36 -07:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 16 deletions

View File

@@ -63,11 +63,6 @@ public final class ExpandedMenuView extends ListView implements ItemInvoker, Men
setChildrenDrawingCacheEnabled(false); setChildrenDrawingCacheEnabled(false);
} }
@Override
protected boolean recycleOnMeasure() {
return false;
}
public boolean invokeItem(MenuItemImpl item) { public boolean invokeItem(MenuItemImpl item) {
return mMenu.performItemAction(item, 0); return mMenu.performItemAction(item, 0);
} }

View File

@@ -34,6 +34,7 @@ import android.widget.TextView;
* The item view for each item in the ListView-based MenuViews. * The item view for each item in the ListView-based MenuViews.
*/ */
public class ListMenuItemView extends LinearLayout implements MenuView.ItemView { public class ListMenuItemView extends LinearLayout implements MenuView.ItemView {
private static final String TAG = "ListMenuItemView";
private MenuItemImpl mItemData; private MenuItemImpl mItemData;
private ImageView mIconView; private ImageView mIconView;
@@ -121,27 +122,25 @@ public class ListMenuItemView extends LinearLayout implements MenuView.ItemView
} }
public void setCheckable(boolean checkable) { public void setCheckable(boolean checkable) {
if (!checkable && mRadioButton == null && mCheckBox == null) { if (!checkable && mRadioButton == null && mCheckBox == null) {
return; return;
} }
if (mRadioButton == null) {
insertRadioButton();
}
if (mCheckBox == null) {
insertCheckBox();
}
// Depending on whether its exclusive check or not, the checkbox or // Depending on whether its exclusive check or not, the checkbox or
// radio button will be the one in use (and the other will be otherCompoundButton) // radio button will be the one in use (and the other will be otherCompoundButton)
final CompoundButton compoundButton; final CompoundButton compoundButton;
final CompoundButton otherCompoundButton; final CompoundButton otherCompoundButton;
if (mItemData.isExclusiveCheckable()) { if (mItemData.isExclusiveCheckable()) {
if (mRadioButton == null) {
insertRadioButton();
}
compoundButton = mRadioButton; compoundButton = mRadioButton;
otherCompoundButton = mCheckBox; otherCompoundButton = mCheckBox;
} else { } else {
if (mCheckBox == null) {
insertCheckBox();
}
compoundButton = mCheckBox; compoundButton = mCheckBox;
otherCompoundButton = mRadioButton; otherCompoundButton = mRadioButton;
} }
@@ -155,12 +154,12 @@ public class ListMenuItemView extends LinearLayout implements MenuView.ItemView
} }
// Make sure the other compound button isn't visible // Make sure the other compound button isn't visible
if (otherCompoundButton.getVisibility() != GONE) { if (otherCompoundButton != null && otherCompoundButton.getVisibility() != GONE) {
otherCompoundButton.setVisibility(GONE); otherCompoundButton.setVisibility(GONE);
} }
} else { } else {
mCheckBox.setVisibility(GONE); if (mCheckBox != null) mCheckBox.setVisibility(GONE);
mRadioButton.setVisibility(GONE); if (mRadioButton != null) mRadioButton.setVisibility(GONE);
} }
} }