Merge "Update drawable container constant state following clone" into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d72901f0d4
@@ -651,6 +651,7 @@ public class AnimatedStateListDrawable extends StateListDrawable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setConstantState(@NonNull DrawableContainerState state) {
|
||||
super.setConstantState(state);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user