private void calcCurrentItem ( ) { int pointerAngle ; // calculate the correct pointer angle, depending on clockwise drawing or not if ( mOpenClockwise ) { pointerAngle = ( mIndicatorAngle + 360 - mPieRotation ) % 360 ; } else { pointerAngle = ( mIndicatorAngle + 180 + mPieRotation ) % 360 ; } for ( int i = 0 ; i < mPieData . size ( ) ; ++ i ) { PieModel model = mPieData . get ( i ) ; if ( model . getStartAngle ( ) <= pointerAngle && pointerAngle <= model . getEndAngle ( ) ) { if ( i != mCurrentItem ) { setCurrentItem ( i , false ) ; } break ; } } }
Calculate which pie slice is under the pointer and set the current item field accordingly .