Class CascadingMenuPopup

java.lang.Object
icyllis.modernui.view.menu.MenuPopup
icyllis.modernui.view.menu.CascadingMenuPopup
All Implemented Interfaces:
MenuPresenter, ShowableListMenu, View.OnKeyListener, AdapterView.OnItemClickListener, PopupWindow.OnDismissListener

public final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, View.OnKeyListener, PopupWindow.OnDismissListener
A popup for a menu which will allow multiple submenus to appear in a cascading fashion, side by side.
  • Constructor Details

    • CascadingMenuPopup

      public CascadingMenuPopup(@NonNull Context context, @NonNull View anchorView, boolean overflowOnly)
      Initializes a new cascading-capable menu popup.
  • Method Details

    • setForceShowIcon

      public void setForceShowIcon(boolean forceShow)
      Specified by:
      setForceShowIcon in class MenuPopup
    • show

      public void show()
      Specified by:
      show in interface ShowableListMenu
    • dismiss

      public void dismiss()
      Specified by:
      dismiss in interface ShowableListMenu
    • onKey

      public boolean onKey(View v, int keyCode, KeyEvent event)
      Description copied from interface: View.OnKeyListener
      Called when a hardware key is dispatched to a view. This allows listeners to get a chance to respond before the target view.

      Key presses in software keyboards will generally NOT trigger this method, although some may elect to do so in some situations. Do not assume a software input method has to be key-based; even if it is, it may use key presses in a different way than you expect, so there is no way to reliably catch soft input key presses.

      Specified by:
      onKey in interface View.OnKeyListener
      Parameters:
      v - The view the key has been dispatched to.
      keyCode - The code for the physical key that was pressed
      event - The KeyEvent object containing full information about the event.
      Returns:
      True if the listener has consumed the event, false otherwise.
    • addMenu

      public void addMenu(MenuBuilder menu)
      Description copied from class: MenuPopup
      Adds the given menu to the popup, if it is capable of displaying submenus within itself. If menu is the first menu shown, it won't be displayed until show() is called. If the popup was already showing, adding a submenu via this method will cause that new submenu to be shown immediately (that is, if this MenuPopup implementation is capable of showing its own submenus).
      Specified by:
      addMenu in class MenuPopup
      Parameters:
      menu - menu
    • isShowing

      public boolean isShowing()
      Specified by:
      isShowing in interface ShowableListMenu
      Returns:
      true if the popup is currently showing, false otherwise.
    • onDismiss

      public void onDismiss()
      Called when one or more of the popup windows was dismissed.
      Specified by:
      onDismiss in interface PopupWindow.OnDismissListener
    • 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 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 - the menu or submenu that is closing
      allMenusAreClosing - true if all displayed menus and submenus are closing, false if only the specified menu is 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.
    • setGravity

      public void setGravity(int dropDownGravity)
      Specified by:
      setGravity in class MenuPopup
    • setAnchorView

      public void setAnchorView(@NonNull View anchor)
      Specified by:
      setAnchorView in class MenuPopup
    • setOnDismissListener

      public void setOnDismissListener(PopupWindow.OnDismissListener listener)
      Description copied from class: MenuPopup
      Set a listener to receive a callback when the popup is dismissed.
      Specified by:
      setOnDismissListener in class MenuPopup
      Parameters:
      listener - Listener that will be notified when the popup is dismissed.
    • getListView

      public ListView getListView()
      Specified by:
      getListView in interface ShowableListMenu
      Returns:
      The internal ListView for the visible menu.
    • setHorizontalOffset

      public void setHorizontalOffset(int x)
      Specified by:
      setHorizontalOffset in class MenuPopup
    • setVerticalOffset

      public void setVerticalOffset(int y)
      Specified by:
      setVerticalOffset in class MenuPopup
    • setShowTitle

      public void setShowTitle(boolean showTitle)
      Description copied from class: MenuPopup
      Set whether a title entry should be shown in the popup menu (if a title exists for the menu).
      Specified by:
      setShowTitle in class MenuPopup
      Parameters:
      showTitle - show title