java.lang.Object
uk.co.samuelwall.materialtaptargetprompt.extras.PromptFocal
Direct Known Subclasses:
CirclePromptFocal, RectanglePromptFocal

public abstract class PromptFocal
extends java.lang.Object
Used to render the prompt focal.
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected int mBaseRippleAlpha
    The alpha value for the ripple.
    protected boolean mDrawRipple
    Should the ripple be drawn.
  • Constructor Summary

    Constructors
    Constructor Description
    PromptFocal()  
  • Method Summary

    Modifier and Type Method Description
    android.graphics.PointF calculateAngleEdgePoint​(float angle, float padding)
    Calculate the point on the focal edge based on the angle.
    boolean contains​(float x, float y)
    Does the element contain the point.
    void draw​(android.graphics.Canvas canvas)
    Draw the element.
    abstract android.graphics.RectF getBounds()
    Get the focal bounds at scale 1.
    android.graphics.Path getPath()
    Get the focal path to be drawn.
    abstract void prepare​(PromptOptions options, float targetX, float targetY)
    Setup the focal ready for rendering when targeting a point on the screen, called prior to first render.
    abstract void prepare​(PromptOptions options, android.view.View target, int[] promptViewPosition)
    Setup the focal ready for rendering when targeting a view, called prior to first render.
    abstract void setColour​(int colour)
    Set the focal colour.
    void setDrawRipple​(boolean drawRipple)
    Sets whether the ripple is drawn around the focal.
    void setRippleAlpha​(int rippleAlpha)
    Sets the alpha value to use for the ripple colour.
    void update​(PromptOptions options, float revealModifier, float alphaModifier)
    Update the current prompt rendering state based on the prompt options and current reveal & alpha scales.
    abstract void updateRipple​(float revealModifier, float alphaModifier)
    Update the ripple around the focal.

    Methods inherited from class java.lang.Object

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

    • mDrawRipple

      protected boolean mDrawRipple
      Should the ripple be drawn.
    • mBaseRippleAlpha

      protected int mBaseRippleAlpha
      The alpha value for the ripple.
  • Constructor Details

    • PromptFocal

      public PromptFocal()
  • Method Details

    • setDrawRipple

      public void setDrawRipple​(boolean drawRipple)
      Sets whether the ripple is drawn around the focal.
      Parameters:
      drawRipple - True to draw the ripple.
    • setRippleAlpha

      public void setRippleAlpha​(int rippleAlpha)
      Sets the alpha value to use for the ripple colour.
      Parameters:
      rippleAlpha - The ripple alpha value between 0 - 255
    • getPath

      public android.graphics.Path getPath()
      Get the focal path to be drawn. Override this to support a transparent focal colour.
      Returns:
      The path used to draw the focal
    • calculateAngleEdgePoint

      @NonNull public android.graphics.PointF calculateAngleEdgePoint​(float angle, float padding)
      Calculate the point on the focal edge based on the angle. This is called after prepare(PromptOptions, float, float) or prepare(PromptOptions, View, int[]). Base implementation assumes that focal is a rectangle.
      Parameters:
      angle - The angle with 0 based on the right.
      padding - The padding added to the focal bounds.
      Returns:
      The calculated point
    • setColour

      public abstract void setColour​(int colour)
      Set the focal colour.
      Parameters:
      colour - Int colour.
    • getBounds

      @NonNull public abstract android.graphics.RectF getBounds()
      Get the focal bounds at scale 1.
      Returns:
      The screen area that the focal is drawn in at scale 1.
    • prepare

      public abstract void prepare​(@NonNull PromptOptions options, @NonNull android.view.View target, int[] promptViewPosition)
      Setup the focal ready for rendering when targeting a view, called prior to first render.
      Parameters:
      options - The option that the prompt was built from.
      target - The prompt target view.
      promptViewPosition - The prompt views screen position.
    • prepare

      public abstract void prepare​(@NonNull PromptOptions options, float targetX, float targetY)
      Setup the focal ready for rendering when targeting a point on the screen, called prior to first render.
      Parameters:
      options - The option that the prompt was built from.
      targetX - The target screen x position.
      targetY - The target screen y position.
    • updateRipple

      public abstract void updateRipple​(float revealModifier, float alphaModifier)
      Update the ripple around the focal.
      Parameters:
      revealModifier - The amount to scale the ripple by where a 1 value is the same size as the focal.
      alphaModifier - The amount to modify the ripple alpha by.
    • update

      void update​(@NonNull PromptOptions options, float revealModifier, float alphaModifier)
      Update the current prompt rendering state based on the prompt options and current reveal & alpha scales.
      Parameters:
      options - The options used to create the prompt.
      revealModifier - The current size/revealed scale from 0 - 1.
      alphaModifier - The current colour alpha scale from 0 - 1.
    • draw

      void draw​(@NonNull android.graphics.Canvas canvas)
      Draw the element.
      Parameters:
      canvas - The canvas to draw to.
    • contains

      boolean contains​(float x, float y)
      Does the element contain the point.
      Parameters:
      x - x coordinate.
      y - y coordinate.
      Returns:
      True if the element contains the point, false otherwise.