Extending Gallery

[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 MotionEvents from onInterceptTouchEvent.

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 (mGestureDetector in 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.

About these ads

0 Responses to “Extending Gallery”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





Follow

Get every new post delivered to your Inbox.

%d bloggers like this: