[imagine a picture with a can of worms here]
And now here’s screenshots of Google Plus app and the shiny new Market app:
In both you can swipe left and right to navigate between different views. That’s cool, I want to do that too! Here’s a try.
It’s a subclass of Gallery, and it uses its own instance of
GestureDetector and feeds that gesture detector with
When gesture detector recognizes a scroll, it determines whether it’s horizontal or vertical and locks on the direction until the gesture finishes. This avoids diagonal scrolling.
If it’s a horizontal scroll,
onInterceptTouchEvent will return true so that future motion events go to inherited
Gallery.onTouchEvent to do the actual scrolling.
Gallery’s own gesture detector (
Gallery.java) doesn’t get all motion events and thus sometimes reports huge sudden scrolls that cause gallery to jump around. I’ve put in a a nasty hack that discards those.