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, wait
onRestoreInstanceState, onSaveInstanceState
protected 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)
MenuPresenter
MenuBuilder.addMenuPresenter(MenuPresenter)
initForMenu
in interface MenuPresenter
context
- 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 MenuPresenter
root
- Intended parent of the MenuView.public void updateMenuView(boolean cleared)
updateMenuView
in interface MenuPresenter
cleared
- 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)
MenuPresenter
setCallback
in interface MenuPresenter
cb
- 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)
MenuPresenter
onCloseMenu
in interface MenuPresenter
menu
- Menu or submenu that is closing.allMenusAreClosing
- True if all associated menus are closing.public boolean onSubMenuSelected(SubMenuBuilder menu)
MenuPresenter
onSubMenuSelected
in interface MenuPresenter
menu
- SubMenu being openedpublic boolean flagActionItems()
MenuPresenter
flagActionItems
in interface MenuPresenter
public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item)
MenuPresenter
expandItemActionView
in interface MenuPresenter
menu
- Menu containing the item to be expandeditem
- Item to be expandedpublic boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item)
MenuPresenter
collapseItemActionView
in interface MenuPresenter
menu
- Menu containing the item to be collapseditem
- Item to be collapsedpublic int getId()
MenuPresenter
getId
in interface MenuPresenter
public void setId(int id)
Copyright © 2011–2014. All rights reserved.