[Android] AudioBrowserFragment: activate scroll indexing

Edward Wang git at videolan.org
Sun Jun 8 22:29:25 CEST 2014


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Wed Jun  4 13:19:22 2014 -0400| [c05f39fb2ef629413fb61e46728cf8e888d4ae92] | committer: Edward Wang

AudioBrowserFragment: activate scroll indexing

Close #11152

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=c05f39fb2ef629413fb61e46728cf8e888d4ae92
---

 .../videolan/vlc/gui/audio/AudioBrowserFragment.java    |    8 ++++++++
 .../videolan/vlc/gui/audio/AudioBrowserListAdapter.java |   15 ++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index fd3100d..d23f640 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -392,6 +392,7 @@ public class AudioBrowserFragment extends SherlockFragment {
             Media media = audioList.get(i);
             mSongsAdapter.add(media.getTitle(), media.getArtist(), media);
         }
+        mSongsAdapter.addScrollSections();
 
         Collections.sort(audioList, MediaComparators.byArtist);
         for (int i = 0; i < audioList.size(); i++) {
@@ -418,6 +419,13 @@ public class AudioBrowserFragment extends SherlockFragment {
         mArtistsAdapter.notifyDataSetChanged();
         mAlbumsAdapter.notifyDataSetChanged();
         mGenresAdapter.notifyDataSetChanged();
+        // Refresh the fast scroll data, since SectionIndexer doesn't respect notifyDataSetChanged
+        int[] lists = { R.id.songs_list, R.id.artists_list, R.id.albums_list, R.id.genres_list };
+        for(int r : lists) {
+            ListView l = (ListView)getView().findViewById(r);
+            l.setFastScrollEnabled(false);
+            l.setFastScrollEnabled(true);
+        }
     }
 
     AudioBrowserListAdapter.ContextPopupMenuListener mContextPopupMenuListener
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
index 4ef2cf6..4b40b14 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
@@ -109,7 +109,20 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
         notifyDataSetChanged();
     }
 
-    public void addLeterSeparators() {
+    public void addLetterSeparators() {
+        calculateSections(true);
+    }
+
+    public void addScrollSections() {
+        calculateSections(false);
+    }
+
+    /**
+     * Calculate sections of the list
+     *
+     * @param addSeparators True to add GUI-level separators, false to just populate the cache
+     */
+    private void calculateSections(boolean addSeparators) {
         char prevFirstChar = 'a';
         boolean firstSeparator = true;
 



More information about the Android mailing list