public abstract class BaseMenuPresenter extends Object implements MenuPresenter
MenuPresenter.Callback| Modifier and Type | Field and Description |
|---|---|
protected android.content.Context |
mContext |
protected android.view.LayoutInflater |
mInflater |
protected MenuBuilder |
mMenu |
protected MenuView |
mMenuView |
protected android.content.Context |
mSystemContext |
protected android.view.LayoutInflater |
mSystemInflater |
| Constructor and Description |
|---|
BaseMenuPresenter(android.content.Context context,
int menuLayoutRes,
int itemLayoutRes)
Construct a new BaseMenuPresenter.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addItemView(android.view.View itemView,
int childIndex)
Add an item view at the given index.
|
abstract void |
bindItemView(MenuItemImpl item,
MenuView.ItemView itemView)
Bind item data to an existing item view.
|
boolean |
collapseItemActionView(MenuBuilder menu,
MenuItemImpl item)
Called when a menu item with a collapsable action view should collapse its action view.
|
MenuView.ItemView |
createItemView(android.view.ViewGroup parent)
Create a new item view that can be re-bound to other item data later.
|
boolean |
expandItemActionView(MenuBuilder menu,
MenuItemImpl item)
Called when a menu item with a collapsable action view should expand its action view.
|
protected boolean |
filterLeftoverView(android.view.ViewGroup parent,
int childIndex)
Filter the child view at index and remove it if appropriate.
|
boolean |
flagActionItems()
Called by Menu implementations to flag items that will be shown as actions.
|
int |
getId()
Returns an ID for determining how to save/restore instance state.
|
android.view.View |
getItemView(MenuItemImpl item,
android.view.View convertView,
android.view.ViewGroup parent)
Prepare an item view for use.
|
MenuView |
getMenuView(android.view.ViewGroup root)
Retrieve a MenuView to display the menu specified in
#initForMenu(Context, Menu). |
void |
initForMenu(android.content.Context context,
MenuBuilder menu)
Initialize this presenter for the given context and menu.
|
void |
onCloseMenu(MenuBuilder menu,
boolean allMenusAreClosing)
Called by Menu implementations to indicate that a menu or submenu is
closing.
|
boolean |
onSubMenuSelected(SubMenuBuilder menu)
Called by Menu implementations to indicate that a submenu item
has been selected.
|
void |
setCallback(MenuPresenter.Callback cb)
Set a callback object that will be notified of menu events
related to this specific presentation.
|
void |
setId(int id) |
boolean |
shouldIncludeItem(int childIndex,
MenuItemImpl item)
Filter item by child index and item data.
|
void |
updateMenuView(boolean cleared)
Reuses item views when it can
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonRestoreInstanceState, onSaveInstanceStateprotected android.content.Context mSystemContext
protected android.content.Context mContext
protected MenuBuilder mMenu
protected android.view.LayoutInflater mSystemInflater
protected android.view.LayoutInflater mInflater
protected MenuView mMenuView
public BaseMenuPresenter(android.content.Context context,
int menuLayoutRes,
int itemLayoutRes)
context - Context for generating system-supplied viewsmenuLayoutRes - Layout resource ID for the menu container viewitemLayoutRes - Layout resource ID for a single item viewpublic void initForMenu(android.content.Context context,
MenuBuilder menu)
MenuPresenterMenuBuilder.addMenuPresenter(MenuPresenter)initForMenu in interface MenuPresentercontext - Context for this presenter; used for view creation and resource managementmenu - Menu to hostpublic MenuView getMenuView(android.view.ViewGroup root)
MenuPresenter#initForMenu(Context, Menu).getMenuView in interface MenuPresenterroot - Intended parent of the MenuView.public void updateMenuView(boolean cleared)
updateMenuView in interface MenuPresentercleared - true if the menu was entirely clearedprotected void addItemView(android.view.View itemView,
int childIndex)
itemView - View to addchildIndex - Index within the parent to insert atprotected boolean filterLeftoverView(android.view.ViewGroup parent,
int childIndex)
parent - Parent to filter fromchildIndex - Index to filterpublic void setCallback(MenuPresenter.Callback cb)
MenuPresentersetCallback in interface MenuPresentercb - Callback that will be notified of future eventspublic MenuView.ItemView createItemView(android.view.ViewGroup parent)
public android.view.View getItemView(MenuItemImpl item, android.view.View convertView, android.view.ViewGroup parent)
item - Item to presentconvertView - Existing view to reuseparent - Intended parent view - use for inflation.public abstract void bindItemView(MenuItemImpl item, MenuView.ItemView itemView)
item - Item to binditemView - View to populate with item datapublic boolean shouldIncludeItem(int childIndex,
MenuItemImpl item)
childIndex - Indended presentation index of this itemitem - Item to presentpublic void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing)
MenuPresenteronCloseMenu in interface MenuPresentermenu - Menu or submenu that is closing.allMenusAreClosing - True if all associated menus are closing.public boolean onSubMenuSelected(SubMenuBuilder menu)
MenuPresenteronSubMenuSelected in interface MenuPresentermenu - SubMenu being openedpublic boolean flagActionItems()
MenuPresenterflagActionItems in interface MenuPresenterpublic boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item)
MenuPresenterexpandItemActionView in interface MenuPresentermenu - Menu containing the item to be expandeditem - Item to be expandedpublic boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item)
MenuPresentercollapseItemActionView in interface MenuPresentermenu - Menu containing the item to be collapseditem - Item to be collapsedpublic int getId()
MenuPresentergetId in interface MenuPresenterpublic void setId(int id)
Copyright © 2011–2014. All rights reserved.