com.actionbarsherlock.internal.view.menu
Class ActionMenuPresenter

java.lang.Object
  extended by com.actionbarsherlock.internal.view.menu.BaseMenuPresenter
      extended by com.actionbarsherlock.internal.view.menu.ActionMenuPresenter
All Implemented Interfaces:
MenuPresenter, ActionProvider.SubUiVisibilityListener

public class ActionMenuPresenter
extends BaseMenuPresenter
implements ActionProvider.SubUiVisibilityListener

MenuPresenter for building action menus as seen in the action bar and action modes.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.actionbarsherlock.internal.view.menu.MenuPresenter
MenuPresenter.Callback
 
Field Summary
 
Fields inherited from class com.actionbarsherlock.internal.view.menu.BaseMenuPresenter
mContext, mInflater, mMenu, mMenuView, mSystemContext, mSystemInflater
 
Constructor Summary
ActionMenuPresenter(android.content.Context context)
           
 
Method Summary
 void bindItemView(MenuItemImpl item, MenuView.ItemView itemView)
          Bind item data to an existing item view.
 boolean dismissPopupMenus()
          Dismiss all popup menus - overflow and submenus.
 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.
 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).
 boolean hideOverflowMenu()
          Hide the overflow menu if it is currently showing.
 boolean hideSubMenus()
          Dismiss all submenu popups.
 void initForMenu(android.content.Context context, MenuBuilder menu)
          Initialize this presenter for the given context and menu.
 boolean isOverflowMenuShowing()
           
 boolean isOverflowReserved()
           
 void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing)
          Called by Menu implementations to indicate that a menu or submenu is closing.
 void onConfigurationChanged(android.content.res.Configuration newConfig)
           
 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 onSubUiVisibilityChanged(boolean isVisible)
           
static boolean reserveOverflow(android.content.Context context)
           
 void setExpandedActionViewsExclusive(boolean isExclusive)
           
 void setItemLimit(int itemCount)
           
 void setReserveOverflow(boolean reserveOverflow)
           
 void setWidthLimit(int width, boolean strict)
           
 boolean shouldIncludeItem(int childIndex, MenuItemImpl item)
          Filter item by child index and item data.
 boolean showOverflowMenu()
          Display the overflow menu if one is present.
 void updateMenuView(boolean cleared)
          Reuses item views when it can
 
Methods inherited from class com.actionbarsherlock.internal.view.menu.BaseMenuPresenter
addItemView, collapseItemActionView, createItemView, expandItemActionView, getId, setCallback, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionMenuPresenter

public ActionMenuPresenter(android.content.Context context)
Method Detail

initForMenu

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

Specified by:
initForMenu in interface MenuPresenter
Overrides:
initForMenu in class BaseMenuPresenter
Parameters:
context - Context for this presenter; used for view creation and resource management
menu - Menu to host

reserveOverflow

public static boolean reserveOverflow(android.content.Context context)

onConfigurationChanged

public void onConfigurationChanged(android.content.res.Configuration newConfig)

setWidthLimit

public void setWidthLimit(int width,
                          boolean strict)

setReserveOverflow

public void setReserveOverflow(boolean reserveOverflow)

setItemLimit

public void setItemLimit(int itemCount)

setExpandedActionViewsExclusive

public void setExpandedActionViewsExclusive(boolean isExclusive)

getMenuView

public MenuView getMenuView(android.view.ViewGroup root)
Description copied from interface: MenuPresenter
Retrieve a MenuView to display the menu specified in #initForMenu(Context, Menu).

Specified by:
getMenuView in interface MenuPresenter
Overrides:
getMenuView in class BaseMenuPresenter
Parameters:
root - Intended parent of the MenuView.
Returns:
A freshly created MenuView.

getItemView

public android.view.View getItemView(MenuItemImpl item,
                                     android.view.View convertView,
                                     android.view.ViewGroup parent)
Description copied from class: BaseMenuPresenter
Prepare an item view for use. See AdapterView for the basic idea at work here. This may require creating a new item view, but well-behaved implementations will re-use the view passed as convertView if present. The returned view will be populated with data from the item parameter.

Overrides:
getItemView in class BaseMenuPresenter
Parameters:
item - Item to present
convertView - Existing view to reuse
parent - Intended parent view - use for inflation.
Returns:
View that presents the requested menu item

bindItemView

