Open shayanpourvatan opened 8 years ago
better way is adding following part to scrollTo
:
if (position >= mRecyclerView.getAdapter().getItemCount()) {
position = mRecyclerView.getAdapter().getItemCount() - 1;
}
so result will be :
@Override
public void scrollTo(float scrollProgress, boolean fromTouch) {
int position = getPositionFromScrollProgress(scrollProgress);
if (position >= mRecyclerView.getAdapter().getItemCount()) {
position = mRecyclerView.getAdapter().getItemCount() - 1;
}
mRecyclerView.scrollToPosition(position);
updateSectionIndicator(position, scrollProgress);
}
or changing getPositionFromScrollProgress
to :
private int getPositionFromScrollProgress(float scrollProgress) {
return (int) ((mRecyclerView.getAdapter().getItemCount() - 1) * scrollProgress);
}
( add (-1) to calculation ). I don't know witch one is better but all of them fixed my problem
i've got an indexOutOfBound in AbsRecyclerViewFastScroller$override.updateSectionIndicator, after tracing your code, i've seen position that came to the
updateSectionIndicator
is bigger than size of my list, i've add following part of code :so
updateSectionIndicator
will be :error fixed with this code, please fix this in next update. thanks for your great library.