private void stopDrag(MotionEvent ev){
  mTouchMode=TOUCH_MODE_IDLE;
  final boolean commitChange=ev.getAction() == MotionEvent.ACTION_UP && isEnabled();
  final boolean oldState=isChecked();
  final boolean newState;
  if (commitChange) {
    mVelocityTracker.computeCurrentVelocity(1000);
    final float xvel=mVelocityTracker.getXVelocity();
    if (Math.abs(xvel) > mMinFlingVelocity) {
      newState=ViewUtils.isLayoutRtl(this) ? (xvel < 0) : (xvel > 0);
    }
 else {
      newState=getTargetCheckedState();
    }
  }
 else {
    newState=oldState;
  }
  if (newState != oldState) {
    playSoundEffect(SoundEffectConstants.CLICK);
  }
  setChecked(newState);
  cancelSuperTouch(ev);
}

private void stopDrag ( MotionEvent ev ) { mTouchMode = TOUCH_MODE_IDLE ; final boolean commitChange = ev . getAction ( ) == MotionEvent . ACTION_UP && isEnabled ( ) ; final boolean oldState = isChecked ( ) ; final boolean newState ; if ( commitChange ) { mVelocityTracker . computeCurrentVelocity ( 1000 ) ; final float xvel = mVelocityTracker . getXVelocity ( ) ; if ( Math . abs ( xvel ) > mMinFlingVelocity ) { newState = ViewUtils . isLayoutRtl ( this ) ? ( xvel < 0 ) : ( xvel > 0 ) ; } else { newState = getTargetCheckedState ( ) ; } } else { newState = oldState ; } if ( newState != oldState ) { playSoundEffect ( SoundEffectConstants . CLICK ) ; } setChecked ( newState ) ; cancelSuperTouch ( ev ) ; }
called from ontouchevent to end a drag operation .
