com.actionbarsherlock.internal.view.menu
Class MenuPopupHelper

java.lang.Object
  extended by com.actionbarsherlock.internal.view.menu.MenuPopupHelper
All Implemented Interfaces:
android.view.View.OnKeyListener, android.view.ViewTreeObserver.OnGlobalLayoutListener, android.widget.AdapterView.OnItemClickListener, android.widget.PopupWindow.OnDismissListener, MenuPresenter, View_OnAttachStateChangeListener

public class MenuPopupHelper
extends Object
implements android.widget.AdapterView.OnItemClickListener, android.view.View.OnKeyListener, android.view.ViewTreeObserver.OnGlobalLayoutListener, android.widget.PopupWindow.OnDismissListener, View_OnAttachStateChangeListener, MenuPresenter

Presents a menu as a small, simple popup anchored to another view.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.actionbarsherlock.internal.view.menu.MenuPresenter
MenuPresenter.Callback
 
Constructor Summary
MenuPopupHelper(android.content.Context context, MenuBuilder menu)
           
MenuPopupHelper(android.content.Context context, MenuBuilder menu, android.view.View anchorView)
           
MenuPopupHelper(android.content.Context context, MenuBuilder menu, android.view.View anchorView, boolean overflowOnly)
           
 
Method Summary
 boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item)
          Called when a menu item with a collapsable action view should collapse its action view.
 void dismiss()
           
 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.
 boolean isShowing()
           
 void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing)
          Called by Menu implementations to indicate that a menu or submenu is closing.
 void onDismiss()
           
 void onGlobalLayout()
           
 void onItemClick(android.widget.AdapterView<?> parent, android.view.View view, int position, long id)
           
 boolean onKey(android.view.View v, int keyCode, android.view.KeyEvent event)
           
 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 onViewAttachedToWindow(android.view.View v)
           
 void onViewDetachedFromWindow(android.view.View v)
           
 void setAnchorView(android.view.View anchor)
           
 void setCallback(MenuPresenter.Callback cb)
          Set a callback object that will be notified of menu events related to this specific presentation.
 void setForceShowIcon(boolean forceShow)
           
 void show()
           
 boolean tryShow()
           
 void updateMenuView(boolean cleared)
          Update the menu UI in response to a change.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MenuPopupHelper

public MenuPopupHelper(android.content.Context context,
                       MenuBuilder menu)

MenuPopupHelper

public MenuPopupHelper(android.content.Context context,
                       MenuBuilder menu,
                       android.view.View anchorView)

MenuPopupHelper

public MenuPopupHelper(android.content.Context context,
                       MenuBuilder menu,
                       android.view.View anchorView,
                       boolean overflowOnly)
Method Detail

setAnchorView

public void setAnchorView(android.view.View anchor)

setForceShowIcon

public void setForceShowIcon(boolean forceShow)

show

public void show()

tryShow

public boolean tryShow()

dismiss

public void dismiss()

onDismiss

public void onDismiss()
Specified by:
onDismiss in interface android.widget.PopupWindow.OnDismissListener

isShowing

public boolean isShowing()

onItemClick

public void onItemClick(android.widget.AdapterView<?> parent,
                        android.view.View view,
                        int position,
                        long id)
Specified by:
onItemClick in interface android.widget.AdapterView.OnItemClickListener

onKey

public boolean onKey(android.view.View v,
                     int keyCode,
                     android.view.KeyEvent event)
Specified by:
onKey in interface android.view.View.OnKeyListener

onGlobalLayout

public void onGlobalLayout()
Specified by:
onGlobalLayout in interface android.view.ViewTreeObserver.OnGlobalLayoutListener

onViewAttachedToWindow

public void onViewAttachedToWindow(android.view.View v)
Specified by:
onViewAttachedToWindow in interface View_OnAttachStateChangeListener

onViewDetachedFromWindow

public void onViewDetachedFromWindow(android.view.View v)
Specified by:
onViewDetachedFromWindow in interface View_OnAttachStateChangeListener

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
Parameters:
context - Context for this presenter; used for view creation and resource management
menu - Menu to host

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
Parameters:
root - Intended parent of the MenuView.
Returns:
A freshly created MenuView.

updateMenuView

public void updateMenuView(boolean cleared)
Description copied from interface: MenuPresenter
Update the menu UI in response to a change. Called by MenuBuilder during the normal course of operation.

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

setCallback

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

Specified by:
setCallback in interface MenuPresenter
Parameters:
cb - Callback that will be notified of future events

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
Parameters:
subMenu - SubMenu being opened
Returns:
true if the the event was handled, false otherwise.

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
Parameters:
menu - Menu or submenu that is closing.
allMenusAreClosing - True if all associated menus are closing.

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
Returns:
true if this presenter changed the action status of any items.

expandItemActionView

public boolean expandItemActionView(MenuBuilder menu,
                                    MenuItemImpl item)
Description copied from interface: MenuPresenter
Called when a menu item with a collapsable action view should expand its action view.

Specified by:
expandItemActionView in interface MenuPresenter
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

public boolean collapseItemActionView(MenuBuilder menu,
                                      MenuItemImpl item)
Description copied from interface: MenuPresenter
Called when a menu item with a collapsable action view should collapse its action view.

Specified by:
collapseItemActionView in interface MenuPresenter
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

public int getId()
Description copied from interface: MenuPresenter
Returns an ID for determining how to save/restore instance state.

Specified by:
getId in interface MenuPresenter
Returns:
a valid ID value.

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


Copyright © 2012-2013. All Rights Reserved.