Class MaterialTapTargetPrompt

java.lang.Object
uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt

public class MaterialTapTargetPrompt
extends java.lang.Object
A Material Design tap target onboarding implementation.

For more information about onboarding and tap targets, read the Onboarding Material Design guidelines.

  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  MaterialTapTargetPrompt.Builder
    A builder to create a MaterialTapTargetPrompt instance.
    static interface  MaterialTapTargetPrompt.PromptStateChangeListener
    Interface definition for a callback to be invoked when a prompts state changes.
  • Field Summary

    Fields
    Modifier and Type Field Description
    static int STATE_BACK_BUTTON_PRESSED
    The prompt has been dismissed by the system back button being pressed.
    static int STATE_DISMISSED
    The prompt has been removed from view after the prompt has either been pressed somewhere other than the prompt target or the system back button has been pressed.
    static int STATE_DISMISSING
    The dismiss() method has been called and the prompt is being removed from view.
    static int STATE_FINISHED
    The prompt has been removed from view after the prompt has been pressed in the focal area.
    static int STATE_FINISHING
    The finish() method has been called and the prompt is being removed from view.
    static int STATE_FOCAL_PRESSED
    The prompt target has been pressed in the focal area.
    static int STATE_NON_FOCAL_PRESSED
    The prompt has been pressed outside the focal area.
    static int STATE_NOT_SHOWN
    Prompt has yet to be shown.
    static int STATE_REVEALED
    Prompt reveal animation has finished and the prompt is displayed.
    static int STATE_REVEALING
    Prompt is reveal animation is running.
    static int STATE_SHOW_FOR_TIMEOUT
    The prompt has been dismissed by the show for timeout.
  • Method Summary

    Modifier and Type Method Description
    void cancelShowForTimer()
    Cancel the show for timer if it has been created.
    static MaterialTapTargetPrompt createDefault​(PromptOptions promptOptions)
    Creates a prompt with the supplied options.
    void dismiss()
    Removes the prompt from view, using a contract and fade animation.
    void finish()
    Removes the prompt from view, using a expand and fade animation.
    int getState()
    Get the current state of the prompt.
    protected void onPromptStateChanged​(int state)
    Handles emitting the prompt state changed events.
    void show()
    Displays the prompt.
    void showFor​(long millis)
    Displays the prompt for a maximum amount of time.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • STATE_NOT_SHOWN

      public static final int STATE_NOT_SHOWN
      Prompt has yet to be shown.
      See Also:
      Constant Field Values
    • STATE_REVEALING

      public static final int STATE_REVEALING
      Prompt is reveal animation is running.
      See Also:
      Constant Field Values
    • STATE_REVEALED

      public static final int STATE_REVEALED
      Prompt reveal animation has finished and the prompt is displayed.
      See Also:
      Constant Field Values
    • STATE_FOCAL_PRESSED

      public static final int STATE_FOCAL_PRESSED
      The prompt target has been pressed in the focal area.
      See Also:
      Constant Field Values
    • STATE_FINISHED

      public static final int STATE_FINISHED
      The prompt has been removed from view after the prompt has been pressed in the focal area.
      See Also:
      Constant Field Values
    • STATE_DISMISSING

      public static final int STATE_DISMISSING
      The dismiss() method has been called and the prompt is being removed from view.
      See Also:
      Constant Field Values
    • STATE_DISMISSED

      public static final int STATE_DISMISSED
      The prompt has been removed from view after the prompt has either been pressed somewhere other than the prompt target or the system back button has been pressed.
      See Also:
      Constant Field Values
    • STATE_FINISHING

      public static final int STATE_FINISHING
      The finish() method has been called and the prompt is being removed from view.
      See Also:
      Constant Field Values
    • STATE_NON_FOCAL_PRESSED

      public static final int STATE_NON_FOCAL_PRESSED
      The prompt has been pressed outside the focal area.
      See Also:
      Constant Field Values
    • STATE_SHOW_FOR_TIMEOUT

      public static final int STATE_SHOW_FOR_TIMEOUT
      The prompt has been dismissed by the show for timeout.
      See Also:
      Constant Field Values
    • STATE_BACK_BUTTON_PRESSED

      public static final int STATE_BACK_BUTTON_PRESSED
      The prompt has been dismissed by the system back button being pressed.
      See Also:
      Constant Field Values
  • Method Details

    • show

      public void show()
      Displays the prompt.
    • showFor

      public void showFor​(long millis)
      Displays the prompt for a maximum amount of time.
      Parameters:
      millis - The number of milliseconds to show the prompt for.
    • cancelShowForTimer

      public void cancelShowForTimer()
      Cancel the show for timer if it has been created.
    • getState

      public int getState()
      Get the current state of the prompt.
      See Also:
      STATE_NOT_SHOWN, STATE_REVEALING, STATE_REVEALED, STATE_FOCAL_PRESSED, STATE_NON_FOCAL_PRESSED, STATE_BACK_BUTTON_PRESSED, STATE_FINISHING, STATE_FINISHED, STATE_DISMISSING, STATE_DISMISSED
    • finish

      public void finish()
      Removes the prompt from view, using a expand and fade animation.

      This is treated as if the user has touched the target focal point.

    • dismiss

      public void dismiss()
      Removes the prompt from view, using a contract and fade animation.

      This is treated as if the user has touched outside the target focal point.

    • onPromptStateChanged

      protected void onPromptStateChanged​(int state)
      Handles emitting the prompt state changed events.
      Parameters:
      state - The state that the prompt is now in.
    • createDefault

      @NonNull public static MaterialTapTargetPrompt createDefault​(@NonNull PromptOptions promptOptions)
      Creates a prompt with the supplied options.
      Parameters:
      promptOptions - The options to use to create the prompt.
      Returns:
      The created prompt.