summaryrefslogtreecommitdiff
path: root/core/java/android/widget/CompoundButton.java
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2015-09-04 10:10:42 -0400
committerAlan Viverette <alanv@google.com>2015-09-04 10:10:42 -0400
commitad0020f8075ecf768cb610d60dbb167d41f0fbe5 (patch)
treeb09784bf0b41d3a09a581d9f70333955622ea693 /core/java/android/widget/CompoundButton.java
parent3916e7e757c8d157ee736a86b25c41a0a74015f6 (diff)
Invalidate when Drawable.setState() returns true
Ensures views that manage drawables follow the contract set forth in the Drawable.setState() documentation. Bug: 23792020 Change-Id: I4e5a449cd6535487873fd8443da50555c38e8ed9
Diffstat (limited to 'core/java/android/widget/CompoundButton.java')
-rw-r--r--core/java/android/widget/CompoundButton.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java
index 602e1ab069dd..b19fe17054d7 100644
--- a/core/java/android/widget/CompoundButton.java
+++ b/core/java/android/widget/CompoundButton.java
@@ -456,14 +456,11 @@ public abstract class CompoundButton extends Button implements Checkable {
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
-
- if (mButtonDrawable != null) {
- int[] myDrawableState = getDrawableState();
-
- // Set the state of the Drawable
- mButtonDrawable.setState(myDrawableState);
-
- invalidate();
+
+ final Drawable buttonDrawable = mButtonDrawable;
+ if (buttonDrawable != null && buttonDrawable.isStateful()
+ && buttonDrawable.setState(getDrawableState())) {
+ invalidateDrawable(buttonDrawable);
}
}