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

Commit 2140c549 authored by Doris Liu's avatar Doris Liu Committed by Android (Google) Code Review
Browse files

Merge "Check whether AnimationDrawable is one shot only when visibility changes"

parents 56dafdb5 084938f2
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -105,10 +105,12 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An
    /**
     * Sets whether this AnimationDrawable is visible.
     * <p>
     * When the drawable becomes invisible, it will pause its animation. A
     * subsequent change to visible with <code>restart</code> set to true will
     * restart the animation from the first frame. If <code>restart</code> is
     * false, the animation will resume from the most recent frame.
     * When the drawable becomes invisible, it will pause its animation. A subsequent change to
     * visible with <code>restart</code> set to true will restart the animation from the
     * first frame. If <code>restart</code> is false, the drawable will resume from the most recent
     * frame. If the drawable has already reached the last frame, it will then loop back to the
     * first frame, unless it's a one shot drawable (set through {@link #setOneShot(boolean)}),
     * in which case, it will stay on the last frame.
     *
     * @param visible true if visible, false otherwise
     * @param restart when visible, true to force the animation to restart
@@ -120,7 +122,7 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An
        final boolean changed = super.setVisible(visible, restart);
        if (visible) {
            if (restart || changed) {
                boolean startFromZero = restart || !mRunning ||
                boolean startFromZero = restart || (!mRunning && !mAnimationState.mOneShot) ||
                        mCurFrame >= mAnimationState.getChildCount();
                setFrame(startFromZero ? 0 : mCurFrame, true, mAnimating);
            }
@@ -131,7 +133,7 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An
    }

    /**
     * Starts the animation, looping if necessary. This method has no effect
     * Starts the animation from the first frame, looping if necessary. This method has no effect
     * if the animation is running.
     * <p>
     * <strong>Note:</strong> Do not call this in the
@@ -158,7 +160,7 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An
    }

    /**
     * Stops the animation. This method has no effect if the animation is not
     * Stops the animation at the current frame. This method has no effect if the animation is not
     * running.
     *
     * @see #isRunning()
@@ -169,6 +171,7 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An
        mAnimating = false;

        if (isRunning()) {
            mCurFrame = 0;
            unscheduleSelf(this);
        }
    }
@@ -196,7 +199,6 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An

    @Override
    public void unscheduleSelf(Runnable what) {
        mCurFrame = 0;
        mRunning = false;
        super.unscheduleSelf(what);
    }