@Override public boolean onTouchEvent(MotionEvent event){
  if (!isEnabled())   return false;
  int pointerIndex;
  final int action=event.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
    mActivePointerId=event.getPointerId(event.getPointerCount() - 1);
  pointerIndex=event.findPointerIndex(mActivePointerId);
mDownMotionX=event.getX(pointerIndex);
pressedThumb=evalPressedThumb(mDownMotionX);
if (pressedThumb == null) return super.onTouchEvent(event);
setPressed(true);
invalidate();
onStartTrackingTouch();
trackTouchEvent(event);
attemptClaimDrag();
break;
case MotionEvent.ACTION_MOVE:
if (pressedThumb != null) {
if (mIsDragging) {
trackTouchEvent(event);
}
 else {
pointerIndex=event.findPointerIndex(mActivePointerId);
final float x=event.getX(pointerIndex);
if (Math.abs(x - mDownMotionX) > mScaledTouchSlop) {
setPressed(true);
invalidate();
onStartTrackingTouch();
trackTouchEvent(event);
attemptClaimDrag();
}
}
if (notifyWhileDragging && listener != null) {
listener.onRangeSeekBarValuesChanged(this,getSelectedMinValue(),getSelectedMaxValue());
}
}
break;
case MotionEvent.ACTION_UP:
if (mIsDragging) {
trackTouchEvent(event);
onStopTrackingTouch();
setPressed(false);
}
 else {
onStartTrackingTouch();
trackTouchEvent(event);
onStopTrackingTouch();
}
pressedThumb=null;
invalidate();
if (listener != null) {
listener.onRangeSeekBarValuesChanged(this,getSelectedMinValue(),getSelectedMaxValue());
}
break;
case MotionEvent.ACTION_POINTER_DOWN:
{
final int index=event.getPointerCount() - 1;
mDownMotionX=event.getX(index);
mActivePointerId=event.getPointerId(index);
invalidate();
break;
}
case MotionEvent.ACTION_POINTER_UP:
onSecondaryPointerUp(event);
invalidate();
break;
case MotionEvent.ACTION_CANCEL:
if (mIsDragging) {
onStopTrackingTouch();
setPressed(false);
}
invalidate();
break;
}
return true;
}

@ Override public boolean onTouchEvent ( MotionEvent event ) { if ( ! isEnabled ( ) ) return false ; int pointerIndex ; final int action = event . getAction ( ) ; switch ( action & MotionEvent . ACTION_MASK ) { case MotionEvent . ACTION_DOWN : mActivePointerId = event . getPointerId ( event . getPointerCount ( ) - 1 ) ; pointerIndex = event . findPointerIndex ( mActivePointerId ) ; mDownMotionX = event . getX ( pointerIndex ) ; pressedThumb = evalPressedThumb ( mDownMotionX ) ; if ( pressedThumb == null ) return super . onTouchEvent ( event ) ; setPressed ( true ) ; invalidate ( ) ; onStartTrackingTouch ( ) ; trackTouchEvent ( event ) ; attemptClaimDrag ( ) ; break ; case MotionEvent . ACTION_MOVE : if ( pressedThumb != null ) { if ( mIsDragging ) { trackTouchEvent ( event ) ; } else { pointerIndex = event . findPointerIndex ( mActivePointerId ) ; final float x = event . getX ( pointerIndex ) ; if ( Math . abs ( x - mDownMotionX ) > mScaledTouchSlop ) { setPressed ( true ) ; invalidate ( ) ; onStartTrackingTouch ( ) ; trackTouchEvent ( event ) ; attemptClaimDrag ( ) ; } } if ( notifyWhileDragging && listener != null ) { listener . onRangeSeekBarValuesChanged ( this , getSelectedMinValue ( ) , getSelectedMaxValue ( ) ) ; } } break ; case MotionEvent . ACTION_UP : if ( mIsDragging ) { trackTouchEvent ( event ) ; onStopTrackingTouch ( ) ; setPressed ( false ) ; } else { onStartTrackingTouch ( ) ; trackTouchEvent ( event ) ; onStopTrackingTouch ( ) ; } pressedThumb = null ; invalidate ( ) ; if ( listener != null ) { listener . onRangeSeekBarValuesChanged ( this , getSelectedMinValue ( ) , getSelectedMaxValue ( ) ) ; } break ; case MotionEvent . ACTION_POINTER_DOWN : { final int index = event . getPointerCount ( ) - 1 ; mDownMotionX = event . getX ( index ) ; mActivePointerId = event . getPointerId ( index ) ; invalidate ( ) ; break ; } case MotionEvent . ACTION_POINTER_UP : onSecondaryPointerUp ( event ) ; invalidate ( ) ; break ; case MotionEvent . ACTION_CANCEL : if ( mIsDragging ) { onStopTrackingTouch ( ) ; setPressed ( false ) ; } invalidate ( ) ; break ; } return true ; }
handles thumb selection and movement . notifies listener callback on certain events .
