Loading core/java/android/widget/Switch.java +18 −0 Original line number Diff line number Diff line Loading @@ -208,7 +208,13 @@ public class Switch extends CompoundButton { final TypedArray a = context.obtainStyledAttributes( attrs, com.android.internal.R.styleable.Switch, defStyleAttr, defStyleRes); mThumbDrawable = a.getDrawable(com.android.internal.R.styleable.Switch_thumb); if (mThumbDrawable != null) { mThumbDrawable.setCallback(this); } mTrackDrawable = a.getDrawable(com.android.internal.R.styleable.Switch_track); if (mTrackDrawable != null) { mTrackDrawable.setCallback(this); } mTextOn = a.getText(com.android.internal.R.styleable.Switch_textOn); mTextOff = a.getText(com.android.internal.R.styleable.Switch_textOff); mShowText = a.getBoolean(com.android.internal.R.styleable.Switch_showText, true); Loading Loading @@ -433,7 +439,13 @@ public class Switch extends CompoundButton { * @attr ref android.R.styleable#Switch_track */ public void setTrackDrawable(Drawable track) { if (mTrackDrawable != null) { mTrackDrawable.setCallback(null); } mTrackDrawable = track; if (track != null) { track.setCallback(this); } requestLayout(); } Loading Loading @@ -468,7 +480,13 @@ public class Switch extends CompoundButton { * @attr ref android.R.styleable#Switch_thumb */ public void setThumbDrawable(Drawable thumb) { if (mThumbDrawable != null) { mThumbDrawable.setCallback(null); } mThumbDrawable = thumb; if (thumb != null) { thumb.setCallback(this); } requestLayout(); } Loading graphics/java/android/graphics/drawable/AnimatedStateListDrawable.java +7 −2 Original line number Diff line number Diff line Loading @@ -91,7 +91,8 @@ public class AnimatedStateListDrawable extends StateListDrawable { if (visible) { mTransition.start(); } else { mTransition.stop(); // Ensure we're showing the correct state when visible. jumpToCurrentState(); } } Loading Loading @@ -140,7 +141,11 @@ public class AnimatedStateListDrawable extends StateListDrawable { protected boolean onStateChange(int[] stateSet) { final int keyframeIndex = mState.indexOfKeyframe(stateSet); if (keyframeIndex == getCurrentIndex()) { // No transition needed. // Propagate state change to current keyframe. final Drawable current = getCurrent(); if (current != null) { return current.setState(stateSet); } return false; } Loading Loading
core/java/android/widget/Switch.java +18 −0 Original line number Diff line number Diff line Loading @@ -208,7 +208,13 @@ public class Switch extends CompoundButton { final TypedArray a = context.obtainStyledAttributes( attrs, com.android.internal.R.styleable.Switch, defStyleAttr, defStyleRes); mThumbDrawable = a.getDrawable(com.android.internal.R.styleable.Switch_thumb); if (mThumbDrawable != null) { mThumbDrawable.setCallback(this); } mTrackDrawable = a.getDrawable(com.android.internal.R.styleable.Switch_track); if (mTrackDrawable != null) { mTrackDrawable.setCallback(this); } mTextOn = a.getText(com.android.internal.R.styleable.Switch_textOn); mTextOff = a.getText(com.android.internal.R.styleable.Switch_textOff); mShowText = a.getBoolean(com.android.internal.R.styleable.Switch_showText, true); Loading Loading @@ -433,7 +439,13 @@ public class Switch extends CompoundButton { * @attr ref android.R.styleable#Switch_track */ public void setTrackDrawable(Drawable track) { if (mTrackDrawable != null) { mTrackDrawable.setCallback(null); } mTrackDrawable = track; if (track != null) { track.setCallback(this); } requestLayout(); } Loading Loading @@ -468,7 +480,13 @@ public class Switch extends CompoundButton { * @attr ref android.R.styleable#Switch_thumb */ public void setThumbDrawable(Drawable thumb) { if (mThumbDrawable != null) { mThumbDrawable.setCallback(null); } mThumbDrawable = thumb; if (thumb != null) { thumb.setCallback(this); } requestLayout(); } Loading
graphics/java/android/graphics/drawable/AnimatedStateListDrawable.java +7 −2 Original line number Diff line number Diff line Loading @@ -91,7 +91,8 @@ public class AnimatedStateListDrawable extends StateListDrawable { if (visible) { mTransition.start(); } else { mTransition.stop(); // Ensure we're showing the correct state when visible. jumpToCurrentState(); } } Loading Loading @@ -140,7 +141,11 @@ public class AnimatedStateListDrawable extends StateListDrawable { protected boolean onStateChange(int[] stateSet) { final int keyframeIndex = mState.indexOfKeyframe(stateSet); if (keyframeIndex == getCurrentIndex()) { // No transition needed. // Propagate state change to current keyframe. final Drawable current = getCurrent(); if (current != null) { return current.setState(stateSet); } return false; } Loading