Add getter for current play time
BUG: 30993532 Test: cts tests in the same topic branch Change-Id: I45ee9c61f53051fcac3399eebc378aa2c0ce056d
This commit is contained in:
@@ -3137,6 +3137,7 @@ package android.animation {
|
||||
public final class AnimatorSet extends android.animation.Animator {
|
||||
ctor public AnimatorSet();
|
||||
method public java.util.ArrayList<android.animation.Animator> getChildAnimations();
|
||||
method public long getCurrentPlayTime();
|
||||
method public long getDuration();
|
||||
method public long getStartDelay();
|
||||
method public boolean isRunning();
|
||||
|
||||
@@ -3257,6 +3257,7 @@ package android.animation {
|
||||
public final class AnimatorSet extends android.animation.Animator {
|
||||
ctor public AnimatorSet();
|
||||
method public java.util.ArrayList<android.animation.Animator> getChildAnimations();
|
||||
method public long getCurrentPlayTime();
|
||||
method public long getDuration();
|
||||
method public long getStartDelay();
|
||||
method public boolean isRunning();
|
||||
|
||||
@@ -3137,6 +3137,7 @@ package android.animation {
|
||||
public final class AnimatorSet extends android.animation.Animator {
|
||||
ctor public AnimatorSet();
|
||||
method public java.util.ArrayList<android.animation.Animator> getChildAnimations();
|
||||
method public long getCurrentPlayTime();
|
||||
method public long getDuration();
|
||||
method public long getStartDelay();
|
||||
method public boolean isRunning();
|
||||
|
||||
@@ -934,6 +934,31 @@ public final class AnimatorSet extends Animator implements AnimationHandler.Anim
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current position of the animation in time, which is equal to the current
|
||||
* time minus the time that the animation started. An animation that is not yet started will
|
||||
* return a value of zero, unless the animation has has its play time set via
|
||||
* {@link #setCurrentPlayTime(long)}, in which case it will return the time that was set.
|
||||
*
|
||||
* @return The current position in time of the animation.
|
||||
*/
|
||||
public long getCurrentPlayTime() {
|
||||
if (mSeekState.isActive()) {
|
||||
return mSeekState.getPlayTime();
|
||||
}
|
||||
if (mLastFrameTime == -1) {
|
||||
// Not yet started or during start delay
|
||||
return 0;
|
||||
}
|
||||
float durationScale = ValueAnimator.getDurationScale();
|
||||
durationScale = durationScale == 0 ? 1 : durationScale;
|
||||
if (mReversing) {
|
||||
return (long) ((mLastFrameTime - mFirstFrame) / durationScale);
|
||||
} else {
|
||||
return (long) ((mLastFrameTime - mFirstFrame - mStartDelay) / durationScale);
|
||||
}
|
||||
}
|
||||
|
||||
private void initChildren() {
|
||||
if (!isInitialized()) {
|
||||
mChildrenInitialized = true;
|
||||
|
||||
Reference in New Issue
Block a user