alibaba / UltraViewPager

UltraViewPager is an extension for ViewPager to provide multiple features in a single ViewPager.
MIT License
5k stars 680 forks source link

position from onPageScrolled is unreliable #146

Closed truthhonestmessaging closed 3 years ago

truthhonestmessaging commented 3 years ago

I am trying to get the position of viewPager by onPageScrolled method of OnPageChangeListener instead of using onPageSelected because than I can update which view is selected more frequently.

however, the position from onPageScrolled method is unreliable. Sometimes it is incorrect - doesn't update to the new position. It is kind of random but happens so often. I literally just set a textview to display position of ultraPager, and it often does not update correctly. position retrieved from onPageSelected method seems to work reliably though.

This is a bug report. I am using Ultra View Pager to center select the view horizontally.

truthhonestmessaging commented 3 years ago

Oh this is actually an easy fix. If positionOffset is close to 1 like it would be 0.99876 then I can manually increment the position that is returned from the method. I do if positionOffset > 0.5, realPosition = position + 1

This is trivial.