public interface TimingTarget
TimingTargetAdapter
and
override methods of interest or they can create or use an implementation of
TimingTarget
. A timing target can be passed into an
Animator.Builder
via the
Animator.Builder.addTarget(TimingTarget)
method or set later with the
Animator.addTarget(TimingTarget)
method. Any animation may have
multiple timing targets.
The thread context of calls to all the methods defined below is that of the
of the timing source being used by the animation. This thread context is
typically documented for each TimingSource
subclass.
Modifier and Type | Method and Description |
---|---|
void |
begin(Animator source)
Called once when the animation begins.
|
void |
end(Animator source)
Called once when the animation ends.
|
void |
repeat(Animator source)
Called when the animation repeats the animation cycle.
|
void |
reverse(Animator source)
Called when a running animation is reversed via
Animator.reverseNow() . |
void |
timingEvent(Animator source,
double fraction)
This method will receive all of the timing events during an animation.
|
void begin(Animator source)
This is always the first call made to any timing target.
source
- the animation.void end(Animator source)
This is always the last call made to any timing target.
source
- the animation.void repeat(Animator source)
Animator.getRepeatCount()
- 1 times, unless
Animator.getRepeatCount()
== Animator.INFINITE
in which
case it will be invoked until the animation is manually stopped.
if Animator.RepeatBehavior.REVERSE
is used then the animation will
reverse direction on repeat.
source
- the animation.void reverse(Animator source)
Animator.reverseNow()
. This method is not invoked when
Animator.startReverse()
is called or when the direction changes on
repeat—it is only used as a notification when an animation is
reversed via Animator.reverseNow()
.
Notifications occur at the rate of the TimingSource
being used by
the animation. Therefore, several calls to Animator.reverseNow()
may be coalesced into a single call of this method. However, all directed
reversals take place, i.e., calls to Animator.reverseNow()
are not
ignored.
It is also possible, if Animator.RepeatBehavior.REVERSE
is used,
that a repeat which reverses the animation could occur during the same tick
of the TimingSource
that a reversal due to
Animator.reverseNow()
does. In this case both reversals are taken
into account before this method is invoked. If this occurs this method is
invoked before repeat(Animator)
.
Overall, client code should understand that this method is not a general
notification that the animation's direction has changed. If such a
mechanism is needed the value of Animator.getCurrentDirection()
should be monitored in calls to timingEvent(Animator, double)
.
This method's purpose is to inform that the Animator.reverseNow()
method has been invoked one or more times on the animation.
source
- the animation.void timingEvent(Animator source, double fraction)
source
- the animation.fraction
- the fraction of completion between the start and end of the
current cycle. Note that on reversing cycles (
Animator.Direction.BACKWARD
) the fraction decreases from
1.0 to 0 on backwards-running cycles (A call to
Animator.getCurrentDirection()
will report which direction
the animation is going). Note also that animations with a duration
of INFINITE
will have an undefined value
for the fraction, since there is no fraction that makes sense if
the animation has no defined length.