am 0a8a3eab: am 46b4920a: Merge "Propagate state changes even when we don\'t change drawable index" into lmp-mr1-dev
* commit '0a8a3eab8bfc3390e1225dfade40599279b4921b': Propagate state changes even when we don't change drawable index
This commit is contained in:
@@ -139,27 +139,15 @@ public class AnimatedStateListDrawable extends StateListDrawable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onStateChange(int[] stateSet) {
|
protected boolean onStateChange(int[] stateSet) {
|
||||||
final int keyframeIndex = mState.indexOfKeyframe(stateSet);
|
// If we're not already at the target index, either attempt to find a
|
||||||
if (keyframeIndex == getCurrentIndex()) {
|
// valid transition to it or jump directly there.
|
||||||
// Propagate state change to current keyframe.
|
final int targetIndex = mState.indexOfKeyframe(stateSet);
|
||||||
final Drawable current = getCurrent();
|
final boolean changedIndex = targetIndex != getCurrentIndex()
|
||||||
if (current != null) {
|
&& (selectTransition(targetIndex) || selectDrawable(targetIndex));
|
||||||
return current.setState(stateSet);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attempt to find a valid transition to the keyframe.
|
// Always call super.onStateChanged() to propagate the state change to
|
||||||
if (selectTransition(keyframeIndex)) {
|
// the current drawable.
|
||||||
return true;
|
return super.onStateChange(stateSet) || changedIndex;
|
||||||
}
|
|
||||||
|
|
||||||
// No valid transition, attempt to jump directly to the keyframe.
|
|
||||||
if (selectDrawable(keyframeIndex)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onStateChange(stateSet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean selectTransition(int toIndex) {
|
private boolean selectTransition(int toIndex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user