Skip to content
This repository has been archived by the owner on Aug 24, 2023. It is now read-only.

Commit

Permalink
FastScrollRecyclerView: Prevent division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
jahirfiquitiva authored and AkaneTan committed Jul 31, 2023
1 parent d7c2fbd commit 1b0aa69
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,9 @@ public String scrollToPositionAtProgress(float touchFraction) {
//The offset used here is kind of hard to explain.
//If the position we wish to scroll to is, say, position 10.5, we scroll to position 10,
//and then offset by 0.5 * rowHeight. This is how we achieve smooth scrolling.
scrollPosition = spanCount * exactItemPos / mScrollPosState.rowHeight;
scrollOffset = -(exactItemPos % mScrollPosState.rowHeight);
int rowHeight = mScrollPosState.rowHeight > 0 ? mScrollPosState.rowHeight : 1;
scrollPosition = spanCount * exactItemPos / rowHeight;
scrollOffset = -(exactItemPos % rowHeight);
}

LinearLayoutManager layoutManager = ((LinearLayoutManager) getLayoutManager());
Expand Down

0 comments on commit 1b0aa69

Please sign in to comment.