public void bindItemView(MenuItemImpl item,
                         MenuView.ItemView itemView)
Description copied from class: BaseMenuPresenter
Bind item data to an existing item view.

Specified by:
bindItemView in class BaseMenuPresenter
Parameters:
item - Item to bind
itemView - View to populate with item data

shouldIncludeItem

public boolean shouldIncludeItem(int childIndex,
                                 MenuItemImpl item)
Description copied from class: BaseMenuPresenter
Filter item by child index and item data.

Overrides:
shouldIncludeItem in class BaseMenuPresenter
Parameters:
childIndex - Indended presentation index of this item
item - Item to present
Returns:
true if this item should be included in this menu presentation; false otherwise

updateMenuView

public void updateMenuView(boolean cleared)
Description copied from class: BaseMenuPresenter
Reuses item views when it can

Specified by:
updateMenuView in interface MenuPresenter
Overrides:
updateMenuView in class BaseMenuPresenter
Parameters:
cleared - true if the menu was entirely cleared

filterLeftoverView

public boolean filterLeftoverView(android.view.ViewGroup parent,
                                  int childIndex)
Description copied from class: BaseMenuPresenter
Filter the child view at index and remove it if appropriate.

Overrides:
filterLeftoverView in class BaseMenuPresenter
Parameters:
parent - Parent to filter from
childIndex - Index to filter
Returns:
true if the child view at index was removed

onSubMenuSelected

public boolean onSubMenuSelected(SubMenuBuilder subMenu)
Description copied from interface: MenuPresenter
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.

Specified by:
onSubMenuSelected in interface MenuPresenter
Overrides:
onSubMenuSelected in class BaseMenuPresenter
Parameters:
subMenu - SubMenu being opened
Returns:
true if the the event was handled, false otherwise.

showOverflowMenu

public boolean showOverflowMenu()
Display the overflow menu if one is present.

Returns:
true if the overflow menu was shown, false otherwise.

hideOverflowMenu

public boolean hideOverflowMenu()
Hide the overflow menu if it is currently showing.

Returns:
true if the overflow menu was hidden, false otherwise.

dismissPopupMenus

public boolean dismissPopupMenus()
Dismiss all popup menus - overflow and submenus.

Returns:
true if popups were dismissed, false otherwise. (This can be because none were open.)

hideSubMenus

public boolean hideSubMenus()
Dismiss all submenu popups.

Returns:
true if popups were dismissed, false otherwise. (This can be because none were open.)

isOverflowMenuShowing

public boolean isOverflowMenuShowing()
Returns:
true if the overflow menu is currently showing

isOverflowReserved

public boolean isOverflowReserved()
Returns:
true if space has been reserved in the action menu for an overflow item.

flagActionItems

public boolean flagActionItems()
Description copied from interface: MenuPresenter
Called by Menu implementations to flag items that will be shown as actions.

Specified by:
flagActionItems in interface MenuPresenter
Overrides:
flagActionItems in class BaseMenuPresenter
Returns:
true if this presenter changed the action status of any items.

onCloseMenu

public void onCloseMenu(MenuBuilder menu,
                        boolean allMenusAreClosing)
Description copied from interface: MenuPresenter
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.

Specified by:
onCloseMenu in interface MenuPresenter
Overrides:
onCloseMenu in class BaseMenuPresenter
Parameters:
menu - Menu or submenu that is closing.
allMenusAreClosing - True if all associated menus are closing.

onSaveInstanceState

public android.os.Parcelable onSaveInstanceState()
Description copied from interface: MenuPresenter
Returns a Parcelable describing the current state of the presenter. It will be passed to the MenuPresenter.onRestoreInstanceState(Parcelable) method of the presenter sharing the same ID later.

Specified by:
onSaveInstanceState in interface MenuPresenter
Returns:
The saved instance state

onRestoreInstanceState

public void onRestoreInstanceState(android.os.Parcelable state)
Description copied from interface: MenuPresenter
Supplies the previously saved instance state to be restored.

Specified by:
onRestoreInstanceState in interface MenuPresenter
Parameters:
state - The previously saved instance state

onSubUiVisibilityChanged

public void onSubUiVisibilityChanged(boolean isVisible)
Specified by:
onSubUiVisibilityChanged in interface ActionProvider.SubUiVisibilityListener


Copyright © 2012-2013. All Rights Reserved.