From bd331bbaf5c2374ce34f23a3c5f589e7dfeaf41c Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 25 Aug 2015 17:22:02 -0700 Subject: Disable fast scrolling when less than 2 pages worth of items --- .../java/github/daneren2005/dsub/view/FastScroller.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java b/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java index c698e37b..07f899ed 100644 --- a/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java +++ b/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java @@ -117,7 +117,6 @@ public class FastScroller extends LinearLayout { public void attachRecyclerView(RecyclerView recyclerView) { this.recyclerView = recyclerView; recyclerView.addOnScrollListener(scrollListener); - recyclerView.setVerticalScrollBarEnabled(false); } public void detachRecyclerView() { recyclerView.removeOnScrollListener(scrollListener); @@ -218,9 +217,16 @@ public class FastScroller extends LinearLayout { float proportion = (float)position/(float)itemCount; setBubbleAndHandlePosition(height*proportion); - if(!hasScrolled && (dx > 0 || dy > 0)) { - setVisibility(View.VISIBLE); - hasScrolled = true; + if((visibleRange * 2) < itemCount) { + if (!hasScrolled && (dx > 0 || dy > 0)) { + setVisibility(View.VISIBLE); + hasScrolled = true; + recyclerView.setVerticalScrollBarEnabled(false); + } + } else if(hasScrolled) { + setVisibility(View.GONE); + hasScrolled = false; + recyclerView.setVerticalScrollBarEnabled(true); } } } -- cgit v1.2.3