public class RenderNodeAnimator extends Animator
Animator.AnimatorListener, Animator.AnimatorPauseListener
Modifier and Type | Field and Description |
---|---|
static int |
ALPHA |
static int |
LAST_VALUE |
static int |
PAINT_ALPHA
Field for the Paint alpha channel, which should be specified as a value
between 0 and 255.
|
static int |
PAINT_STROKE_WIDTH |
static int |
ROTATION |
static int |
ROTATION_X |
static int |
ROTATION_Y |
static int |
SCALE_X |
static int |
SCALE_Y |
static int |
TRANSLATION_X |
static int |
TRANSLATION_Y |
static int |
TRANSLATION_Z |
static int |
X |
static int |
Y |
static int |
Z |
DURATION_INFINITE
Constructor and Description |
---|
RenderNodeAnimator(CanvasProperty<Float> property,
float finalValue) |
RenderNodeAnimator(CanvasProperty<Paint> property,
int paintField,
float finalValue)
Creates a new render node animator for a field on a Paint property.
|
RenderNodeAnimator(int property,
float finalValue) |
RenderNodeAnimator(int x,
int y,
float startRadius,
float endRadius) |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the animation.
|
Animator |
clone()
Creates and returns a copy of this object.
|
void |
end()
Ends the animation.
|
long |
getDuration()
Gets the duration of the animation.
|
TimeInterpolator |
getInterpolator()
Returns the timing interpolator that this animation uses.
|
long |
getStartDelay()
The amount of time, in milliseconds, to delay processing the animation
after
Animator.start() is called. |
long |
getTotalDuration()
Gets the total duration of the animation, accounting for animation sequences, start delay,
and repeating.
|
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.
|
static int |
mapViewPropertyToRenderProperty(int viewProperty) |
protected void |
onFinished() |
void |
pause()
Pauses a running animation.
|
void |
resume()
Resumes a paused animation, causing the animator to pick up where it left off
when it was paused.
|
void |
setAllowRunningAsynchronously(boolean mayRunAsync)
Whether or not the Animator is allowed to run asynchronously off of
the UI thread.
|
RenderNodeAnimator |
setDuration(long duration)
Sets the duration of the animation.
|
void |
setInterpolator(TimeInterpolator interpolator)
The time interpolator used in calculating the elapsed fraction of the
animation.
|
void |
setStartDelay(long startDelay)
The amount of time, in milliseconds, to delay processing the animation
after
Animator.start() is called. |
void |
setStartValue(float startValue) |
void |
setTarget(Canvas canvas) |
void |
setTarget(View view) |
void |
start()
Starts this animation.
|
addListener, addPauseListener, appendChangingConfigurations, canReverse, createConstantState, getChangingConfigurations, getListeners, isPaused, removeAllListeners, removeListener, removePauseListener, reverse, setChangingConfigurations, setTarget, setupEndValues, setupStartValues
public static final int TRANSLATION_X
public static final int TRANSLATION_Y
public static final int TRANSLATION_Z
public static final int SCALE_X
public static final int SCALE_Y
public static final int ROTATION
public static final int ROTATION_X
public static final int ROTATION_Y
public static final int X
public static final int Y
public static final int Z
public static final int ALPHA
public static final int LAST_VALUE
public static final int PAINT_STROKE_WIDTH
public static final int PAINT_ALPHA
public RenderNodeAnimator(int property, float finalValue)
public RenderNodeAnimator(CanvasProperty<Float> property, float finalValue)
public RenderNodeAnimator(CanvasProperty<Paint> property, int paintField, float finalValue)
property
- The paint property to targetpaintField
- Paint field to animate, one of PAINT_ALPHA
or
PAINT_STROKE_WIDTH
finalValue
- The target value for the propertypublic RenderNodeAnimator(int x, int y, float startRadius, float endRadius)
public static int mapViewPropertyToRenderProperty(int viewProperty)
public void start()
Animator
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.
public void cancel()
Animator
Animator.end()
, cancel()
causes the animation to
stop in its tracks, sending an
Animator.AnimatorListener.onAnimationCancel(Animator)
to
its listeners, followed by an
Animator.AnimatorListener.onAnimationEnd(Animator)
message.
This method must be called on the thread that is running the animation.
public void end()
Animator
Animator.AnimatorListener.onAnimationEnd(Animator)
method on
its listeners.
This method must be called on the thread that is running the animation.
public void pause()
Animator
started
or has since ended, then the call is ignored. Paused
animations can be resumed by calling Animator.resume()
.pause
in class Animator
Animator.resume()
,
Animator.isPaused()
,
Animator.AnimatorPauseListener
public void resume()
Animator
resume
in class Animator
Animator.pause()
,
Animator.isPaused()
,
Animator.AnimatorPauseListener
public void setTarget(View view)
public void setTarget(Canvas canvas)
public void setStartValue(float startValue)
public void setStartDelay(long startDelay)
Animator
Animator.start()
is called.setStartDelay
in class Animator
startDelay
- The amount of the delay, in millisecondspublic long getStartDelay()
Animator
Animator.start()
is called.getStartDelay
in class Animator
public RenderNodeAnimator setDuration(long duration)
Animator
setDuration
in class Animator
duration
- The length of the animation, in milliseconds.public long getDuration()
Animator
getDuration
in class Animator
public long getTotalDuration()
Animator
Animator.DURATION_INFINITE
if the duration is infinite.getTotalDuration
in class Animator
Animator.start()
is called. Animator.DURATION_INFINITE
will be returned if the animation or any
child animation repeats infinite times.public boolean isRunning()
Animator
public boolean isStarted()
Animator
createCircularReveal()
),
this state is a superset of Animator.isRunning()
, because an Animator with a
nonzero startDelay
will return true for Animator.isStarted()
during
the delay phase, whereas Animator.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.public void setInterpolator(TimeInterpolator interpolator)
Animator
AccelerateDecelerateInterpolator
.setInterpolator
in class Animator
interpolator
- the interpolator to be used by this animationpublic TimeInterpolator getInterpolator()
Animator
getInterpolator
in class Animator
protected void onFinished()
public Animator clone()
Object
x
, the expression:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true
, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x)
true
, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
super.clone
. If a class and all of its superclasses (except
Object
) obey this convention, it will be the case that
x.clone().getClass() == x.getClass()
.
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by super.clone
before returning it. Typically, this means
copying any mutable objects that comprise the internal "deep structure"
of the object being cloned and replacing the references to these
objects with references to the copies. If a class contains only
primitive fields or references to immutable objects, then it is usually
the case that no fields in the object returned by super.clone
need to be modified.
The method clone
for class Object
performs a
specific cloning operation. First, if the class of this object does
not implement the interface Cloneable
, then a
CloneNotSupportedException
is thrown. Note that all arrays
are considered to implement the interface Cloneable
and that
the return type of the clone
method of an array type T[]
is T[]
where T is any reference or primitive type.
Otherwise, this method creates a new instance of the class of this
object and initializes all its fields with exactly the contents of
the corresponding fields of this object, as if by assignment; the
contents of the fields are not themselves cloned. Thus, this method
performs a "shallow copy" of this object, not a "deep copy" operation.
The class Object
does not itself implement the interface
Cloneable
, so calling the clone
method on an object
whose class is Object
will result in throwing an
exception at run time.
public void setAllowRunningAsynchronously(boolean mayRunAsync)
Animator
Whether or not the Animator is allowed to run asynchronously off of the UI thread. This is a hint that informs the Animator that it is OK to run the animation off-thread, however the Animator may decide that it must run the animation on the UI thread anyway.
Regardless of whether or not the animation runs asynchronously, all listener callbacks will be called on the UI thread.
To be able to use this hint the following must be true:
Animator.isStarted()
is true. Requests
to change duration, delay, etc... may be ignored.Animator.AnimatorListener.onAnimationEnd(Animator)
or
Animator.AnimatorListener.onAnimationRepeat(Animator)
may end up delayed
as they must be posted back to the UI thread, and any actions performed
by those callbacks (such as starting new animations) will not happen
in the same frame.Animator.cancel()
, Animator.end()
, Animator.reverse()
, etc...)
may be asynchronous. It is guaranteed that all state changes that are
performed on the UI thread in the same frame will be applied as a single
atomic update, however that frame may be the current frame,
the next frame, or some future frame. This will also impact the observed
state of the Animator. For example, Animator.isStarted()
may still return true
after a call to Animator.end()
. Using the lifecycle callbacks is preferred over
queries to Animator.isStarted()
, Animator.isRunning()
, and Animator.isPaused()
for this reason.setAllowRunningAsynchronously
in class Animator