Package icyllis.modernui.view.menu
Class MenuPopup
java.lang.Object
icyllis.modernui.view.menu.MenuPopup
- All Implemented Interfaces:
MenuPresenter,ShowableListMenu,AdapterView.OnItemClickListener
- Direct Known Subclasses:
CascadingMenuPopup,StandardMenuPopup
public abstract class MenuPopup
extends Object
implements ShowableListMenu, MenuPresenter, AdapterView.OnItemClickListener
Base class for a menu popup abstraction - i.e., some type of menu, housed in a popup window
environment.
-
Nested Class Summary
Nested classes/interfaces inherited from interface icyllis.modernui.view.menu.MenuPresenter
MenuPresenter.Callback -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddMenu(MenuBuilder menu) Adds the given menu to the popup, if it is capable of displaying submenus within itself.booleancollapseItemActionView(MenuBuilder menu, MenuItemImpl item) Called when a menu item with a collapsable action view should collapse its action view.booleanexpandItemActionView(MenuBuilder menu, MenuItemImpl item) Called when a menu item with a collapsable action view should expand its action view.intgetId()Returns an ID for determining how to save/restore instance state.getMenuView(ViewGroup root) Retrieve a MenuView to display the menu specified inMenuPresenter.initForMenu(Context, MenuBuilder).voidinitForMenu(Context context, MenuBuilder menu) Initializes this presenter for the given context and menu.protected static intmeasureIndividualMenuWidth(ListAdapter adapter, ViewGroup parent, Context context, int maxAllowedWidth) Measures the width of the given menu view.voidonItemClick(AdapterView<?> parent, View view, int position, long id) Callback method to be invoked when an item in this AdapterView has been clicked.abstract voidsetAnchorView(View anchor) voidsetEpicenterBounds(Rect bounds) Specifies the anchor-relative bounds of the popup's transition epicenter.abstract voidsetForceShowIcon(boolean forceShow) abstract voidsetGravity(int dropDownGravity) abstract voidsetHorizontalOffset(int x) abstract voidSet a listener to receive a callback when the popup is dismissed.abstract voidsetShowTitle(boolean showTitle) Set whether a title entry should be shown in the popup menu (if a title exists for the menu).abstract voidsetVerticalOffset(int y) protected static booleanReturns whether icon spacing needs to be preserved for the given menu, based on whether any of its items contains an icon.protected static MenuAdaptertoMenuAdapter(ListAdapter adapter) Converts the given ListAdapter originating from a menu, to a MenuAdapter, accounting for the possibility of the parameter adapter actually wrapping the MenuAdapter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface icyllis.modernui.view.menu.MenuPresenter
flagActionItems, onCloseMenu, onSubMenuSelected, setCallback, updateMenuViewMethods inherited from interface icyllis.modernui.view.menu.ShowableListMenu
dismiss, getListView, isShowing, show
-
Constructor Details
-
MenuPopup
public MenuPopup()
-
-
Method Details
-
setForceShowIcon
public abstract void setForceShowIcon(boolean forceShow) -
setGravity
public abstract void setGravity(int dropDownGravity) -
setAnchorView
-
setHorizontalOffset
public abstract void setHorizontalOffset(int x) -
setVerticalOffset
public abstract void setVerticalOffset(int y) -
setEpicenterBounds
Specifies the anchor-relative bounds of the popup's transition epicenter.- Parameters:
bounds- anchor-relative bounds
-
getEpicenterBounds
- Returns:
- anchor-relative bounds of the popup's transition epicenter
-
setShowTitle
public abstract void setShowTitle(boolean showTitle) Set whether a title entry should be shown in the popup menu (if a title exists for the menu).- Parameters:
showTitle- show title
-
setOnDismissListener
Set a listener to receive a callback when the popup is dismissed.- Parameters:
listener- Listener that will be notified when the popup is dismissed.
-
getMenuView
Description copied from interface:MenuPresenterRetrieve a MenuView to display the menu specified inMenuPresenter.initForMenu(Context, MenuBuilder).- Specified by:
getMenuViewin interfaceMenuPresenter- Parameters:
root- Intended parent of the MenuView.- Returns:
- A freshly created MenuView.
-
getId
public int getId()Description copied from interface:MenuPresenterReturns an ID for determining how to save/restore instance state.- Specified by:
getIdin interfaceMenuPresenter- Returns:
- a valid ID value.
-
onItemClick
Description copied from interface:AdapterView.OnItemClickListenerCallback method to be invoked when an item in this AdapterView has been clicked.Implementers can call getItemAtPosition(position) if they need to access the data associated with the selected item.
- Specified by:
onItemClickin interfaceAdapterView.OnItemClickListener- Parameters:
parent- The AdapterView where the click happened.view- The view within the AdapterView that was clicked (this will be a view provided by the adapter)position- The position of the view in the adapter.id- The row id of the item that was clicked.
-
measureIndividualMenuWidth
protected static int measureIndividualMenuWidth(@NonNull ListAdapter adapter, @Nullable ViewGroup parent, Context context, int maxAllowedWidth) Measures the width of the given menu view.- Returns:
- The width.
-
toMenuAdapter
Converts the given ListAdapter originating from a menu, to a MenuAdapter, accounting for the possibility of the parameter adapter actually wrapping the MenuAdapter. (That could happen if a header view was added on the menu.)
-