Class StandardMenuPopup

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

A standard menu popup in which when a submenu is opened, it replaces its parent menu in the viewport.
  • Constructor Details

  • Method Details

    • setForceShowIcon

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

      public void setGravity(int gravity)
      Specified by:
      setGravity in class MenuPopup
    • show

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

      public void dismiss()
      Specified by:
      dismiss in interface ShowableListMenu
    • 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
    • onDismiss

      public void onDismiss()
      Description copied from interface: PopupWindow.OnDismissListener
      Called when this popup window is 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(@NonNull 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.
    • setAnchorView

      public void setAnchorView(View anchor)
      Specified by:
      setAnchorView in class MenuPopup
    • 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.
    • 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