Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android View Pager flings the wrong way

I have found an interesting bug in the android view-pager (r4 of the ACL).

The velocity tracker will fling the view-pager the wrong way when scrolling your finger too fast/off the edge of the screen on older or slow devices.

I can reproduce on original Galaxy Tab, HTC Desire, Nexus One, San Francisco, HTC Hero.

Open up Google +, market, or something with a fairly substational view pager implementation.

If you go to far left page, then gently pull your finger over the right edge of the screen you can get the view-pager to jump to the right (the opposite way to the drag direction).

I need to investigate more but this looks like the velocity tracker can't keep up on slower devices. This can of course make the view pager jump around when quickly scrolling left to right. try on the new market (3.3+) to go from one side to the other and see the annoying results!

Any ideas on fixes by extending the class.. Im thinking that the screen may be providing odd results when alot is going on and maybe missing some MotionEvents, as I have found it nearly impossible to replicat on newer devices. (Nexus S, Samsung GSII, Sensation).

EDIT: This problem has been resolved as of ACL v6

Thanks, Chris

like image 918
Chris.Jenkins Avatar asked Nov 03 '11 14:11

Chris.Jenkins


1 Answers

I think the version of ViewPager that went out with r4 had some issues like this that have since been fixed. The next release should be coming soon. This is a behavior that we will likely refine over time in addition to the upcoming fixes.

If you're curious and would like to edit the source included with the support library package, I believe the fix was to start passing MotionEvents to the VelocityTracker during onInterceptTouchEvent from the initial down event rather than only after the intercept occurred in onTouchEvent. This gives the VelocityTracker more data to work with. Alternatively you could experiment with other triggers.

like image 69
adamp Avatar answered Oct 23 '22 06:10

adamp