Skip to content

Commit

Permalink
Useless checks was removed. Division by zero fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Olifer committed Feb 14, 2018
1 parent 75cd3cc commit 0948f34
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
int newPosition = findCompletelyVisiblePosition();
if (newPosition != RecyclerView.NO_POSITION) {
indicator.setDotCount(adapter.getItemCount());
if (newPosition >= 0 && newPosition < adapter.getItemCount()) {
if (newPosition < adapter.getItemCount()) {
indicator.setCurrentPosition(newPosition);
}
}
Expand Down Expand Up @@ -126,15 +126,16 @@ private void updateCurrentOffset() {
if (position == RecyclerView.NO_POSITION) {
return;
}
final int itemCount = adapter.getItemCount();

// In case there is an infinite pager
if (position >= adapter.getItemCount()) {
position = position % adapter.getItemCount();
if (position >= itemCount && itemCount != 0) {
position = position % itemCount;
}

final float offset = (getCurrentFrameLeft() - leftView.getX()) / leftView.getMeasuredWidth();

if (offset >= 0 && offset <= 1 && position != RecyclerView.NO_POSITION && position < adapter.getItemCount()) {
if (offset >= 0 && offset <= 1 && position < itemCount) {
indicator.onPageScrolled(position, offset);
}
}
Expand Down

0 comments on commit 0948f34

Please sign in to comment.