Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - combine swipe and pinch-to-zoom

  • We have the Gallery, which support swiping.
  • We also have 3rd-party components that support pinch-to-zoom on ImageView, such as ImageViewTouch in ImageViewZoom.

Now I would like to combine them both.

The problem is that the swipe events get consumed by the ImageViewTouch and missed by the Gallery.

How can consume events by both components?

That would solve my problem, because, eventually, after a few events, each component will know how to react accordingly. For example, if the first event is ACTION_DOWN, it can be part of a pinch-to-zoom or part of a swipe. Both components (Gallery and ImageViewTouch) should consume it in order to know what to do in following events.

like image 918
AlikElzin-kilaka Avatar asked Oct 22 '22 15:10

AlikElzin-kilaka


1 Answers

I combined both components by changing some code in ImageViewZoom. The change was for the events to return a value if they were consumed by the ImageViewTouch. If so, than the event should not be passed to the gallery. If the event is not consumed by the ImageView, than the gallery should consume it (if it can).

There are still some small issues, but it's functional. Hopefully other people in the community can help.

Here's the fork on github: https://github.com/kilaka/ImageViewZoom

Thanks.

like image 137
AlikElzin-kilaka Avatar answered Nov 09 '22 10:11

AlikElzin-kilaka