Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPAndroidChart: How to cancel fling event?

With MPAndroidChart, how can I stop an ongoing fling event initiated by the user?

Example: User flings the plot backwards, plot keeps scrolling backwards after touching. User presses button "Resume", app calls chart.moveViewToX(dataSet.getEntryCount()), but view is not actually moved until the fling event comes to a complete halt, which can take several seconds.

In other words, I am looking for a solution that executes moveViewToX immediately without waiting for the fling to complete.

like image 791
Torfinn Avatar asked Sep 09 '25 10:09

Torfinn


1 Answers

By dispatching a new ACTION_DOWN event, we can stop the ongoing fling event:

chart.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 0, 0, 0));

Source: Stop ListView scroll animation

like image 197
Torfinn Avatar answered Sep 11 '25 05:09

Torfinn