com.nineoldandroids.animation
Class Animator

java.lang.Object
  extended by com.nineoldandroids.animation.Animator
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
AnimatorSet, ValueAnimator

public abstract class Animator
extends Object
implements Cloneable

This is the superclass for classes which provide basic support for animations which can be started, ended, and have AnimatorListeners added to them.


Nested Class Summary
static interface Animator.AnimatorListener
          An animation listener receives notifications from an animation.
 
Constructor Summary
Animator()
           
 
Method Summary
 void addListener(Animator.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.
 void cancel()
          Cancels the animation.
 Animator clone()
           
 void end()
          Ends the animation.
abstract  long getDuration()
          Gets the length of the animation.
 ArrayList<Animator.AnimatorListener> getListeners()
          Gets the set of Animator.AnimatorListener objects that are currently listening for events on this Animator object.
abstract  long getStartDelay()
          The amount of time, in milliseconds, to delay starting the animation after start() is called.
abstract  boolean isRunning()
          Returns whether this Animator is currently running (having been started and gone past any initial startDelay period and not yet ended).
 boolean isStarted()
          Returns whether this Animator has been started and not yet ended.
 void removeAllListeners()
          Removes all listeners from this object.
 void removeListener(Animator.AnimatorListener listener)
          Removes a listener from the set listening to this animation.
abstract  Animator setDuration(long duration)
          Sets the length of the animation.
abstract  void setInterpolator(Interpolator value)
          The time interpolator used in calculating the elapsed fraction of this animation.
abstract  void setStartDelay(long startDelay)
          The amount of time, in milliseconds, to delay starting 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.
 void start()
          Starts this animation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Animator

public Animator()
Method Detail

start

public 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 Animator.AnimatorListener.onAnimationStart(Animator) for any listeners of this animator.

The 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.


cancel

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

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


end

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

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


getStartDelay

public abstract long getStartDelay()
The amount of time, in milliseconds, to delay starting the animation after start() is called.

Returns:
the number of milliseconds to delay running the animation

setStartDelay

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

Parameters:
startDelay - The amount of the delay, in milliseconds

setDuration

public abstract Animator setDuration(long duration)
Sets the length of the animation.

Parameters:
duration - The length of the animation, in milliseconds.

getDuration

public abstract long getDuration()
Gets the length of the animation.

Returns:
The length of the animation, in milliseconds.

setInterpolator

public abstract void setInterpolator(Interpolator value)
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 AccelerateDecelerateInterpolator

Parameters:
value - the interpolator to be used by 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 boolean isStarted()
Returns whether this Animator has been started and not yet ended. This state is a superset of the state of isRunning(), because an Animator with a nonzero startDelay will return true for isStarted() during the delay phase, whereas isRunning() will return true only after the delay phase is complete.

Returns:
Whether the Animator has been started and not yet ended.

addListener

public void addListener(Animator.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 void removeListener(Animator.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.

getListeners

public ArrayList<Animator.AnimatorListener> getListeners()
Gets the set of Animator.AnimatorListener objects that are currently listening for events on this Animator object.

Returns:
ArrayList The set of listeners.

removeAllListeners

public void removeAllListeners()
Removes all listeners from this object. This is equivalent to calling getListeners() followed by calling clear() on the returned list 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. An 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. An 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(Object target)
Sets the target object whose property will be animated by this animation. Not all subclasses operate on target objects (for example, ValueAnimator, but this method is on the superclass for the convenience of dealing generically with those subclasses that do handle targets.

Parameters:
target - The object being animated