summaryrefslogtreecommitdiffstats
path: root/core/java/android/widget/Switch.java
diff options
context:
space:
mode:
authorYu Haonong <yuhaonong@gmail.com>2012-07-12 12:49:54 +0800
committerYu Haonong <yuhaonong@gmail.com>2012-07-18 16:29:54 +0800
commitca13b1562cedafb17a4f116fb521ed5388423755 (patch)
tree03446fa491af2cd257dda39379446883a897ebdb /core/java/android/widget/Switch.java
parent33034b13cae1429d526722374bd39be3f9605ae4 (diff)
downloadframeworks_base-ca13b1562cedafb17a4f116fb521ed5388423755.zip
frameworks_base-ca13b1562cedafb17a4f116fb521ed5388423755.tar.gz
frameworks_base-ca13b1562cedafb17a4f116fb521ed5388423755.tar.bz2
Switch widget: Fix ON/OFF option update error
When calling setChecked() from a listener which is invoked by the Switch toggle, setChecked() will be called recursively, causing the value of mThumbPosition overridden by the outer setChecked(). This make the nested setChecked() unable to update the "Thumb" position correctly. Set mThumbPosition to sync up with the exact checked state of the Switch to avoid update error. Issue 34748 Change-Id: Id4aa389114dcc590430b11626c80d29c9c6016a0 Signed-off-by: Yu Haonong <yuhaonong@gmail.com>
Diffstat (limited to 'core/java/android/widget/Switch.java')
-rw-r--r--core/java/android/widget/Switch.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java
index 471f259..9ea1372 100644
--- a/core/java/android/widget/Switch.java
+++ b/core/java/android/widget/Switch.java
@@ -675,7 +675,7 @@ public class Switch extends CompoundButton {
@Override
public void setChecked(boolean checked) {
super.setChecked(checked);
- mThumbPosition = checked ? getThumbScrollRange() : 0;
+ mThumbPosition = isChecked() ? getThumbScrollRange() : 0;
invalidate();
}