@Override public void onAnimationEnd(Animator animation) { chart.setChartRotation((int) targetRotation, false); animationListener.onAnimationFinished(); }
@Override public void onAnimationUpdate(ValueAnimator animation) { float scale = animation.getAnimatedFraction(); float rotation = startRotation + (targetRotation - startRotation) * scale; rotation = (rotation % 360 + 360) % 360; chart.setChartRotation((int) rotation, false); }
@Override public void cancelAnimation() { isAnimationStarted = false; handler.removeCallbacks(runnable); chart.setChartRotation((int) targetRotation, false); animationListener.onAnimationFinished(); }
@Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if (isRotationEnabled) { // Set the pie rotation directly. final RectF circleOval = pieChart.getCircleOval(); final float centerX = circleOval.centerX(); final float centerY = circleOval.centerY(); float scrollTheta = vectorToScalarScroll(distanceX, distanceY, e2.getX() - centerX, e2.getY() - centerY); pieChart.setChartRotation(pieChart.getChartRotation() - (int) scrollTheta / FLING_VELOCITY_DOWNSCALE, false); return true; } return false; }
@Override public boolean computeScroll() { if (!isRotationEnabled) { return false; } if (scroller.computeScrollOffset()) { pieChart.setChartRotation(scroller.getCurrY(), false); // pieChart.setChartRotation() will invalidate view so no need to return true; } return false; }