From 57aeb43a5f7fcfb50d7d0d337a1b14faf6cb9198 Mon Sep 17 00:00:00 2001 From: Bruce McLean Date: Fri, 3 Jun 2016 11:03:17 -0400 Subject: [PATCH 1/3] Fix issue with scrolling to end. --- .../AbsRecyclerViewFastScroller.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java b/recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java index 5b88dfc..fff1241 100644 --- a/recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java +++ b/recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java @@ -167,8 +167,13 @@ private void updateSectionIndicator(int position, float scrollProgress) { } } + /** + * calculates position for mRecyclerView which needs position in range of 0 to n-1 + * @param scrollProgress + * @return + */ private int getPositionFromScrollProgress(float scrollProgress) { - return (int) (mRecyclerView.getAdapter().getItemCount() * scrollProgress); + return (int) ((mRecyclerView.getAdapter().getItemCount() - 1) * scrollProgress); } /** From 5ec7f0242018973c02fa88d46a50e4285810adbc Mon Sep 17 00:00:00 2001 From: Bruce McLean Date: Wed, 8 Jun 2016 09:09:04 -0400 Subject: [PATCH 2/3] Tweak calculation of Scroll position - linearity adjustment for large child views. --- .../AbsRecyclerViewFastScroller.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java b/recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java index fff1241..744cb42 100644 --- a/recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java +++ b/recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java @@ -173,7 +173,12 @@ private void updateSectionIndicator(int position, float scrollProgress) { * @return */ private int getPositionFromScrollProgress(float scrollProgress) { - return (int) ((mRecyclerView.getAdapter().getItemCount() - 1) * scrollProgress); + int itemCount = mRecyclerView.getAdapter().getItemCount(); + int positon = (int) (itemCount * scrollProgress); + if(positon >= itemCount) { // limit in case scrollProgress is exactly 1 + positon = itemCount; + } + return positon; } /** From 95a04a7d1a4292c353865d7e45749296cc57cd12 Mon Sep 17 00:00:00 2001 From: Bruce McLean Date: Wed, 8 Jun 2016 09:40:18 -0400 Subject: [PATCH 3/3] Tweak calculation of Scroll position - linearity adjustment for large child views. --- .../recyclerviewfastscroller/AbsRecyclerViewFastScroller.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java b/recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java index 744cb42..b0a93c0 100644 --- a/recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java +++ b/recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java @@ -176,7 +176,7 @@ private int getPositionFromScrollProgress(float scrollProgress) { int itemCount = mRecyclerView.getAdapter().getItemCount(); int positon = (int) (itemCount * scrollProgress); if(positon >= itemCount) { // limit in case scrollProgress is exactly 1 - positon = itemCount; + positon = itemCount - 1; } return positon; }