Package icyllis.modernui.animation

# Class Animator

java.lang.Object
icyllis.modernui.animation.Animator

All Implemented Interfaces:
  `Cloneable`

Direct Known Subclasses:
  `AnimatorSet`, `ValueAnimator`

public abstract class Animator extends Object implements Cloneable
This is the base for classes which provide basic support for animations which can be started, ended, and have listeners added to them.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final long`
  `DURATION_INFINITE`
  The value used to indicate infinite duration (e.g.
  `static final org.apache.logging.log4j.Marker`
  `MARKER`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Animator()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final void`
  `addListener(AnimatorListener listener)`
  Adds a listener to the set of listeners that are sent events through the life of an animation, such as start, repeat, and end.
  `abstract void`
  `cancel()`
  Cancels the animation.
  `boolean`
  `canReverse()`
  `Animator`
  `clone()`
  `abstract void`
  `end()`
  Ends the animation.
  `abstract long`
  `getDuration()`
  Gets the duration of the animation.
  `abstract TimeInterpolator`
  `getInterpolator()`
  Returns the timing interpolator that this animation uses.
  `final List<AnimatorListener>`
  `getListeners()`
  Gets the set of `AnimatorListener` objects that are currently listening for events on this `Animator` object.
  `abstract long`
  `getStartDelay()`
  The amount of time, in milliseconds, to delay processing the animation after `start()` is called.
  `abstract long`
  `getTotalDuration()`
  Gets the total duration of the animation, accounting for animation sequences, start delay, and repeating.
  `final boolean`
  `isPaused()`
  Returns whether this animator is currently in a paused state.
  `abstract boolean`
  `isRunning()`
  Returns whether this Animator is currently running (having been started and gone past any initial startDelay period and not yet ended).
  `abstract boolean`
  `isStarted()`
  Returns whether this Animator has been started and not yet ended.
  `void`
  `pause()`
  Pauses a running animation.
  `final void`
  `removeAllListeners()`
  Removes all `listeners` from this object.
  `final void`
  `removeListener(AnimatorListener listener)`
  Removes a listener from the set listening to this animation.
  `void`
  `resume()`
  Resumes a paused animation, causing the animator to pick up where it left off when it was paused.
  `void`
  `reverse()`
  `abstract Animator`
  `setDuration(long duration)`
  Sets the duration of the animation.
  `abstract void`
  `setInterpolator(TimeInterpolator value)`
  The time interpolator used in calculating the elapsed fraction of the animation.
  `abstract void`
  `setStartDelay(long startDelay)`
  The amount of time, in milliseconds, to delay processing the animation after `start()` is called.
  `void`
  `setTarget(Object target)`
  Sets the target object whose property will be animated by this animation.
  `void`
  `setupEndValues()`
  This method tells the object to use appropriate information to extract ending values for the animation.
  `void`
  `setupStartValues()`
  This method tells the object to use appropriate information to extract starting values for the animation.
  `abstract void`
  `start()`
  Starts this animation.

  ### Methods inherited from class java.lang.Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### MARKER

    public static final org.apache.logging.log4j.Marker MARKER

  - ### DURATION_INFINITE

    public static final long DURATION_INFINITE
    The value used to indicate infinite duration (e.g. when Animators repeat infinitely).
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### Animator

    public Animator()

