[Android] Adjust fascroller bubble for sections name

Geoffrey Métais git at videolan.org
Tue Jul 18 17:44:07 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jul 18 17:25:35 2017 +0200| [75b8cabdbdf7ec37136cfcf3b6fbf713c9b8acbd] | committer: Geoffrey Métais

Adjust fascroller bubble for sections name

> https://code.videolan.org/videolan/vlc-android/commit/75b8cabdbdf7ec37136cfcf3b6fbf713c9b8acbd
---

 vlc-android/src/org/videolan/vlc/gui/view/FastScroller.java | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.java b/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.java
index aaa3aeb19..4c4a0be23 100644
--- a/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.java
+++ b/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.java
@@ -89,8 +89,8 @@ public class FastScroller extends LinearLayout {
         setClipChildren(false);
         LayoutInflater inflater = LayoutInflater.from(context);
         inflater.inflate(R.layout.fastscroller, this);
-        handle = (ImageView) findViewById(R.id.fastscroller_handle);
-        bubble = (TextView) findViewById(R.id.fastscroller_bubble);
+        handle = findViewById(R.id.fastscroller_handle);
+        bubble = findViewById(R.id.fastscroller_bubble);
     }
 
     @Override
@@ -225,15 +225,18 @@ public class FastScroller extends LinearLayout {
     };
 
     private class ScrollListener extends RecyclerView.OnScrollListener {
-
+        StringBuilder sb = new StringBuilder();
         @Override
         public void onScrolled(RecyclerView rv, int dx, int dy) {
+            sb.setLength(0);
             if (mRecyclerviewTotalHeight == 0)
                 mRecyclerviewTotalHeight = mRecyclerView.computeVerticalScrollRange()-mRecyclerView.computeVerticalScrollExtent();
             int firstVisiblePosition = ((LinearLayoutManager)mRecyclerView.getLayoutManager()).findFirstVisibleItemPosition();
             if (mFastScrolling) {
-                String letter = ((SeparatedAdapter)mRecyclerView.getAdapter()).getSectionforPosition(firstVisiblePosition);
-                bubble.setText(letter);
+                sb.append(' ')
+                        .append(((SeparatedAdapter)mRecyclerView.getAdapter()).getSectionforPosition(firstVisiblePosition))
+                        .append(' ');
+                bubble.setText(sb.toString());
                 return;
             }
             if (FastScroller.this.getVisibility() == INVISIBLE)



More information about the Android mailing list