Java Code Examples for com.github.mikephil.charting.utils.Utils#postInvalidateOnAnimation()
The following examples show how to use
com.github.mikephil.charting.utils.Utils#postInvalidateOnAnimation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BarLineChartTouchListener.java From NetKnight with Apache License 2.0 | 5 votes |
public void computeScroll() { if (mDecelerationVelocity.x == 0.f && mDecelerationVelocity.y == 0.f) return; // There's no deceleration in progress final long currentTime = AnimationUtils.currentAnimationTimeMillis(); mDecelerationVelocity.x *= mChart.getDragDecelerationFrictionCoef(); mDecelerationVelocity.y *= mChart.getDragDecelerationFrictionCoef(); final float timeInterval = (float) (currentTime - mDecelerationLastTime) / 1000.f; float distanceX = mDecelerationVelocity.x * timeInterval; float distanceY = mDecelerationVelocity.y * timeInterval; mDecelerationCurrentPoint.x += distanceX; mDecelerationCurrentPoint.y += distanceY; MotionEvent event = MotionEvent.obtain(currentTime, currentTime, MotionEvent.ACTION_MOVE, mDecelerationCurrentPoint.x, mDecelerationCurrentPoint.y, 0); performDrag(event); event.recycle(); mMatrix = mChart.getViewPortHandler().refresh(mMatrix, mChart, false); mDecelerationLastTime = currentTime; if (Math.abs(mDecelerationVelocity.x) >= 0.01 || Math.abs(mDecelerationVelocity.y) >= 0.01) Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google else { // Range might have changed, which means that Y-axis labels // could have changed in size, affecting Y-axis size. // So we need to recalculate offsets. mChart.calculateOffsets(); mChart.postInvalidate(); stopDeceleration(); } }
Example 2
Source File: BarLineChartTouchListener.java From android-kline with Apache License 2.0 | 5 votes |
public void computeScroll() { if (mDecelerationVelocity.x == 0.f && mDecelerationVelocity.y == 0.f) return; // There's no deceleration in progress final long currentTime = AnimationUtils.currentAnimationTimeMillis(); mDecelerationVelocity.x *= mChart.getDragDecelerationFrictionCoef(); mDecelerationVelocity.y *= mChart.getDragDecelerationFrictionCoef(); final float timeInterval = (float) (currentTime - mDecelerationLastTime) / 1000.f; float distanceX = mDecelerationVelocity.x * timeInterval; float distanceY = mDecelerationVelocity.y * timeInterval; mDecelerationCurrentPoint.x += distanceX; mDecelerationCurrentPoint.y += distanceY; MotionEvent event = MotionEvent.obtain(currentTime, currentTime, MotionEvent.ACTION_MOVE, mDecelerationCurrentPoint.x, mDecelerationCurrentPoint.y, 0); performDrag(event); event.recycle(); mMatrix = mChart.getViewPortHandler().refresh(mMatrix, mChart, false); mDecelerationLastTime = currentTime; if (Math.abs(mDecelerationVelocity.x) >= 0.01 || Math.abs(mDecelerationVelocity.y) >= 0.01) Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google else { // Range might have changed, which means that Y-axis labels // could have changed in size, affecting Y-axis size. // So we need to recalculate offsets. mChart.calculateOffsets(); mChart.postInvalidate(); stopDeceleration(); } }
Example 3
Source File: BarLineChartTouchListener.java From Stayfit with Apache License 2.0 | 5 votes |
public void computeScroll() { if (mDecelerationVelocity.x == 0.f && mDecelerationVelocity.y == 0.f) return; // There's no deceleration in progress final long currentTime = AnimationUtils.currentAnimationTimeMillis(); mDecelerationVelocity.x *= mChart.getDragDecelerationFrictionCoef(); mDecelerationVelocity.y *= mChart.getDragDecelerationFrictionCoef(); final float timeInterval = (float)(currentTime - mDecelerationLastTime) / 1000.f; float distanceX = mDecelerationVelocity.x * timeInterval; float distanceY = mDecelerationVelocity.y * timeInterval; mDecelerationCurrentPoint.x += distanceX; mDecelerationCurrentPoint.y += distanceY; MotionEvent event = MotionEvent.obtain(currentTime, currentTime, MotionEvent.ACTION_MOVE, mDecelerationCurrentPoint.x, mDecelerationCurrentPoint.y, 0); performDrag(event); event.recycle(); mMatrix = mChart.getViewPortHandler().refresh(mMatrix, mChart, false); mDecelerationLastTime = currentTime; if (Math.abs(mDecelerationVelocity.x) >= 0.01 || Math.abs(mDecelerationVelocity.y) >= 0.01) Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google else { // Range might have changed, which means that Y-axis labels // could have changed in size, affecting Y-axis size. // So we need to recalculate offsets. mChart.calculateOffsets(); mChart.postInvalidate(); stopDeceleration(); } }
Example 4
Source File: BarLineChartTouchListener.java From iMoney with Apache License 2.0 | 5 votes |
public void computeScroll() { if (mDecelerationVelocity.x == 0.f && mDecelerationVelocity.y == 0.f) return; // There's no deceleration in progress final long currentTime = AnimationUtils.currentAnimationTimeMillis(); mDecelerationVelocity.x *= mChart.getDragDecelerationFrictionCoef(); mDecelerationVelocity.y *= mChart.getDragDecelerationFrictionCoef(); final float timeInterval = (float)(currentTime - mDecelerationLastTime) / 1000.f; float distanceX = mDecelerationVelocity.x * timeInterval; float distanceY = mDecelerationVelocity.y * timeInterval; mDecelerationCurrentPoint.x += distanceX; mDecelerationCurrentPoint.y += distanceY; MotionEvent event = MotionEvent.obtain(currentTime, currentTime, MotionEvent.ACTION_MOVE, mDecelerationCurrentPoint.x, mDecelerationCurrentPoint.y, 0); performDrag(event); event.recycle(); mMatrix = mChart.getViewPortHandler().refresh(mMatrix, mChart, false); mDecelerationLastTime = currentTime; if (Math.abs(mDecelerationVelocity.x) >= 0.01 || Math.abs(mDecelerationVelocity.y) >= 0.01) Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google else { // Range might have changed, which means that Y-axis labels // could have changed in size, affecting Y-axis size. // So we need to recalculate offsets. mChart.calculateOffsets(); mChart.postInvalidate(); stopDeceleration(); } }
Example 5
Source File: PieRadarChartTouchListener.java From NetKnight with Apache License 2.0 | 4 votes |
public void computeScroll() { if (mDecelerationAngularVelocity == 0.f) return; // There's no deceleration in progress final long currentTime = AnimationUtils.currentAnimationTimeMillis(); mDecelerationAngularVelocity *= mChart.getDragDecelerationFrictionCoef(); final float timeInterval = (float) (currentTime - mDecelerationLastTime) / 1000.f; mChart.setRotationAngle(mChart.getRotationAngle() + mDecelerationAngularVelocity * timeInterval); mDecelerationLastTime = currentTime; if (Math.abs(mDecelerationAngularVelocity) >= 0.001) Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google else stopDeceleration(); }
Example 6
Source File: BarLineChartTouchListener.java From StockChart-MPAndroidChart with MIT License | 4 votes |
public void computeScroll() { if (mDecelerationVelocity.x == 0.f && mDecelerationVelocity.y == 0.f) { return; // There's no deceleration in progress } final long currentTime = AnimationUtils.currentAnimationTimeMillis(); mDecelerationVelocity.x *= mChart.getDragDecelerationFrictionCoef(); mDecelerationVelocity.y *= mChart.getDragDecelerationFrictionCoef(); final float timeInterval = (float) (currentTime - mDecelerationLastTime) / 1000.f; float distanceX = mDecelerationVelocity.x * timeInterval; float distanceY = mDecelerationVelocity.y * timeInterval; mDecelerationCurrentPoint.x += distanceX; mDecelerationCurrentPoint.y += distanceY; MotionEvent event = MotionEvent.obtain(currentTime, currentTime, MotionEvent.ACTION_MOVE, mDecelerationCurrentPoint.x, mDecelerationCurrentPoint.y, 0); float dragDistanceX = mChart.isDragXEnabled() ? mDecelerationCurrentPoint.x - mTouchStartPoint.x : 0.f; float dragDistanceY = mChart.isDragYEnabled() ? mDecelerationCurrentPoint.y - mTouchStartPoint.y : 0.f; performDrag(event, dragDistanceX, dragDistanceY); event.recycle(); mMatrix = mChart.getViewPortHandler().refresh(mMatrix, mChart, false); mDecelerationLastTime = currentTime; if (Math.abs(mDecelerationVelocity.x) >= 0.01 || Math.abs(mDecelerationVelocity.y) >= 0.01) { Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google } else { // Range might have changed, which means that Y-axis labels // could have changed in size, affecting Y-axis size. // So we need to recalculate offsets. mChart.calculateOffsets(); mChart.postInvalidate(); stopDeceleration(); } }
Example 7
Source File: PieRadarChartTouchListener.java From NetKnight with Apache License 2.0 | 4 votes |
@SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { if (mGestureDetector.onTouchEvent(event)) return true; // if rotation by touch is enabled if (mChart.isRotationEnabled()) { float x = event.getX(); float y = event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: startAction(event); stopDeceleration(); resetVelocity(); if (mChart.isDragDecelerationEnabled()) sampleVelocity(x, y); setGestureStartAngle(x, y); mTouchStartPoint.x = x; mTouchStartPoint.y = y; break; case MotionEvent.ACTION_MOVE: if (mChart.isDragDecelerationEnabled()) sampleVelocity(x, y); if (mTouchMode == NONE && distance(x, mTouchStartPoint.x, y, mTouchStartPoint.y) > Utils.convertDpToPixel(8f)) { mLastGesture = ChartGesture.ROTATE; mTouchMode = ROTATE; mChart.disableScroll(); } else if (mTouchMode == ROTATE) { updateGestureRotation(x, y); mChart.invalidate(); } endAction(event); break; case MotionEvent.ACTION_UP: if (mChart.isDragDecelerationEnabled()) { stopDeceleration(); sampleVelocity(x, y); mDecelerationAngularVelocity = calculateVelocity(); if (mDecelerationAngularVelocity != 0.f) { mDecelerationLastTime = AnimationUtils.currentAnimationTimeMillis(); Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google } } mChart.enableScroll(); mTouchMode = NONE; endAction(event); break; } } return true; }
Example 8
Source File: PieRadarChartTouchListener.java From Stayfit with Apache License 2.0 | 4 votes |
public void computeScroll() { if (mDecelerationAngularVelocity == 0.f) return; // There's no deceleration in progress final long currentTime = AnimationUtils.currentAnimationTimeMillis(); mDecelerationAngularVelocity *= mChart.getDragDecelerationFrictionCoef(); final float timeInterval = (float) (currentTime - mDecelerationLastTime) / 1000.f; mChart.setRotationAngle(mChart.getRotationAngle() + mDecelerationAngularVelocity * timeInterval); mDecelerationLastTime = currentTime; if (Math.abs(mDecelerationAngularVelocity) >= 0.001) Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google else stopDeceleration(); }
Example 9
Source File: PieRadarChartTouchListener.java From Stayfit with Apache License 2.0 | 4 votes |
@SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { if (mGestureDetector.onTouchEvent(event)) return true; // if rotation by touch is enabled if (mChart.isRotationEnabled()) { float x = event.getX(); float y = event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: startAction(event); stopDeceleration(); resetVelocity(); if (mChart.isDragDecelerationEnabled()) sampleVelocity(x, y); setGestureStartAngle(x, y); mTouchStartPoint.x = x; mTouchStartPoint.y = y; break; case MotionEvent.ACTION_MOVE: if (mChart.isDragDecelerationEnabled()) sampleVelocity(x, y); if (mTouchMode == NONE && distance(x, mTouchStartPoint.x, y, mTouchStartPoint.y) > Utils.convertDpToPixel(8f)) { mLastGesture = ChartGesture.ROTATE; mTouchMode = ROTATE; mChart.disableScroll(); } else if (mTouchMode == ROTATE) { updateGestureRotation(x, y); mChart.invalidate(); } endAction(event); break; case MotionEvent.ACTION_UP: if (mChart.isDragDecelerationEnabled()) { stopDeceleration(); sampleVelocity(x, y); mDecelerationAngularVelocity = calculateVelocity(); if (mDecelerationAngularVelocity != 0.f) { mDecelerationLastTime = AnimationUtils.currentAnimationTimeMillis(); Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google } } mChart.enableScroll(); mTouchMode = NONE; endAction(event); break; } } return true; }
Example 10
Source File: PieRadarChartTouchListener.java From iMoney with Apache License 2.0 | 4 votes |
public void computeScroll() { if (mDecelerationAngularVelocity == 0.f) return; // There's no deceleration in progress final long currentTime = AnimationUtils.currentAnimationTimeMillis(); mDecelerationAngularVelocity *= mChart.getDragDecelerationFrictionCoef(); final float timeInterval = (float)(currentTime - mDecelerationLastTime) / 1000.f; mChart.setRotationAngle(mChart.getRotationAngle() + mDecelerationAngularVelocity * timeInterval); mDecelerationLastTime = currentTime; if (Math.abs(mDecelerationAngularVelocity) >= 0.001) Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google else stopDeceleration(); }
Example 11
Source File: PieRadarChartTouchListener.java From iMoney with Apache License 2.0 | 4 votes |
@SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { if (mGestureDetector.onTouchEvent(event)) return true; // if rotation by touch is enabled if (mChart.isRotationEnabled()) { float x = event.getX(); float y = event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: stopDeceleration(); resetVelocity(); if (mChart.isDragDecelerationEnabled()) sampleVelocity(x, y); setGestureStartAngle(x, y); mTouchStartPoint.x = x; mTouchStartPoint.y = y; break; case MotionEvent.ACTION_MOVE: if (mChart.isDragDecelerationEnabled()) sampleVelocity(x, y); if (mTouchMode == NONE && distance(x, mTouchStartPoint.x, y, mTouchStartPoint.y) > Utils.convertDpToPixel(8f)) { mTouchMode = ROTATE; mChart.disableScroll(); } else if (mTouchMode == ROTATE) { updateGestureRotation(x, y); mChart.invalidate(); } break; case MotionEvent.ACTION_UP: if (mChart.isDragDecelerationEnabled()) { stopDeceleration(); sampleVelocity(x, y); mDecelerationAngularVelocity = calculateVelocity(); if (mDecelerationAngularVelocity != 0.f) { mDecelerationLastTime = AnimationUtils.currentAnimationTimeMillis(); Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google } } mChart.enableScroll(); mTouchMode = NONE; break; } } return true; }
Example 12
Source File: PieRadarChartTouchListener.java From android-kline with Apache License 2.0 | 4 votes |
public void computeScroll() { if (mDecelerationAngularVelocity == 0.f) return; // There's no deceleration in progress final long currentTime = AnimationUtils.currentAnimationTimeMillis(); mDecelerationAngularVelocity *= mChart.getDragDecelerationFrictionCoef(); final float timeInterval = (float) (currentTime - mDecelerationLastTime) / 1000.f; mChart.setRotationAngle(mChart.getRotationAngle() + mDecelerationAngularVelocity * timeInterval); mDecelerationLastTime = currentTime; if (Math.abs(mDecelerationAngularVelocity) >= 0.001) Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google else stopDeceleration(); }
Example 13
Source File: PieRadarChartTouchListener.java From android-kline with Apache License 2.0 | 4 votes |
@SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { if (mGestureDetector.onTouchEvent(event)) return true; // if rotation by touch is enabled if (mChart.isRotationEnabled()) { float x = event.getX(); float y = event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: startAction(event); stopDeceleration(); resetVelocity(); if (mChart.isDragDecelerationEnabled()) sampleVelocity(x, y); setGestureStartAngle(x, y); mTouchStartPoint.x = x; mTouchStartPoint.y = y; break; case MotionEvent.ACTION_MOVE: if (mChart.isDragDecelerationEnabled()) sampleVelocity(x, y); if (mTouchMode == NONE && distance(x, mTouchStartPoint.x, y, mTouchStartPoint.y) > Utils.convertDpToPixel(8f)) { mLastGesture = ChartGesture.ROTATE; mTouchMode = ROTATE; mChart.disableScroll(); } else if (mTouchMode == ROTATE) { updateGestureRotation(x, y); mChart.invalidate(); } endAction(event); break; case MotionEvent.ACTION_UP: if (mChart.isDragDecelerationEnabled()) { stopDeceleration(); sampleVelocity(x, y); mDecelerationAngularVelocity = calculateVelocity(); if (mDecelerationAngularVelocity != 0.f) { mDecelerationLastTime = AnimationUtils.currentAnimationTimeMillis(); Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google } } mChart.enableScroll(); mTouchMode = NONE; endAction(event); break; } } return true; }
Example 14
Source File: PieRadarChartTouchListener.java From Ticket-Analysis with MIT License | 4 votes |
public void computeScroll() { if (mDecelerationAngularVelocity == 0.f) return; // There's no deceleration in progress final long currentTime = AnimationUtils.currentAnimationTimeMillis(); mDecelerationAngularVelocity *= mChart.getDragDecelerationFrictionCoef(); final float timeInterval = (float) (currentTime - mDecelerationLastTime) / 1000.f; mChart.setRotationAngle(mChart.getRotationAngle() + mDecelerationAngularVelocity * timeInterval); mDecelerationLastTime = currentTime; if (Math.abs(mDecelerationAngularVelocity) >= 0.001) Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google else stopDeceleration(); }
Example 15
Source File: PieRadarChartTouchListener.java From Ticket-Analysis with MIT License | 4 votes |
@SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { if (mGestureDetector.onTouchEvent(event)) return true; // if rotation by touch is enabled if (mChart.isRotationEnabled()) { float x = event.getX(); float y = event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: startAction(event); stopDeceleration(); resetVelocity(); if (mChart.isDragDecelerationEnabled()) sampleVelocity(x, y); setGestureStartAngle(x, y); mTouchStartPoint.x = x; mTouchStartPoint.y = y; break; case MotionEvent.ACTION_MOVE: if (mChart.isDragDecelerationEnabled()) sampleVelocity(x, y); if (mTouchMode == NONE && distance(x, mTouchStartPoint.x, y, mTouchStartPoint.y) > Utils.convertDpToPixel(8f)) { mLastGesture = ChartGesture.ROTATE; mTouchMode = ROTATE; mChart.disableScroll(); } else if (mTouchMode == ROTATE) { updateGestureRotation(x, y); mChart.invalidate(); } endAction(event); break; case MotionEvent.ACTION_UP: if (mChart.isDragDecelerationEnabled()) { stopDeceleration(); sampleVelocity(x, y); mDecelerationAngularVelocity = calculateVelocity(); if (mDecelerationAngularVelocity != 0.f) { mDecelerationLastTime = AnimationUtils.currentAnimationTimeMillis(); Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google } } mChart.enableScroll(); mTouchMode = NONE; endAction(event); break; } } return true; }
Example 16
Source File: BarLineChartTouchListener.java From Ticket-Analysis with MIT License | 4 votes |
public void computeScroll() { if (mDecelerationVelocity.x == 0.f && mDecelerationVelocity.y == 0.f) return; // There's no deceleration in progress final long currentTime = AnimationUtils.currentAnimationTimeMillis(); mDecelerationVelocity.x *= mChart.getDragDecelerationFrictionCoef(); mDecelerationVelocity.y *= mChart.getDragDecelerationFrictionCoef(); final float timeInterval = (float) (currentTime - mDecelerationLastTime) / 1000.f; float distanceX = mDecelerationVelocity.x * timeInterval; float distanceY = mDecelerationVelocity.y * timeInterval; mDecelerationCurrentPoint.x += distanceX; mDecelerationCurrentPoint.y += distanceY; MotionEvent event = MotionEvent.obtain(currentTime, currentTime, MotionEvent.ACTION_MOVE, mDecelerationCurrentPoint.x, mDecelerationCurrentPoint.y, 0); float dragDistanceX = mChart.isDragXEnabled() ? mDecelerationCurrentPoint.x - mTouchStartPoint.x : 0.f; float dragDistanceY = mChart.isDragYEnabled() ? mDecelerationCurrentPoint.y - mTouchStartPoint.y : 0.f; performDrag(event, dragDistanceX, dragDistanceY); event.recycle(); mMatrix = mChart.getViewPortHandler().refresh(mMatrix, mChart, false); mDecelerationLastTime = currentTime; if (Math.abs(mDecelerationVelocity.x) >= 0.01 || Math.abs(mDecelerationVelocity.y) >= 0.01) Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google else { // Range might have changed, which means that Y-axis labels // could have changed in size, affecting Y-axis size. // So we need to recalculate offsets. mChart.calculateOffsets(); mChart.postInvalidate(); stopDeceleration(); } }
Example 17
Source File: PieRadarChartTouchListener.java From StockChart-MPAndroidChart with MIT License | 4 votes |
public void computeScroll() { if (mDecelerationAngularVelocity == 0.f) { return; // There's no deceleration in progress } final long currentTime = AnimationUtils.currentAnimationTimeMillis(); mDecelerationAngularVelocity *= mChart.getDragDecelerationFrictionCoef(); final float timeInterval = (float) (currentTime - mDecelerationLastTime) / 1000.f; mChart.setRotationAngle(mChart.getRotationAngle() + mDecelerationAngularVelocity * timeInterval); mDecelerationLastTime = currentTime; if (Math.abs(mDecelerationAngularVelocity) >= 0.001) { Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google } else { stopDeceleration(); } }
Example 18
Source File: PieRadarChartTouchListener.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { if (mGestureDetector.onTouchEvent(event)) { return true; } // if rotation by touch is enabled if (mChart.isRotationEnabled()) { float x = event.getX(); float y = event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: startAction(event); stopDeceleration(); resetVelocity(); if (mChart.isDragDecelerationEnabled()) { sampleVelocity(x, y); } setGestureStartAngle(x, y); mTouchStartPoint.x = x; mTouchStartPoint.y = y; break; case MotionEvent.ACTION_MOVE: if (mChart.isDragDecelerationEnabled()) { sampleVelocity(x, y); } if (mTouchMode == NONE && distance(x, mTouchStartPoint.x, y, mTouchStartPoint.y) > Utils.convertDpToPixel(8f)) { mLastGesture = ChartGesture.ROTATE; mTouchMode = ROTATE; mChart.disableScroll(); } else if (mTouchMode == ROTATE) { updateGestureRotation(x, y); mChart.invalidate(); } endAction(event); break; case MotionEvent.ACTION_UP: if (mChart.isDragDecelerationEnabled()) { stopDeceleration(); sampleVelocity(x, y); mDecelerationAngularVelocity = calculateVelocity(); if (mDecelerationAngularVelocity != 0.f) { mDecelerationLastTime = AnimationUtils.currentAnimationTimeMillis(); Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google } } mChart.enableScroll(); mTouchMode = NONE; endAction(event); break; } } return true; }