android-viewflow icon indicating copy to clipboard operation
android-viewflow copied to clipboard

Vertical movements are not consumed

Open jleidgens opened this issue 13 years ago • 3 comments

If I put a viewflow widget inside a scrollview the scrollview will scroll every time a user mixes a horizontal and vertical fling gesture. I tried to figure out how I could intercept those small vertical movements that are meant as a horizontal slide but not exact enough and result in the scrollview taking over the gesture detection, but I couldn't find the correct spot. The standard gallery seems to intercept those scroll gestures because it prevents the scrollview from moving, but the standard gallery does not handle recycling correct and therefore is not usable for larger amounts of images.

jleidgens avatar Sep 12 '11 14:09 jleidgens

Theoretically, I guess you could extend ScrollView and make sure vertical movements are consumed first when you hit a certain threshold value. It has been suggested that android-viewflow provides such wrapper class but unfortunately it doesn't yet.

pakerfeldt avatar Sep 12 '11 15:09 pakerfeldt

I think extending ScrollView is not something I want to do. I don't need it to use a standard android gallery inside a scrollview. I had a look at the Gallery source code and I found the following in the onScroll method of the gallery widget:

    /*
     * Now's a good time to tell our parent to stop intercepting our events!
     * The user has moved more than the slop amount, since GestureDetector
     * ensures this before calling this method. Also, if a parent is more
     * interested in this touch's events than we are, it would have
     * intercepted them by now (for example, we can assume when a Gallery is
     * in the ListView, a vertical scroll would not end up in this method
     * since a ListView would have intercepted it by now).
     */
    mParent.requestDisallowInterceptTouchEvent(true);

I think this line prevents the scrollview from reacting on vertical touch events once the scroll has started. I looked through your code but I couldn't find a good spot to insert this line and test if it works. I would like to improve your gallery to incorporate this feature but I couldn't come up with a good way to retrieve the parent view and I didn't know when a scroll starts and when one scroll ends.

jleidgens avatar Sep 13 '11 07:09 jleidgens

Could you pull the intercepttouch branch and try it out? Not sure I did it right, but requestDisallowInterceptTouchEvent seems like a good solution. https://github.com/pakerfeldt/android-viewflow/tree/intercepttouch

pakerfeldt avatar Sep 13 '11 07:09 pakerfeldt