FileDocCategorySizeDatePackage
BaseMenuWrapper.javaAPI DocAndroid 5.1 API3830Thu Mar 12 22:22:56 GMT 2015android.support.v7.internal.view.menu

BaseMenuWrapper

public abstract class BaseMenuWrapper extends BaseWrapper

Fields Summary
final android.content.Context
mContext
private Map
mMenuItems
private Map
mSubMenus
Constructors Summary
BaseMenuWrapper(android.content.Context context, T object)

        super(object);
        mContext = context;
    
Methods Summary
final android.view.MenuItemgetMenuItemWrapper(android.view.MenuItem menuItem)

        if (menuItem instanceof SupportMenuItem) {
            final SupportMenuItem supportMenuItem = (SupportMenuItem) menuItem;

            // Instantiate Map if null
            if (mMenuItems == null) {
                mMenuItems = new ArrayMap<>();
            }

            // First check if we already have a wrapper for this item
            MenuItem wrappedItem = mMenuItems.get(menuItem);

            if (null == wrappedItem) {
                // ... if not, create one and add it to our map
                wrappedItem = MenuWrapperFactory.wrapSupportMenuItem(mContext, supportMenuItem);
                mMenuItems.put(supportMenuItem, wrappedItem);
            }

            return wrappedItem;
        }
        return menuItem;
    
final android.view.SubMenugetSubMenuWrapper(android.view.SubMenu subMenu)

        if (subMenu instanceof SupportSubMenu) {
            final SupportSubMenu supportSubMenu = (SupportSubMenu) subMenu;

            // Instantiate Map if null
            if (mSubMenus == null) {
                mSubMenus = new ArrayMap<>();
            }

            SubMenu wrappedMenu = mSubMenus.get(supportSubMenu);

            if (null == wrappedMenu) {
                wrappedMenu = MenuWrapperFactory.wrapSupportSubMenu(mContext, supportSubMenu);
                mSubMenus.put(supportSubMenu, wrappedMenu);
            }
            return wrappedMenu;
        }
        return subMenu;
    
final voidinternalClear()

        if (mMenuItems != null) {
            mMenuItems.clear();
        }
        if (mSubMenus != null) {
            mSubMenus.clear();
        }
    
final voidinternalRemoveGroup(int groupId)

        if (mMenuItems == null) {
            return;
        }

        Iterator<SupportMenuItem> iterator = mMenuItems.keySet().iterator();
        android.view.MenuItem menuItem;

        while (iterator.hasNext()) {
            menuItem = iterator.next();
            if (groupId == menuItem.getGroupId()) {
                iterator.remove();
            }
        }
    
final voidinternalRemoveItem(int id)

        if (mMenuItems == null) {
            return;
        }

        Iterator<SupportMenuItem> iterator = mMenuItems.keySet().iterator();
        android.view.MenuItem menuItem;

        while (iterator.hasNext()) {
            menuItem = iterator.next();
            if (id == menuItem.getItemId()) {
                iterator.remove();
                break;
            }
        }