@NotThreadSafe @TrackPartiallyInitialized public static class Animator.Builder extends java.lang.Object
Animator
instances.
The default values are listed in the table below.
Method | Description | Default |
---|---|---|
addTarget(TimingTarget) |
gets timing events while the animation is running | none |
Animator.setDefaultTimingSource(TimingSource) or
Animator.Builder(TimingSource) |
a timing source for the animation | none |
setDuration(long, TimeUnit) |
the duration of one cycle of the animation | 1 second |
setDisposeTimingSource(boolean) |
if the TimingSource used by the animation should be disposed at
the end of the animation. |
false |
setEndBehavior(Animator.EndBehavior) |
what happens at the end of the animation | Animator.EndBehavior.HOLD |
setInterpolator(Interpolator) |
the interpolator for each animation cycle | LinearInterpolator |
setRepeatBehavior(Animator.RepeatBehavior) |
the repeat behavior of the animation | Animator.RepeatBehavior.REVERSE |
setRepeatCount(long) |
the number of times the animation cycle will repeat | 1 |
setStartDirection(Animator.Direction) |
the start direction for the initial animation cycle | Animator.Direction.FORWARD |
setStartDelay(long, TimeUnit) |
a delay prior to starting the first animation cycle after the call to
Animator.start() or Animator.startReverse() . |
none |
setDebugName(String) |
a meaningful name for the animation used by the
Animator.toString() method |
null |
Values can be "cloned" from another Animator
or
Animator.Builder
using one of several copy methods
provided by this class.
Instances of this class are not thread safe and are intended to be
thread-confined. However, the Animator
objects produced are
thread-safe.
Constructor and Description |
---|
Animator.Builder()
Constructs an animation builder instance using the default timing source.
|
Animator.Builder(TimingSource timingSource)
Constructs an animation builder instance.
|
Modifier and Type | Method and Description |
---|---|
Animator.Builder |
addTarget(TimingTarget target)
Adds a
TimingTarget to the list of targets that get notified of
each timing event while the animation is running. |
Animator.Builder |
addTargets(java.util.Collection<TimingTarget> targets)
Adds the collection of passed
TimingTarget s to the list of
targets that get notified of each timing event while the animation is
running. |
Animator.Builder |
addTargets(TimingTarget... targets)
Adds the collection of passed
TimingTarget s to the list of
targets that get notified of each timing event while the animation is
running. |
Animator |
build()
Constructs an animation with the settings defined by this builder.
|
Animator.Builder |
copy(Animator.Builder from)
Copies all values from the passed animation builder into this builder
not including its timing source.
|
Animator.Builder |
copy(Animator.Builder from,
boolean copyTargets)
Copies all values from the passed animation builder into this builder
not including its timing source.
|
Animator.Builder |
copy(Animator from)
Copies all values from the passed animator into this builder not
including its timing source.
|
Animator.Builder |
copy(Animator from,
boolean copyTargets)
Copies all values from the passed animator into this builder not
including its timing source.
|
Animator.Builder |
setDebugName(java.lang.String name)
Sets the "debug" name of the animation.
|
Animator.Builder |
setDisposeTimingSource(boolean value)
Sets if the animation should invoke
TimingSource.dispose() on its
timing source when it ends. |
Animator.Builder |
setDuration(long value,
java.util.concurrent.TimeUnit unit)
Sets the duration of one cycle of the animation.
|
Animator.Builder |
setEndBehavior(Animator.EndBehavior value)
Sets the behavior at the end of the animation.
|
Animator.Builder |
setInterpolator(Interpolator value)
Sets the interpolator for each animation cycle.
|
Animator.Builder |
setRepeatBehavior(Animator.RepeatBehavior value)
Sets the repeat behavior of the animation.
|
Animator.Builder |
setRepeatCount(long value)
Sets the number of times the animation cycle will repeat.
|
Animator.Builder |
setStartDelay(long value,
java.util.concurrent.TimeUnit unit)
Sets the start delay of the animation.
|
Animator.Builder |
setStartDirection(Animator.Direction value)
Sets the start direction for the initial animation cycle.
|
public Animator.Builder(TimingSource timingSource)
timingSource
- the timing source for the animation.public Animator.Builder()
setDefaultTimingSource(TimingSource)
@NonNull public Animator.Builder addTarget(TimingTarget target)
TimingTarget
to the list of targets that get notified of
each timing event while the animation is running.
TimingTarget
s will be called in the order they are added.
Duplicate additions are ignored.
target
- a TimingTarget
object.@NonNull public Animator.Builder addTargets(java.util.Collection<TimingTarget> targets)
TimingTarget
s to the list of
targets that get notified of each timing event while the animation is
running.
TimingTarget
s will be called in the order they are added.
Duplicate additions are ignored.
targets
- a collection of TimingTarget
objects.@NonNull public Animator.Builder addTargets(TimingTarget... targets)
TimingTarget
s to the list of
targets that get notified of each timing event while the animation is
running.
TimingTarget
s will be called in the order they are added.
Duplicate additions are ignored.
targets
- a collection of TimingTarget
objects.@NonNull public Animator.Builder setDebugName(java.lang.String name)
null
.name
- a name of the animation. A null
value is allowed.@NonNull public Animator.Builder setDisposeTimingSource(boolean value)
TimingSource.dispose()
on its
timing source when it ends. The default value is false
.value
- true
if the animation should invoke
TimingSource.dispose()
on its timing source when it
ends, false
if not.@NonNull public Animator.Builder setDuration(long value, java.util.concurrent.TimeUnit unit)
value
- the duration of the animation. This value must be >= 1.unit
- the time unit of the value parameter. A null
value is
equivalent to setting the default unit of
TimeUnit.SECONDS
.java.lang.IllegalStateException
- if value is not >= 1.@NonNull public Animator.Builder setEndBehavior(Animator.EndBehavior value)
Animator.EndBehavior.HOLD
.value
- the behavior at the end of the animation. A null
value
is equivalent to setting the default value.@NonNull public Animator.Builder setInterpolator(Interpolator value)
value
- the interpolation to use each animation cycle. A null
value is equivalent to setting the default value.@NonNull public Animator.Builder setRepeatBehavior(Animator.RepeatBehavior value)
Animator.RepeatBehavior.REVERSE
.value
- the behavior for each successive animation cycle. A null
value is equivalent to setting the default value.@NonNull public Animator.Builder setRepeatCount(long value)
value
- number of times the animation cycle will repeat. This value must
be >= 1 or Animator.INFINITE
for animations that repeat
indefinitely.java.lang.IllegalArgumentException
- if value is not >=1 or Animator.INFINITE
.@NonNull public Animator.Builder setStartDirection(Animator.Direction value)
Animator.Direction.FORWARD
.value
- initial animation cycle direction. A null
value is
equivalent to setting the default value.@NonNull public Animator.Builder setStartDelay(long value, java.util.concurrent.TimeUnit unit)
Animator.start()
or Animator.startReverse()
. The default
value is 0 indicating no start delay.value
- the start delay of the animation. This value must be >= 0 where
a value of 0 means no start delay.unit
- the time unit of the value parameter. A null
value is
equivalent to setting the default unit of
TimeUnit.SECONDS
.java.lang.IllegalStateException
- if value is not >= 0.@NonNull public Animator.Builder copy(Animator from)
This method allows an animation to be used as a template for other animations and can simplify construction of a large number of similar animations.
from
- an animation, ignored if null
.copy(Animator, boolean)
@NonNull public Animator.Builder copy(Animator from, boolean copyTargets)
This method allows an animation to be used as a template for other animations and can simplify construction of a large number of similar animations.
from
- an animation, ignored if null
.copyTargets
- true
if timing targets should also be copied into this
builder, false
if not.copy(Animator)
@NonNull public Animator.Builder copy(Animator.Builder from)
This method allows an animation builder to be used as a template for other animations and can simplify construction of a large number of similar animations.
from
- an animation builder, ignored if null
.copy(Animator.Builder, boolean)
@NonNull public Animator.Builder copy(Animator.Builder from, boolean copyTargets)
This method allows an animation builder to be used as a template for other animations and can simplify construction of a large number of similar animations.
from
- an animation builder, ignored if null
.copyTargets
- true
if timing targets should also be copied into this
builder, false
if not.copy(Animator.Builder)