@Override public boolean onTouchEvent(MotionEvent event){
  Log.i("OLOLO","onTouchEvent");
  if (!isEnabled()) {
    Log.i("OLOLO","is disabled");
    return false;
  }
  int pointerIndex;
  float threshold=1.0f;
  final int action=event.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
    Log.i("OLOLO","MotionEvent.ACTION_DOWN");
  mActivePointerId=event.getPointerId(event.getPointerCount() - 1);
pointerIndex=event.findPointerIndex(mActivePointerId);
mDownMotionX=event.getX(pointerIndex);
mDownMotionY=event.getY(pointerIndex);
mIgnoreMoveGesture=false;
break;
case MotionEvent.ACTION_MOVE:
if (!axisLocked) {
float ratioLeftRight=Math.abs(event.getX() - mDownMotionX) / Math.abs(event.getY() - mDownMotionY);
float ratioUpDown=Math.abs(event.getY() - mDownMotionY) / Math.abs(event.getX() - mDownMotionX);
if (event.getY() < mDownMotionY && ratioUpDown > threshold) {
mIgnoreMoveGesture=true;
axisLocked=true;
return false;
}
 else if (event.getY() > mDownMotionY && ratioUpDown > threshold) {
mIgnoreMoveGesture=true;
axisLocked=true;
return false;
}
 else if (event.getX() < mDownMotionX && ratioLeftRight > threshold) {
mIgnoreMoveGesture=false;
axisLocked=true;
}
 else if (event.getX() > mDownMotionX && ratioLeftRight > threshold) {
mIgnoreMoveGesture=false;
axisLocked=true;
}
 else {
mIgnoreMoveGesture=false;
axisLocked=true;
}
mPressedThumb=evalPressedThumb(mDownMotionX);
if (mPressedThumb == null) {
return super.onTouchEvent(event);
}
invalidate();
onStartTrackingTouch();
trackTouchEvent(event);
attemptClaimDrag();
}
if (mIgnoreMoveGesture) {
Log.i("OLOLO","prev motion NOT down + ignore event");
return false;
}
if (mPressedThumb != null) {
setPressed(true);
if (mIsDragging) {
trackTouchEvent(event);
}
 else {
pointerIndex=event.findPointerIndex(mActivePointerId);
final float x=event.getX(pointerIndex);
if (Math.abs(x - mDownMotionX) > mScaledTouchSlop) {
Log.i("OLOLO","wtf true");
setPressed(true);
invalidate();
onStartTrackingTouch();
trackTouchEvent(event);
attemptClaimDrag();
}
}
if (mNotifyWhileDragging && mListener != null) {
mListener.onRangeSeekBarValuesChanged(this,getSelectedMinValue(),getSelectedMaxValue());
}
}
break;
case MotionEvent.ACTION_UP:
Log.i("OLOLO","MotionEvent.ACTION_UP");
if (mIsDragging) {
trackTouchEvent(event);
setPressed(false);
}
 else {
if (!axisLocked && !mIgnoreMoveGesture) {
mPressedThumb=evalPressedThumb(mDownMotionX);
}
onStartTrackingTouch();
trackTouchEvent(event);
}
axisLocked=false;
mPressedThumb=null;
invalidate();
if (mListener != null) {
mListener.onRangeSeekBarValuesChanged(this,getSelectedMinValue(),getSelectedMaxValue());
}
onStopTrackingTouch();
break;
case MotionEvent.ACTION_POINTER_DOWN:
{
Log.i("OLOLO","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:
Log.i("OLOLO","MotionEvent.ACTION_POINTER_UP");
mPressedThumb=null;
onSecondaryPointerUp(event);
invalidate();
break;
case MotionEvent.ACTION_CANCEL:
axisLocked=false;
Log.i("OLOLO","MotionEvent.ACTION_CANCEL");
mPressedThumb=null;
if (mIsDragging) {
onStopTrackingTouch();
setPressed(false);
}
invalidate();
break;
}
return true;
}

@ Override public boolean onTouchEvent ( MotionEvent event ) { Log . i ( "OLOLO" , "onTouchEvent" ) ; if ( ! isEnabled ( ) ) { Log . i ( "OLOLO" , "is disabled" ) ; return false ; } int pointerIndex ; float threshold = 1.0f ; final int action = event . getAction ( ) ; switch ( action & MotionEvent . ACTION_MASK ) { case MotionEvent . ACTION_DOWN : Log . i ( "OLOLO" , "MotionEvent.ACTION_DOWN" ) ; mActivePointerId = event . getPointerId ( event . getPointerCount ( ) - 1 ) ; pointerIndex = event . findPointerIndex ( mActivePointerId ) ; mDownMotionX = event . getX ( pointerIndex ) ; mDownMotionY = event . getY ( pointerIndex ) ; mIgnoreMoveGesture = false ; break ; case MotionEvent . ACTION_MOVE : if ( ! axisLocked ) { float ratioLeftRight = Math . abs ( event . getX ( ) - mDownMotionX ) / Math . abs ( event . getY ( ) - mDownMotionY ) ; float ratioUpDown = Math . abs ( event . getY ( ) - mDownMotionY ) / Math . abs ( event . getX ( ) - mDownMotionX ) ; if ( event . getY ( ) < mDownMotionY && ratioUpDown > threshold ) { mIgnoreMoveGesture = true ; axisLocked = true ; return false ; } else if ( event . getY ( ) > mDownMotionY && ratioUpDown > threshold ) { mIgnoreMoveGesture = true ; axisLocked = true ; return false ; } else if ( event . getX ( ) < mDownMotionX && ratioLeftRight > threshold ) { mIgnoreMoveGesture = false ; axisLocked = true ; } else if ( event . getX ( ) > mDownMotionX && ratioLeftRight > threshold ) { mIgnoreMoveGesture = false ; axisLocked = true ; } else { mIgnoreMoveGesture = false ; axisLocked = true ; } mPressedThumb = evalPressedThumb ( mDownMotionX ) ; if ( mPressedThumb == null ) { return super . onTouchEvent ( event ) ; } invalidate ( ) ; onStartTrackingTouch ( ) ; trackTouchEvent ( event ) ; attemptClaimDrag ( ) ; } if ( mIgnoreMoveGesture ) { Log . i ( "OLOLO" , "prev motion NOT down + ignore event" ) ; return false ; } if ( mPressedThumb != null ) { setPressed ( true ) ; if ( mIsDragging ) { trackTouchEvent ( event ) ; } else { pointerIndex = event . findPointerIndex ( mActivePointerId ) ; final float x = event . getX ( pointerIndex ) ; if ( Math . abs ( x - mDownMotionX ) > mScaledTouchSlop ) { Log . i ( "OLOLO" , "wtf true" ) ; setPressed ( true ) ; invalidate ( ) ; onStartTrackingTouch ( ) ; trackTouchEvent ( event ) ; attemptClaimDrag ( ) ; } } if ( mNotifyWhileDragging && mListener != null ) { mListener . onRangeSeekBarValuesChanged ( this , getSelectedMinValue ( ) , getSelectedMaxValue ( ) ) ; } } break ; case MotionEvent . ACTION_UP : Log . i ( "OLOLO" , "MotionEvent.ACTION_UP" ) ; if ( mIsDragging ) { trackTouchEvent ( event ) ; setPressed ( false ) ; } else { if ( ! axisLocked && ! mIgnoreMoveGesture ) { mPressedThumb = evalPressedThumb ( mDownMotionX ) ; } onStartTrackingTouch ( ) ; trackTouchEvent ( event ) ; } axisLocked = false ; mPressedThumb = null ; invalidate ( ) ; if ( mListener != null ) { mListener . onRangeSeekBarValuesChanged ( this , getSelectedMinValue ( ) , getSelectedMaxValue ( ) ) ; } onStopTrackingTouch ( ) ; break ; case MotionEvent . ACTION_POINTER_DOWN : { Log . i ( "OLOLO" , "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 : Log . i ( "OLOLO" , "MotionEvent.ACTION_POINTER_UP" ) ; mPressedThumb = null ; onSecondaryPointerUp ( event ) ; invalidate ( ) ; break ; case MotionEvent . ACTION_CANCEL : axisLocked = false ; Log . i ( "OLOLO" , "MotionEvent.ACTION_CANCEL" ) ; mPressedThumb = null ; if ( mIsDragging ) { onStopTrackingTouch ( ) ; setPressed ( false ) ; } invalidate ( ) ; break ; } return true ; }
handles thumb selection and movement . notifies mlistener callback on certain events .
