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

Commit c3eabb9b authored by Joe Onorato's avatar Joe Onorato
Browse files

The switch widget didn't work properly until after onMeasure had run.

Change-Id: I3259193ca60392ffc133f2ff6479feb8e4ad536e
parent af5473ee
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;