JakeWharton/ViewPagerIndicator

CirclePageIndicator fires onPageSelected() too early

Closed this issue · 3 comments

I'm using the CirclePageIndicator together with a FragmentStatePagerAdapter. If I have three pages managed through this adapter and I'm on the last page and send the application into the background and from there back to the foreground, I'm notified that the page selection changed to index 2. This is correct, however, at this time the fragment was not yet instantiated, so I have no way of doing fragment-specific operations, like changing the UI based on the currently active fragment.

Could the root of this problem bei in v4's ViewPager / FragmentStatePagerAdapter?

I figured that there is a call to populate() in http://grepcode.com/file/repo1.maven.org/maven2/com.google.android/support-v4/r7/android/support/v4/view/ViewPager.java#408 before onPageSelected() is fired and that inside populate() the adapter's finishUpdate() method is called that executes all pending fragment transactions immediately, but I wonder why the fragment is still not present. It gets properly re-created, obviously, after the adapter fired.

File on http://b.android.com. ViewPager is part of the support library from Google, not this library.

Well, CirclePageIndicator calls into my code, but it internally depends on ViewPager's onPageSelected. Sorry, I thought that this could be something that could affect / could be fixed in this library's code.