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) {
|
protected void setConstantState(@NonNull DrawableContainerState state) {
|
||||||
super.setConstantState(state);
|
super.setConstantState(state);
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.io.IOException;
|
|||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.content.res.Resources.Theme;
|
import android.content.res.Resources.Theme;
|
||||||
@@ -81,7 +82,7 @@ import android.util.AttributeSet;
|
|||||||
* @attr ref android.R.styleable#AnimationDrawableItem_drawable
|
* @attr ref android.R.styleable#AnimationDrawableItem_drawable
|
||||||
*/
|
*/
|
||||||
public class AnimationDrawable extends DrawableContainer implements Runnable, Animatable {
|
public class AnimationDrawable extends DrawableContainer implements Runnable, Animatable {
|
||||||
private final AnimationState mAnimationState;
|
private AnimationState mAnimationState;
|
||||||
|
|
||||||
/** The current frame, may be -1 when not animating. */
|
/** The current frame, may be -1 when not animating. */
|
||||||
private int mCurFrame = -1;
|
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) {
|
private AnimationDrawable(AnimationState state, Resources res) {
|
||||||
AnimationState as = new AnimationState(state, this, res);
|
final AnimationState as = new AnimationState(state, this, res);
|
||||||
mAnimationState = as;
|
|
||||||
setConstantState(as);
|
setConstantState(as);
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
setFrame(0, true, false);
|
setFrame(0, true, false);
|
||||||
|
|||||||
@@ -567,8 +567,9 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
|||||||
@Override
|
@Override
|
||||||
public Drawable mutate() {
|
public Drawable mutate() {
|
||||||
if (!mMutated && super.mutate() == this) {
|
if (!mMutated && super.mutate() == this) {
|
||||||
mDrawableContainerState = cloneConstantState();
|
final DrawableContainerState clone = cloneConstantState();
|
||||||
mDrawableContainerState.mutate();
|
clone.mutate();
|
||||||
|
setConstantState(clone);
|
||||||
mMutated = true;
|
mMutated = true;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import java.io.IOException;
|
|||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.content.res.Resources.Theme;
|
import android.content.res.Resources.Theme;
|
||||||
@@ -57,7 +58,7 @@ import android.util.AttributeSet;
|
|||||||
* @attr ref android.R.styleable#LevelListDrawableItem_drawable
|
* @attr ref android.R.styleable#LevelListDrawableItem_drawable
|
||||||
*/
|
*/
|
||||||
public class LevelListDrawable extends DrawableContainer {
|
public class LevelListDrawable extends DrawableContainer {
|
||||||
private final LevelListState mLevelListState;
|
private LevelListState mLevelListState;
|
||||||
private boolean mMutated;
|
private boolean mMutated;
|
||||||
|
|
||||||
public LevelListDrawable() {
|
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) {
|
private LevelListDrawable(LevelListState state, Resources res) {
|
||||||
LevelListState as = new LevelListState(state, this, res);
|
final LevelListState as = new LevelListState(state, this, res);
|
||||||
mLevelListState = as;
|
|
||||||
setConstantState(as);
|
setConstantState(as);
|
||||||
onLevelChange(getLevel());
|
onLevelChange(getLevel());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user