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

Commit 1309914e authored by Doris Liu's avatar Doris Liu
Browse files

Refactor AnimatorSet in prep for adding more functionalities

This refactor changes how relationships (i.e. with/after/before)
among Animators in an AnimatorSet are represented. Specifically,
a directed graph is used: parent-child indicates sequential
relationship, and siblings will fire simultaneously.

This CL also fixed the issue where start delays for Animators that
play together are not handled correctly.

Bug: 11649073
Bug: 18069038
Change-Id: I5dad4889fbe81440e66bf98601e8a247d3aedb2e
parent 511758a3
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -26,6 +26,11 @@ import java.util.ArrayList;
 */
public abstract class Animator implements Cloneable {

    /**
     * The value used to indicate infinite duration (e.g. when Animators repeat infinitely).
     * @hide
     */
    public static final long DURATION_INFINITE = -1;
    /**
     * The set of listeners to be sent events through the life of an animation.
     */
@@ -183,6 +188,16 @@ public abstract class Animator implements Cloneable {
     */
    public abstract long getDuration();

    /**
     * Gets the total duration of the animation, accounting for animation sequences, start delay,
     * and repeating. Return {@link #DURATION_INFINITE} if the duration is infinite.
     * @hide
     * TODO: Unhide
     */
    public long getTotalDuration() {
        return getStartDelay() + getDuration();
    }

    /**
     * The time interpolator used in calculating the elapsed fraction of the
     * animation. The interpolator determines whether the animation runs with
+460 −463

File changed.

Preview size limit exceeded, changes collapsed.

+12 −0
Original line number Diff line number Diff line
@@ -574,6 +574,18 @@ public class ValueAnimator extends Animator {
        return mUnscaledDuration;
    }

    /**
     * @hide
     */
    @Override
    public long getTotalDuration() {
        if (mRepeatCount == INFINITE) {
            return DURATION_INFINITE;
        } else {
            return mUnscaledStartDelay + (mUnscaledDuration * (mRepeatCount + 1));
        }
    }

    /**
     * Sets the position of the animation to the specified point in time. This time should
     * be between 0 and the total duration of the animation, including any repetition. If
+8 −0
Original line number Diff line number Diff line
@@ -336,6 +336,14 @@ public class RenderNodeAnimator extends Animator {
        return mUnscaledDuration;
    }

    /**
     * @hide
     */
    @Override
    public long getTotalDuration() {
        return mUnscaledDuration + mUnscaledStartDelay;
    }

    @Override
    public boolean isRunning() {
        return mState == STATE_DELAYED || mState == STATE_RUNNING;