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

Commit d72901f0 authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Update drawable container constant state following clone" into lmp-mr1-dev

parents 9a888816 5ed8f278
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -651,6 +651,7 @@ public class AnimatedStateListDrawable extends StateListDrawable {
        }
    }

    @Override
    protected void setConstantState(@NonNull DrawableContainerState state) {
        super.setConstantState(state);

+12 −3
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.annotation.NonNull;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.Resources.Theme;
@@ -81,7 +82,7 @@ import android.util.AttributeSet;
 * @attr ref android.R.styleable#AnimationDrawableItem_drawable
 */
public class AnimationDrawable extends DrawableContainer implements Runnable, Animatable {
    private final AnimationState mAnimationState;
    private AnimationState mAnimationState;

    /** The current frame, may be -1 when not animating. */
    private int mCurFrame = -1;
@@ -408,9 +409,17 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An
        }
    }

    @Override
    protected void setConstantState(@NonNull DrawableContainerState state) {
        super.setConstantState(state);

        if (state instanceof AnimationState) {
            mAnimationState = (AnimationState) state;
        }
    }

    private AnimationDrawable(AnimationState state, Resources res) {
        AnimationState as = new AnimationState(state, this, res);
        mAnimationState = as;
        final AnimationState as = new AnimationState(state, this, res);
        setConstantState(as);
        if (state != null) {
            setFrame(0, true, false);
+3 −2
Original line number Diff line number Diff line
@@ -567,8 +567,9 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
    @Override
    public Drawable mutate() {
        if (!mMutated && super.mutate() == this) {
            mDrawableContainerState = cloneConstantState();
            mDrawableContainerState.mutate();
            final DrawableContainerState clone = cloneConstantState();
            clone.mutate();
            setConstantState(clone);
            mMutated = true;
        }
        return this;
+12 −3
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.annotation.NonNull;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.Resources.Theme;
@@ -57,7 +58,7 @@ import android.util.AttributeSet;
 * @attr ref android.R.styleable#LevelListDrawableItem_drawable
 */
public class LevelListDrawable extends DrawableContainer {
    private final LevelListState mLevelListState;
    private LevelListState mLevelListState;
    private boolean mMutated;

    public LevelListDrawable() {
@@ -227,9 +228,17 @@ public class LevelListDrawable extends DrawableContainer {
        }
    }

    @Override
    protected void setConstantState(@NonNull DrawableContainerState state) {
        super.setConstantState(state);

        if (state instanceof LevelListState) {
            mLevelListState = (LevelListState) state;
        }
    }

    private LevelListDrawable(LevelListState state, Resources res) {
        LevelListState as = new LevelListState(state, this, res);
        mLevelListState = as;
        final LevelListState as = new LevelListState(state, this, res);
        setConstantState(as);
        onLevelChange(getLevel());
    }