public class ListMenuPresenter extends Object implements MenuPresenter, AdapterView.OnItemClickListener
MenuPresenter.Callback
Constructor and Description |
---|
ListMenuPresenter(Context context,
int itemLayoutRes)
Construct a new ListMenuPresenter.
|
ListMenuPresenter(int itemLayoutRes,
int themeRes)
Construct a new ListMenuPresenter.
|
Modifier and Type | Method and Description |
---|---|
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.
|
ListAdapter |
getAdapter()
Call this instead of getMenuView if you want to manage your own ListView.
|
int |
getId()
Returns an ID for determining how to save/restore instance state.
|
MenuView |
getMenuView(ViewGroup root)
Retrieve a MenuView to display the menu specified in
MenuPresenter.initForMenu(Context, MenuBuilder) . |
void |
initForMenu(Context context,
MenuBuilder menu)
Initializes 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 |
onItemClick(AdapterView<?> parent,
View view,
int position,
long id)
Callback method to be invoked when an item in this AdapterView has
been clicked.
|
void |
onRestoreInstanceState(Parcelable state)
Supplies the previously saved instance state to be restored.
|
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 |
restoreHierarchyState(Bundle inState) |
void |
saveHierarchyState(Bundle outState) |
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) |
void |
setItemIndexOffset(int offset) |
void |
updateMenuView(boolean cleared)
Update the menu UI in response to a change.
|
public static final String VIEWS_TAG
public ListMenuPresenter(Context context, int itemLayoutRes)
context
- Context to use for theming. This will supersede the context provided
to initForMenu when this presenter is added.itemLayoutRes
- Layout resource for individual item views.public ListMenuPresenter(int itemLayoutRes, int themeRes)
itemLayoutRes
- Layout resource for individual item views.themeRes
- Resource ID of a theme to use for views.public void initForMenu(Context context, MenuBuilder menu)
MenuPresenter
This method is called by MenuBuilder when a presenter is added. See
MenuBuilder.addMenuPresenter(MenuPresenter)
.
initForMenu
in interface MenuPresenter
context
- the context for this presenter; used for view creation
and resource management, must be non-null
menu
- the menu to host, or null
to clear the hosted menupublic MenuView getMenuView(ViewGroup root)
MenuPresenter
MenuPresenter.initForMenu(Context, MenuBuilder)
.getMenuView
in interface MenuPresenter
root
- Intended parent of the MenuView.public ListAdapter getAdapter()
public void updateMenuView(boolean cleared)
MenuPresenter
updateMenuView
in interface MenuPresenter
cleared
- true if the menu was entirely clearedpublic void setCallback(MenuPresenter.Callback cb)
MenuPresenter
setCallback
in interface MenuPresenter
cb
- Callback that will be notified of future eventspublic boolean onSubMenuSelected(SubMenuBuilder subMenu)
MenuPresenter
onSubMenuSelected
in interface MenuPresenter
subMenu
- SubMenu being openedpublic void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing)
MenuPresenter
onCloseMenu
in interface MenuPresenter
menu
- the menu or submenu that is closingallMenusAreClosing
- true
if all displayed menus and
submenus are closing, false
if only
the specified menu is closingpublic void setItemIndexOffset(int offset)
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
AdapterView.OnItemClickListener
Implementers can call getItemAtPosition(position) if they need to access the data associated with the selected item.
onItemClick
in interface AdapterView.OnItemClickListener
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.public boolean flagActionItems()
MenuPresenter
flagActionItems
in interface MenuPresenter
public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item)
MenuPresenter
expandItemActionView
in interface MenuPresenter
menu
- Menu containing the item to be expandeditem
- Item to be expandedpublic boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item)
MenuPresenter
collapseItemActionView
in interface MenuPresenter
menu
- Menu containing the item to be collapseditem
- Item to be collapsedpublic void saveHierarchyState(Bundle outState)
public void restoreHierarchyState(Bundle inState)
public void setId(int id)
public int getId()
MenuPresenter
getId
in interface MenuPresenter
public Parcelable onSaveInstanceState()
MenuPresenter
MenuPresenter.onRestoreInstanceState(Parcelable)
method of the presenter sharing the same ID later.onSaveInstanceState
in interface MenuPresenter
public void onRestoreInstanceState(Parcelable state)
MenuPresenter
onRestoreInstanceState
in interface MenuPresenter
state
- The previously saved instance state