- ## Method Details

  - ### start

    public abstract void start()
    Starts this animation. If the animation has a nonzero startDelay, the animation will start running after that delay elapses. A non-delayed animation will have its initial value(s) set immediately, followed by calls to `AnimatorListener.onAnimationStart(Animator, boolean)` for any listeners of this animator.

    The animation started by calling this method will be run on the thread that called this method.

  - ### cancel

    public abstract void cancel()
    Cancels the animation. Unlike `end()`, `cancel()` causes the animation to stop in its tracks, sending an `AnimatorListener.onAnimationCancel(Animator)` to its listeners, followed by an `AnimatorListener.onAnimationEnd(Animator, boolean)` message.

    This method must be called on the thread that is running the animation.

  - ### end

    public abstract void end()
    Ends the animation. This causes the animation to assign the end value of the property being animated, then calling the `AnimatorListener.onAnimationEnd(Animator, boolean)` method on its listeners.

    This method must be called on the thread that is running the animation.

  - ### pause

    public void pause()
    Pauses a running animation. This method should only be called on the same thread on which the animation was started. If the animation has not yet been `started` or has since ended, then the call is ignored. Paused animations can be resumed by calling `resume()`.
    See Also:
      - `resume()`
      - `isPaused()`
      - `AnimatorListener.onAnimationPause(Animator)`

  - ### resume

    public void resume()
    Resumes a paused animation, causing the animator to pick up where it left off when it was paused. This method should only be called on the same thread on which the animation was started. Calls to resume() on an animator that is not currently paused will be ignored.
    See Also:
      - `pause()`
      - `isPaused()`
      - `AnimatorListener.onAnimationResume(Animator)`

  - ### isPaused

    public final boolean isPaused()
    Returns whether this animator is currently in a paused state.
    Returns:
      True if the animator is currently paused, false otherwise.
    See Also:
      - `pause()`
      - `resume()`

  - ### setStartDelay

    public abstract void setStartDelay(long startDelay)
    The amount of time, in milliseconds, to delay processing the animation after `start()` is called.
    Parameters:
      `startDelay` - The amount of the delay, in milliseconds

  - ### getStartDelay

    public abstract long getStartDelay()
    The amount of time, in milliseconds, to delay processing the animation after `start()` is called.
    Returns:
      the number of milliseconds to delay running the animation

  - ### setDuration

    public abstract Animator setDuration(long duration)
    Sets the duration of the animation.
    Parameters:
      `duration` - The length of the animation, in milliseconds.

  - ### getDuration

    public abstract long getDuration()
    Gets the duration of the animation.
    Returns:
      The length of the animation, in milliseconds.

  - ### getTotalDuration

    public abstract long getTotalDuration()
    Gets the total duration of the animation, accounting for animation sequences, start delay, and repeating. Return `DURATION_INFINITE` if the duration is infinite.
    Returns:
      Total time an animation takes to finish, starting from the time `start()` is called. `DURATION_INFINITE` will be returned if the animation or any child animation repeats infinite times.

  - ### setInterpolator

    public abstract void setInterpolator(TimeInterpolator value)
    The time interpolator used in calculating the elapsed fraction of the animation. The interpolator determines whether the animation runs with linear or non-linear motion, such as acceleration and deceleration. The default value is `TimeInterpolator.ACCELERATE_DECELERATE`.
    Parameters:
      `value` - the interpolator to be used by this animation

  - ### getInterpolator

    public abstract TimeInterpolator getInterpolator()
    Returns the timing interpolator that this animation uses.
    Returns:
      The timing interpolator for this animation.

  - ### isRunning

    public abstract boolean isRunning()
    Returns whether this Animator is currently running (having been started and gone past any initial startDelay period and not yet ended).
    Returns:
      Whether the Animator is running.

  - ### isStarted

    public abstract boolean isStarted()
    Returns whether this Animator has been started and not yet ended. For reusable Animators (which most Animators are, apart from the one-shot animator), this state is a superset of `isRunning()`, because an Animator with a nonzero `getStartDelay()` will return true during the delay phase, whereas `isRunning()` will return true only after the delay phase is complete. Non-reusable animators will always return true after they have been started, because they cannot return to a non-started state.
    Returns:
      whether the Animator has been started and not yet ended.

  - ### addListener

    public final void addListener(@NonNull AnimatorListener listener)
    Adds a listener to the set of listeners that are sent events through the life of an animation, such as start, repeat, and end.
    Parameters:
      `listener` - the listener to be added to the current set of listeners for this animation.

  - ### removeListener

    public final void removeListener(@NonNull AnimatorListener listener)
    Removes a listener from the set listening to this animation.
    Parameters:
      `listener` - the listener to be removed from the current set of listeners for this animation.

  - ### removeAllListeners

    public final void removeAllListeners()
    Removes all `listeners` from this object.

  - ### getListeners

    @Nullable public final List<AnimatorListener> getListeners()
    Gets the set of `AnimatorListener` objects that are currently listening for events on this `Animator` object.
    Returns:
      The set of listeners.

  - ### clone

    public Animator clone()
    Overrides:
      `clone` in class `Object`

  - ### setupStartValues

    public void setupStartValues()
    This method tells the object to use appropriate information to extract starting values for the animation. For example, a AnimatorSet object will pass this call to its child objects to tell them to set up the values. A ObjectAnimator object will use the information it has about its target object and PropertyValuesHolder objects to get the start values for its properties. A ValueAnimator object will ignore the request since it does not have enough information (such as a target object) to gather these values.

  - ### setupEndValues

    public void setupEndValues()
    This method tells the object to use appropriate information to extract ending values for the animation. For example, a AnimatorSet object will pass this call to its child objects to tell them to set up the values. A ObjectAnimator object will use the information it has about its target object and PropertyValuesHolder objects to get the start values for its properties. A ValueAnimator object will ignore the request since it does not have enough information (such as a target object) to gather these values.

  - ### setTarget

    public void setTarget(@Nullable Object target)
    Sets the target object whose property will be animated by this animation. Not all subclasses operate on target objects, but this method is on the superclass for the convenience of dealing generically with those subclasses that do handle targets.

    Note: The target is stored as a weak reference internally to avoid leaking resources by having animators directly reference old targets. Therefore, you should ensure that animator targets always have a hard reference elsewhere.

    Parameters:
      `target` - The object being animated

  - ### canReverse

    @Internal public boolean canReverse()

  - ### reverse

    @Internal public void reverse()