private void updateSliderState ( int touchX , int touchY ) { int distanceX = touchX - mCircleCenterX ; int distanceY = mCircleCenterY - touchY ; //noinspection SuspiciousNameCombination double c = Math . sqrt ( Math . pow ( distanceX , 2 ) + Math . pow ( distanceY , 2 ) ) ; mAngle = Math . acos ( distanceX / c ) ; if ( distanceY < 0 ) { mAngle = - mAngle ; } if ( mListener != null ) { // notify slider moved listener of the new position which should be in [0..1] range mListener . onSliderMoved ( ( mAngle - mStartAngle ) / ( 2 * Math . PI ) ) ; } }
Invoked when slider starts moving or is currently moving . This method calculates and sets position and angle of the thumb .