public void setOn(boolean on, boolean animated) { if (this.isOn == on) return; if (!isAttachedToWindow && animated) { dirtyAnimation = true; this.isOn = on; return; } this.isOn = on; knobState = this.isOn; 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 (ShSwitchView.this.onSwitchStateChangeListener != null && isOn != preIsOn) { ShSwitchView.this.onSwitchStateChangeListener.onSwitchStateChange(isOn); } }
@Override public void set(ShSwitchView sv, Float innerContentRate) { sv.setInnerContentRate(innerContentRate); }