Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd65ab04 authored by Doris Liu's avatar Doris Liu
Browse files

Add getter for current play time

BUG: 30993532
Test: cts tests in the same topic branch
Change-Id: I45ee9c61f53051fcac3399eebc378aa2c0ce056d
parent 6d452092
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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();
+1 −0
Original line number Diff line number Diff line
@@ -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();
+1 −0
Original line number Diff line number Diff line
@@ -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();
+25 −0
Original line number Diff line number Diff line
@@ -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;