|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.actionbarsherlock.internal.view.menu.BaseMenuPresenter
public abstract class BaseMenuPresenter
Base class for MenuPresenters that have a consistent container view and item views. Behaves similarly to an AdapterView in that existing item views will be reused if possible when items change.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.actionbarsherlock.internal.view.menu.MenuPresenter |
|---|
MenuPresenter.Callback |
| Field Summary | |
|---|---|
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 Summary | |
|---|---|
BaseMenuPresenter(android.content.Context context,
int menuLayoutRes,
int itemLayoutRes)
Construct a new BaseMenuPresenter. |
|
| Method Summary | |
|---|---|
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 |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.actionbarsherlock.internal.view.menu.MenuPresenter |
|---|
onRestoreInstanceState, onSaveInstanceState |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
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 view| Method Detail |
|---|
public 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 cleared
protected void addItemView(android.view.View itemView,
int childIndex)
itemView - View to addchildIndex - Index within the parent to insert at
protected boolean filterLeftoverView(android.view.ViewGroup parent,
int childIndex)
parent - Parent to filter fromchildIndex - Index to filter
public void setCallback(MenuPresenter.Callback cb)
MenuPresenter
setCallback 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 data
public boolean shouldIncludeItem(int childIndex,
MenuItemImpl item)
childIndex - Indended presentation index of this itemitem - Item to present
public void onCloseMenu(MenuBuilder menu,
boolean allMenusAreClosing)
MenuPresenter
onCloseMenu in interface MenuPresentermenu - Menu or submenu that is closing.allMenusAreClosing - True if all associated menus are closing.public boolean onSubMenuSelected(SubMenuBuilder menu)
MenuPresenter
onSubMenuSelected in interface MenuPresentermenu - SubMenu being opened
public boolean flagActionItems()
MenuPresenter
flagActionItems in interface MenuPresenter
public boolean expandItemActionView(MenuBuilder menu,
MenuItemImpl item)
MenuPresenter
expandItemActionView in interface MenuPresentermenu - Menu containing the item to be expandeditem - Item to be expanded
public boolean collapseItemActionView(MenuBuilder menu,
MenuItemImpl item)
MenuPresenter
collapseItemActionView in interface MenuPresentermenu - Menu containing the item to be collapseditem - Item to be collapsed
public int getId()
MenuPresenter
getId in interface MenuPresenterpublic void setId(int id)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||