@ Override protected void onDataChanged ( ) { super . onDataChanged ( ) ; int currentAngle = 0 ; int index = 0 ; int size = mPieData . size ( ) ; for ( PieModel model : mPieData ) { int endAngle = ( int ) ( currentAngle + model . getValue ( ) * 360.f / mTotalValue ) ; if ( index == size - 1 ) { endAngle = 360 ; } model . setStartAngle ( currentAngle ) ; model . setEndAngle ( endAngle ) ; currentAngle = model . getEndAngle ( ) ; index ++ ; } calcCurrentItem ( ) ; onScrollFinished ( ) ; }
Should be called after new data is inserted . Will be automatically called when the view dimensions has changed .