Relationship between the ViewPager and the current fragment
I am using ViewPager ( http://developer.android.com/reference/android/support/v4/view/ViewPager.html ) with some images in Fragments, but because I want to support scaling, I extend ViewPager and override:
The next step is to determine if the image will be enlarged. If it's zoomed in, I'll let it handle the event, otherwise I'll pass the super event.
My main problem and the gist of my question is to determine the best and most efficient way to communicate between the current fragment and my ViewPager?
I am currently using the following when changing the current element:
Fragment photoFrag = (Fragment) getAdapter().instantiateItem(this, getCurrentItem());
But it seems like there should probably be a better way of communicating between Fragment and ViewPage, and I'm missing something.
Edit : Sorry, I forgot to mention that I would like the message to be included back and forth, so I would like the Fragment to be able to communicate with the ViewPager and the Fragment Pager. I saw an example (URL stayed at work) where an interface class was used to communicate between the current snippet and the ViewPager. So the base image should tell the ViewPager when it should handle scrolling, when it's not needed, and when fake scrolls, etc.
I was in a rush to get this question during an Android hangout
source to share