Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 539802e7 authored by Joe Onorato's avatar Joe Onorato Committed by Android (Google) Code Review
Browse files

Merge "The switch widget didn't work properly until after onMeasure had run." into honeycomb

parents 7866b8a6 c3eabb9b
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -479,9 +479,9 @@ public class Switch extends CompoundButton {
    }

    private void animateThumbToCheckedState(boolean newCheckedState) {
        float targetPos = newCheckedState ? 0 : getThumbScrollRange();
        // TODO animate!
        mThumbPosition = targetPos;
        //float targetPos = newCheckedState ? 0 : getThumbScrollRange();
        //mThumbPosition = targetPos;
        setChecked(newCheckedState);
    }

@@ -493,12 +493,15 @@ public class Switch extends CompoundButton {
    public void setChecked(boolean checked) {
        super.setChecked(checked);
        mThumbPosition = checked ? 0 : getThumbScrollRange();
        invalidate();
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);

        mThumbPosition = isChecked() ? 0 : getThumbScrollRange();

        int switchRight = getWidth() - getPaddingRight();
        int switchLeft = switchRight - mSwitchWidth;
        int switchTop = 0;