Methods Summary |
---|
protected void | addItemView(android.view.View itemView, int childIndex)
final IconMenuItemView v = (IconMenuItemView) itemView;
final IconMenuView parent = (IconMenuView) mMenuView;
v.setIconMenuView(parent);
v.setItemInvoker(parent);
v.setBackgroundDrawable(parent.getItemBackgroundDrawable());
super.addItemView(itemView, childIndex);
|
public void | bindItemView(MenuItemImpl item, com.android.internal.view.menu.MenuView.ItemView itemView)
final IconMenuItemView view = (IconMenuItemView) itemView;
view.setItemData(item);
view.initialize(item.getTitleForItemView(view), item.getIcon());
view.setVisibility(item.isVisible() ? View.VISIBLE : View.GONE);
view.setEnabled(view.isEnabled());
view.setLayoutParams(view.getTextAppropriateLayoutParams());
|
protected boolean | filterLeftoverView(android.view.ViewGroup parent, int childIndex)
if (parent.getChildAt(childIndex) != mMoreView) {
return super.filterLeftoverView(parent, childIndex);
}
return false;
|
public int | getNumActualItemsShown()
return ((IconMenuView) mMenuView).getNumActualItemsShown();
|
public void | initForMenu(android.content.Context context, MenuBuilder menu)
super.initForMenu(context, menu);
mMaxItems = -1;
|
public void | onRestoreInstanceState(android.os.Parcelable state)
restoreHierarchyState((Bundle) state);
|
public android.os.Parcelable | onSaveInstanceState()
if (mMenuView == null) {
return null;
}
Bundle state = new Bundle();
saveHierarchyState(state);
if (mOpenSubMenuId > 0) {
state.putInt(OPEN_SUBMENU_KEY, mOpenSubMenuId);
}
return state;
|
public boolean | onSubMenuSelected(SubMenuBuilder subMenu)
if (!subMenu.hasVisibleItems()) return false;
// The window manager will give us a token.
MenuDialogHelper helper = new MenuDialogHelper(subMenu);
helper.setPresenterCallback(mSubMenuPresenterCallback);
helper.show(null);
mOpenSubMenu = helper;
mOpenSubMenuId = subMenu.getItem().getItemId();
super.onSubMenuSelected(subMenu);
return true;
|
public void | restoreHierarchyState(android.os.Bundle inState)
SparseArray<Parcelable> viewStates = inState.getSparseParcelableArray(VIEWS_TAG);
if (viewStates != null) {
((View) mMenuView).restoreHierarchyState(viewStates);
}
int subMenuId = inState.getInt(OPEN_SUBMENU_KEY, 0);
if (subMenuId > 0 && mMenu != null) {
MenuItem item = mMenu.findItem(subMenuId);
if (item != null) {
onSubMenuSelected((SubMenuBuilder) item.getSubMenu());
}
}
|
public void | saveHierarchyState(android.os.Bundle outState)
SparseArray<Parcelable> viewStates = new SparseArray<Parcelable>();
if (mMenuView != null) {
((View) mMenuView).saveHierarchyState(viewStates);
}
outState.putSparseParcelableArray(VIEWS_TAG, viewStates);
|
public boolean | shouldIncludeItem(int childIndex, MenuItemImpl item)
final ArrayList<MenuItemImpl> itemsToShow = mMenu.getNonActionItems();
boolean fits = (itemsToShow.size() == mMaxItems && childIndex < mMaxItems) ||
childIndex < mMaxItems - 1;
return fits && !item.isActionButton();
|
public void | updateMenuView(boolean cleared)
final IconMenuView menuView = (IconMenuView) mMenuView;
if (mMaxItems < 0) mMaxItems = menuView.getMaxItems();
final ArrayList<MenuItemImpl> itemsToShow = mMenu.getNonActionItems();
final boolean needsMore = itemsToShow.size() > mMaxItems;
super.updateMenuView(cleared);
if (needsMore && (mMoreView == null || mMoreView.getParent() != menuView)) {
if (mMoreView == null) {
mMoreView = menuView.createMoreItemView();
mMoreView.setBackgroundDrawable(menuView.getItemBackgroundDrawable());
}
menuView.addView(mMoreView);
} else if (!needsMore && mMoreView != null) {
menuView.removeView(mMoreView);
}
menuView.setNumActualItemsShown(needsMore ? mMaxItems - 1 : itemsToShow.size());
|