am 5f876974: am 667ec63c: Merge "Don\'t propagate AnimatedStateListDrawable state change to super()" into lmp-mr1-dev
* commit '5f876974d025406cd48eac9759989c09c899a4dd': Don't propagate AnimatedStateListDrawable state change to super()
This commit is contained in:
@@ -142,12 +142,18 @@ public class AnimatedStateListDrawable extends StateListDrawable {
|
|||||||
// If we're not already at the target index, either attempt to find a
|
// If we're not already at the target index, either attempt to find a
|
||||||
// valid transition to it or jump directly there.
|
// valid transition to it or jump directly there.
|
||||||
final int targetIndex = mState.indexOfKeyframe(stateSet);
|
final int targetIndex = mState.indexOfKeyframe(stateSet);
|
||||||
final boolean changedIndex = targetIndex != getCurrentIndex()
|
boolean changed = targetIndex != getCurrentIndex()
|
||||||
&& (selectTransition(targetIndex) || selectDrawable(targetIndex));
|
&& (selectTransition(targetIndex) || selectDrawable(targetIndex));
|
||||||
|
|
||||||
// Always call super.onStateChanged() to propagate the state change to
|
// We need to propagate the state change to the current drawable, but
|
||||||
// the current drawable.
|
// we can't call StateListDrawable.onStateChange() without changing the
|
||||||
return super.onStateChange(stateSet) || changedIndex;
|
// current drawable.
|
||||||
|
final Drawable current = getCurrent();
|
||||||
|
if (current != null) {
|
||||||
|
changed |= current.setState(stateSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean selectTransition(int toIndex) {
|
private boolean selectTransition(int toIndex) {
|
||||||
|
|||||||
@@ -285,7 +285,6 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An
|
|||||||
|
|
||||||
private void inflateChildElements(Resources r, XmlPullParser parser, AttributeSet attrs,
|
private void inflateChildElements(Resources r, XmlPullParser parser, AttributeSet attrs,
|
||||||
Theme theme) throws XmlPullParserException, IOException {
|
Theme theme) throws XmlPullParserException, IOException {
|
||||||
TypedArray a;
|
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
final int innerDepth = parser.getDepth()+1;
|
final int innerDepth = parser.getDepth()+1;
|
||||||
@@ -300,7 +299,8 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
a = obtainAttributes(r, theme, attrs, R.styleable.AnimationDrawableItem);
|
final TypedArray a = obtainAttributes(r, theme, attrs,
|
||||||
|
R.styleable.AnimationDrawableItem);
|
||||||
|
|
||||||
final int duration = a.getInt(R.styleable.AnimationDrawableItem_duration, -1);
|
final int duration = a.getInt(R.styleable.AnimationDrawableItem_duration, -1);
|
||||||
if (duration < 0) {
|
if (duration < 0) {
|
||||||
@@ -308,14 +308,11 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An
|
|||||||
+ ": <item> tag requires a 'duration' attribute");
|
+ ": <item> tag requires a 'duration' attribute");
|
||||||
}
|
}
|
||||||
|
|
||||||
final int drawableRes = a.getResourceId(R.styleable.AnimationDrawableItem_drawable, 0);
|
Drawable dr = a.getDrawable(R.styleable.AnimationDrawableItem_drawable);
|
||||||
|
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
Drawable dr;
|
if (dr == null) {
|
||||||
if (drawableRes != 0) {
|
|
||||||
dr = r.getDrawable(drawableRes, theme);
|
|
||||||
} else {
|
|
||||||
while ((type=parser.next()) == XmlPullParser.TEXT) {
|
while ((type=parser.next()) == XmlPullParser.TEXT) {
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user