09-17-2010 01:06 AM
I have a GridFieldManager, which has a bunch of BitmapFields inside it. say 100rows resulting in a virtural height of say 3000px.
On the touch device like storm, when I scroll, all the cells/rows in the grid scroll up/down.
When a fast gesture is made the scrolling happens rapidly. I would like to determine when the scrolling is over or ended. Once end of scrolling is detected, I would like to find out the what area of the gridFieldManager is getting shown on the screen.
I have tried setting up a scrollChangeListener.
public void scrollChanged(Manager mgr, int newX, int newY) fn is getting hit till the time the scolling is happening giving me new values of newY. When scrolling happens rapidly, this fn gets called 15-20times. I would like to find out a way when this function is called the last time ?
I did see
but i dont want to do timer thread to keep running all the time when the screen is invoked.
Please do help.
09-20-2010 09:49 AM
The best I could come up with when I faced this problem was to have some countdown process where the counter resets on each scrollChanged(). When it reaches zero, I declare the scrolling stopped and check the scroll position. I decided that 500 ms after the last scrollChanged() was a good enough indication.
Since I already have a repeatedly running TimerTask managing the screen transitions, this was an easy task for me to add. If you don't have anything like that yet you might consider firing a one-time delayed action which is cancelled and rescheduled on each scrollChanged(). Just don't create a new Timer each time - use the same one (maybe pre-create it and have it in some static member) and schedule new TimerTasks whenever they are needed.