com.actionbarsherlock.internal.view.menu
Interface MenuPresenter

All Known Implementing Classes:
ActionMenuPresenter, BaseMenuPresenter, MenuPopupHelper

public interface MenuPresenter

A MenuPresenter is responsible for building views for a Menu object. It takes over some responsibility from the old style monolithic MenuBuilder class.


Nested Class Summary
static interface MenuPresenter.Callback
          Called by menu implementation to notify another component of open/close events.
 
Method Summary
 boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item)
          Called when a menu item with a collapsable action view should collapse its action view.
 boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item)
          Called when a menu item with a collapsable action view should expand its action view.
 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.
 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.
 void onRestoreInstanceState(android.os.Parcelable state)
          Supplies the previously saved instance state to be restored.
 android.os.Parcelable onSaveInstanceState()
          Returns a Parcelable describing the current state of the presenter.
 boolean onSubMenuSelected(SubMenuBuilder subMenu)
          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 updateMenuView(boolean cleared)
          Update the menu UI in response to a change.
 

Method Detail

initForMenu

void initForMenu(android.content.Context context,
                 MenuBuilder menu)
Initialize this presenter for the given context and menu. This method is called by MenuBuilder when a presenter is added. See MenuBuilder.addMenuPresenter(MenuPresenter)

Parameters:
context - Context for this presenter; used for view creation and resource management
menu - Menu to host

getMenuView

MenuView getMenuView(android.view.ViewGroup root)
Retrieve a MenuView to display the menu specified in #initForMenu(Context, Menu).

Parameters:
root - Intended parent of the MenuView.
Returns:
A freshly created MenuView.

updateMenuView

void updateMenuView(boolean cleared)
Update the menu UI in response to a change. Called by MenuBuilder during the normal course of operation.

Parameters:
cleared - true if the menu was entirely cleared

setCallback

void setCallback(MenuPresenter.Callback cb)
Set a callback object that will be notified of menu events related to this specific presentation.

Parameters:
cb - Callback that will be notified of future events

onSubMenuSelected

boolean onSubMenuSelected(SubMenuBuilder subMenu)
Called by Menu implementations to indicate that a submenu item has been selected. An active Callback should be notified, and if applicable the presenter should present the submenu.

Parameters:
subMenu - SubMenu being opened
Returns:
true if the the event was handled, false otherwise.

onCloseMenu

void onCloseMenu(MenuBuilder menu,
                 boolean allMenusAreClosing)
Called by Menu implementations to indicate that a menu or submenu is closing. Presenter implementations should close the representation of the menu indicated as necessary and notify a registered callback.

Parameters:
menu - Menu or submenu that is closing.
allMenusAreClosing - True if all associated menus are closing.

flagActionItems

boolean flagActionItems()
Called by Menu implementations to flag items that will be shown as actions.

Returns:
true if this presenter changed the action status of any items.

expandItemActionView

boolean expandItemActionView(MenuBuilder menu,
                             MenuItemImpl item)
Called when a menu item with a collapsable action view should expand its action view.

Parameters:
menu - Menu containing the item to be expanded
item - Item to be expanded
Returns:
true if this presenter expanded the action view, false otherwise.

collapseItemActionView

boolean collapseItemActionView(MenuBuilder menu,
                               MenuItemImpl item)
Called when a menu item with a collapsable action view should collapse its action view.

Parameters:
menu - Menu containing the item to be collapsed
item - Item to be collapsed
Returns:
true if this presenter collapsed the action view, false otherwise.

getId

int getId()
Returns an ID for determining how to save/restore instance state.

Returns:
a valid ID value.

onSaveInstanceState

android.os.Parcelable onSaveInstanceState()
Returns a Parcelable describing the current state of the presenter. It will be passed to the onRestoreInstanceState(Parcelable) method of the presenter sharing the same ID later.

Returns:
The saved instance state

onRestoreInstanceState

void onRestoreInstanceState(android.os.Parcelable state)
Supplies the previously saved instance state to be restored.

Parameters:
state - The previously saved instance state


Copyright © 2012-2013. All Rights Reserved.