Skip to content

Commit

Permalink
Check for illegal offset values in ViewPagerAdapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Olifer committed Feb 21, 2018
1 parent 9d129bc commit e1baf34
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ public void onInvalidated() {

@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixel) {
indicator.onPageScrolled(position, positionOffset);
final float offset;
// ViewPager may emit negative positionOffset for very fast scrolling
if (positionOffset < 0) {
offset = 0;
} else if (positionOffset > 1) {
offset = 1;
} else {
offset = positionOffset;
}
indicator.onPageScrolled(position, offset);
}

@Override
Expand Down

0 comments on commit e1baf34

Please sign in to comment.