aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-10-23 15:50:46 -0700
committerScott Jackson <daneren2005@gmail.com>2015-10-23 15:50:46 -0700
commit67965f871cc78689da43926a11cfe1068ba51e5c (patch)
tree5984d843afc0bacebba4b8e36422500885f1abc4 /app
parent3cf3c0143b0c5e2e767fe8d89dcf79ea2d19a186 (diff)
downloaddsub-67965f871cc78689da43926a11cfe1068ba51e5c.tar.gz
dsub-67965f871cc78689da43926a11cfe1068ba51e5c.tar.bz2
dsub-67965f871cc78689da43926a11cfe1068ba51e5c.zip
Use simpler position calculation to get rid of jitter
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/FastScroller.java15
1 files changed, 5 insertions, 10 deletions
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 e36667d8..bdfde1cf 100644
--- a/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java
+++ b/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java
@@ -209,17 +209,12 @@ public class FastScroller extends LinearLayout {
View firstVisibleView = recyclerView.getChildAt(0);
int firstVisiblePosition = recyclerView.getChildPosition(firstVisibleView);
int visibleRange = recyclerView.getChildCount();
- int lastVisiblePosition = firstVisiblePosition+visibleRange;
int itemCount = recyclerView.getAdapter().getItemCount();
- int position;
- if(firstVisiblePosition == 0)
- position = 0;
- else if(lastVisiblePosition == itemCount)
- position = itemCount;
- else
- position = (int)(((float)firstVisiblePosition/(((float)itemCount-(float)visibleRange)))*(float)itemCount);
- float proportion = (float)position/(float)itemCount;
- setBubbleAndHandlePosition(height*proportion);
+
+ // Add the percentage of the item the user has scrolled past already
+ float position = firstVisiblePosition + (-firstVisibleView.getY() / firstVisibleView.getHeight());
+ float proportion = position / itemCount;
+ setBubbleAndHandlePosition(height * proportion);
if((visibleRange * 2) < itemCount) {
if (!hasScrolled && (dx > 0 || dy > 0)) {