Search in sources :

Example 6 with SubMenuBuilder

use of com.android.internal.view.menu.SubMenuBuilder in project platform_frameworks_base by android.

the class ActionMenuPresenter method onRestoreInstanceState.

@Override
public void onRestoreInstanceState(Parcelable state) {
    SavedState saved = (SavedState) state;
    if (saved.openSubMenuId > 0) {
        MenuItem item = mMenu.findItem(saved.openSubMenuId);
        if (item != null) {
            SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            onSubMenuSelected(subMenu);
        }
    }
}
Also used : SubMenuBuilder(com.android.internal.view.menu.SubMenuBuilder) MenuItem(android.view.MenuItem)

Example 7 with SubMenuBuilder

use of com.android.internal.view.menu.SubMenuBuilder in project platform_frameworks_base by android.

the class ActionMenuPresenter method onSubMenuSelected.

public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
    if (!subMenu.hasVisibleItems())
        return false;
    SubMenuBuilder topSubMenu = subMenu;
    while (topSubMenu.getParentMenu() != mMenu) {
        topSubMenu = (SubMenuBuilder) topSubMenu.getParentMenu();
    }
    View anchor = findViewForItem(topSubMenu.getItem());
    if (anchor == null) {
        // responsibility to display the new submenu.
        return false;
    }
    mOpenSubMenuId = subMenu.getItem().getItemId();
    boolean preserveIconSpacing = false;
    final int count = subMenu.size();
    for (int i = 0; i < count; i++) {
        MenuItem childItem = subMenu.getItem(i);
        if (childItem.isVisible() && childItem.getIcon() != null) {
            preserveIconSpacing = true;
            break;
        }
    }
    mActionButtonPopup = new ActionButtonSubmenu(mContext, subMenu, anchor);
    mActionButtonPopup.setForceShowIcon(preserveIconSpacing);
    mActionButtonPopup.show();
    super.onSubMenuSelected(subMenu);
    return true;
}
Also used : SubMenuBuilder(com.android.internal.view.menu.SubMenuBuilder) MenuItem(android.view.MenuItem) MenuView(com.android.internal.view.menu.MenuView) View(android.view.View) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView)

Example 8 with SubMenuBuilder

use of com.android.internal.view.menu.SubMenuBuilder in project android_frameworks_base by DirtyUnicorns.

the class ActionMenuPresenter method onSubMenuSelected.

public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
    if (!subMenu.hasVisibleItems())
        return false;
    SubMenuBuilder topSubMenu = subMenu;
    while (topSubMenu.getParentMenu() != mMenu) {
        topSubMenu = (SubMenuBuilder) topSubMenu.getParentMenu();
    }
    View anchor = findViewForItem(topSubMenu.getItem());
    if (anchor == null) {
        // responsibility to display the new submenu.
        return false;
    }
    mOpenSubMenuId = subMenu.getItem().getItemId();
    boolean preserveIconSpacing = false;
    final int count = subMenu.size();
    for (int i = 0; i < count; i++) {
        MenuItem childItem = subMenu.getItem(i);
        if (childItem.isVisible() && childItem.getIcon() != null) {
            preserveIconSpacing = true;
            break;
        }
    }
    mActionButtonPopup = new ActionButtonSubmenu(mContext, subMenu, anchor);
    mActionButtonPopup.setForceShowIcon(preserveIconSpacing);
    mActionButtonPopup.show();
    super.onSubMenuSelected(subMenu);
    return true;
}
Also used : SubMenuBuilder(com.android.internal.view.menu.SubMenuBuilder) MenuItem(android.view.MenuItem) MenuView(com.android.internal.view.menu.MenuView) View(android.view.View) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView)

Example 9 with SubMenuBuilder

use of com.android.internal.view.menu.SubMenuBuilder in project android_frameworks_base by ResurrectionRemix.

the class ActionMenuPresenter method onSubMenuSelected.

public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
    if (!subMenu.hasVisibleItems())
        return false;
    SubMenuBuilder topSubMenu = subMenu;
    while (topSubMenu.getParentMenu() != mMenu) {
        topSubMenu = (SubMenuBuilder) topSubMenu.getParentMenu();
    }
    View anchor = findViewForItem(topSubMenu.getItem());
    if (anchor == null) {
        // responsibility to display the new submenu.
        return false;
    }
    mOpenSubMenuId = subMenu.getItem().getItemId();
    boolean preserveIconSpacing = false;
    final int count = subMenu.size();
    for (int i = 0; i < count; i++) {
        MenuItem childItem = subMenu.getItem(i);
        if (childItem.isVisible() && childItem.getIcon() != null) {
            preserveIconSpacing = true;
            break;
        }
    }
    mActionButtonPopup = new ActionButtonSubmenu(mContext, subMenu, anchor);
    mActionButtonPopup.setForceShowIcon(preserveIconSpacing);
    mActionButtonPopup.show();
    super.onSubMenuSelected(subMenu);
    return true;
}
Also used : SubMenuBuilder(com.android.internal.view.menu.SubMenuBuilder) MenuItem(android.view.MenuItem) MenuView(com.android.internal.view.menu.MenuView) View(android.view.View) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView)

Example 10 with SubMenuBuilder

use of com.android.internal.view.menu.SubMenuBuilder in project android_frameworks_base by ResurrectionRemix.

the class ActionMenuPresenter method onRestoreInstanceState.

@Override
public void onRestoreInstanceState(Parcelable state) {
    SavedState saved = (SavedState) state;
    if (saved.openSubMenuId > 0) {
        MenuItem item = mMenu.findItem(saved.openSubMenuId);
        if (item != null) {
            SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            onSubMenuSelected(subMenu);
        }
    }
}
Also used : SubMenuBuilder(com.android.internal.view.menu.SubMenuBuilder) MenuItem(android.view.MenuItem)

Aggregations

MenuItem (android.view.MenuItem)10 SubMenuBuilder (com.android.internal.view.menu.SubMenuBuilder)10 View (android.view.View)5 ActionMenuItemView (com.android.internal.view.menu.ActionMenuItemView)5 MenuView (com.android.internal.view.menu.MenuView)5