I'm using a ViewPager ( http://developer.android.com/reference/android/support/v4/view/ViewPager.html ) with some images in Fragments, and because I want to support zooming I am extending ViewPager and overriding:
onInterceptTouchEvent
The next step is to determine whether or not the image is zoomed in. If it is zoomed in I'll let it handle the event, otherwise I'll pass the event to super.
My main problem, and the heart of my question, is determining the best and most efficient way to communicate between the current fragment and my ViewPager?
Currently I'm using the following when the current item changes:
Fragment photoFrag = (Fragment) getAdapter().instantiateItem(this, getCurrentItem());
But it feels as though there should probably be a better way to communicate between the Fragment and the ViewPage and I'm missing something.
Edit: Sorry I did forget to mention that I'd like the communication to go back and forth, so I'd like the fragment to be able to communicate with the ViewPager, and the Pager with the fragment. I saw an example (URL left at work) where an Interface class was used to communicate between the current Fragment and the ViewPager. So the underlying image needs to tell the ViewPager when it should handle the Scroll, when it doesn't need to, and when to fake scroll, etc.
I was rushing to get this question up during the Android Hangout
Thanks