java.lang.Object
com.thecoderscorner.menu.mgr.DialogManager
Direct Known Subclasses:
EmptyDialogManager

public abstract class DialogManager extends Object
Dialog Manager provides the capability to work with dialogs, to present them, change the values of them and also to update them from a remote command arriving. This includes being able to deal with activation from a remote. Usually, for local or remote activities this class is extended and the dialogDidChange method is implemented to update the UI accordingly and optionally, the buttonWasPressed method may need to be overridden.
  • Field Details

  • Constructor Details

    • DialogManager

      public DialogManager()
  • Method Details

    • isDialogVisible

      public boolean isDialogVisible()
      Returns:
      true if the dialog is on display, otherwise false
    • updateStateFromCommand

      public void updateStateFromCommand(MenuCommand cmd)
      Update the dialog from an incoming remote command, checking first if the command is a dialog event, and then updating all the fields and calling dialogDidChange.
      Parameters:
      cmd - the command
    • withTitle

      public DialogManager withTitle(String title, boolean silent)
      Using builder syntax you can show dialog using the with commands, this sets the title
      Parameters:
      title - the new title
      silent - if an update should be triggered
      Returns:
      itself for chaining
    • withMessage

      public DialogManager withMessage(String message, boolean silent)
      Using builder syntax you can show dialog using the with commands this sets the message
      Parameters:
      message - the message field
      silent - if an update should be triggered
      Returns:
      itself for chaining
    • withDelegate

      public DialogManager withDelegate(DialogShowMode mode, Function<MenuButtonType,Boolean> delegate)
      Using builder syntax you can show dialog using the with commands this sets the delegate and mode
      Parameters:
      mode - the mode in which the dialog should show, regular, or locally
      delegate - the delegate to call on a button being pressed
      Returns:
      itself for chaining
    • showDialogWithButtons

      public void showDialogWithButtons(MenuButtonType b1, MenuButtonType b2)
      Actually shows the dialog with the buttons provided
      Parameters:
      b1 - one of the button types
      b2 - one of the button types
    • hideDialog

      public void hideDialog()
      Remove the dialog from display
    • toPrintableText

      protected String toPrintableText(MenuButtonType type)
    • getDialogShowMode

      public DialogShowMode getDialogShowMode()
      Returns:
      the mode in which the dialog is being shown
    • getButtonType

      public MenuButtonType getButtonType(int btnNum)
      the button type for a given button number - 0 or 1
      Parameters:
      btnNum - the button number
      Returns:
      the button type
    • dialogDidChange

      protected abstract void dialogDidChange()
      this should be overridden to update the UI, it signifies that the dialog has changed
    • buttonWasPressed

      protected void buttonWasPressed(MenuButtonType btn)
      This can be overridden if needed, it will be called whenever a button is pressed.
      Parameters:
      btn - the button type