public void setOn(boolean on, boolean animated) { if (this.mIsChecked == on) return; if (!isAttachedToWindow && animated) { dirtyAnimation = true; this.mIsChecked = on; return; } this.mIsChecked = on; knobState = this.mIsChecked; if (!animated) { if (on) { setKnobMoveRate(1.0F); setInnerContentRate(0.0F); } else { setKnobMoveRate(0.0F); setInnerContentRate(1.0F); } setKnobExpandRate(0.0F); } else { if (knobState) { knobMoveAnimator.setFloatValues(knobMoveRate, 1.0F); knobMoveAnimator.start(); innerContentAnimator.setFloatValues(innerContentRate, 0.0F); innerContentAnimator.start(); } else { knobMoveAnimator.setFloatValues(knobMoveRate, 0.0F); knobMoveAnimator.start(); innerContentAnimator.setFloatValues(innerContentRate, 1.0F); innerContentAnimator.start(); } knobExpandAnimator.setFloatValues(knobExpandRate, 0.0F); knobExpandAnimator.start(); } if (onSwitchStateChangeListener != null && mIsChecked != preIsOn) { onSwitchStateChangeListener.onSwitchStateChange(mIsChecked); } }
@Override public void set(AnSwitch sv, Float innerContentRate) { sv.setInnerContentRate(innerContentRate); }