AnimatorListeners
added to them.
*/
public abstract class Animator implements Cloneable {
/**
* The set of listeners to be sent events through the life of an animation.
*/
ArrayListThe animation started by calling this method will be run on the thread that called * this method. This thread should have a Looper on it (a runtime exception will be thrown if * this is not the case). Also, if the animation will animate * properties of objects in the view hierarchy, then the calling thread should be the UI * thread for that view hierarchy.
* */ public void start() { } /** * Cancels the animation. Unlike {@link #end()},cancel()
causes the animation to
* stop in its tracks, sending an
* {@link android.animation.Animator.AnimatorListener#onAnimationCancel(Animator)} to
* its listeners, followed by an
* {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} message.
*
* This method must be called on the thread that is running the animation.
*/ public void cancel() { } /** * Ends the animation. This causes the animation to assign the end value of the property being * animated, then calling the * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} method on * its listeners. * *This method must be called on the thread that is running the animation.
*/ public void end() { } /** * The amount of time, in milliseconds, to delay starting the animation after * {@link #start()} is called. * * @return the number of milliseconds to delay running the animation */ public abstract long getStartDelay(); /** * The amount of time, in milliseconds, to delay starting the animation after * {@link #start()} is called. * @param startDelay The amount of the delay, in milliseconds */ public abstract void setStartDelay(long startDelay); /** * Sets the length of the animation. * * @param duration The length of the animation, in milliseconds. */ public abstract Animator setDuration(long duration); /** * Gets the length of the animation. * * @return The length of the animation, in milliseconds. */ public abstract long getDuration(); /** * The time interpolator used in calculating the elapsed fraction of this animation. The * interpolator determines whether the animation runs with linear or non-linear motion, * such as acceleration and deceleration. The default value is * {@link android.view.animation.AccelerateDecelerateInterpolator} * * @param value the interpolator to be used by this animation */ public abstract void setInterpolator(TimeInterpolator value); /** * Returns whether this Animator is currently running (having been started and not yet ended). * @return Whether the Animator is running. */ public abstract boolean isRunning(); /** * Adds a listener to the set of listeners that are sent events through the life of an * animation, such as start, repeat, and end. * * @param listener the listener to be added to the current set of listeners for this animation. */ public void addListener(AnimatorListener listener) { if (mListeners == null) { mListeners = new ArrayListAnimator
object.
*
* @return ArrayListgetListeners()
followed by calling clear()
on the
* returned list of listeners.
*/
public void removeAllListeners() {
if (mListeners != null) {
mListeners.clear();
mListeners = null;
}
}
@Override
public Animator clone() {
try {
final Animator anim = (Animator) super.clone();
if (mListeners != null) {
ArrayListAn animation listener receives notifications from an animation. * Notifications indicate animation related events, such as the end or the * repetition of the animation.
*/ public static interface AnimatorListener { /** *Notifies the start of the animation.
* * @param animation The started animation. */ void onAnimationStart(Animator animation); /** *Notifies the end of the animation. This callback is not invoked * for animations with repeat count set to INFINITE.
* * @param animation The animation which reached its end. */ void onAnimationEnd(Animator animation); /** *Notifies the cancellation of the animation. This callback is not invoked * for animations with repeat count set to INFINITE.
* * @param animation The animation which was canceled. */ void onAnimationCancel(Animator animation); /** *Notifies the repetition of the animation.
* * @param animation The animation which was repeated. */ void onAnimationRepeat(Animator animation); } }