[Android] [PATCH] Sort in Artist AlbumSongs by tracknumber

Geoffrey Métais geoffrey.metais at gmail.com
Mon Dec 8 14:55:19 CET 2014


---
 .../org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java   |  2 +-
 .../org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java    | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index 172f08d..37163c3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -358,8 +358,8 @@ public class AudioAlbumsSongsFragment extends Fragment implements SwipeRefreshLa
                             mAlbumsAdapter.addSeparator(media.getArtist(), media);
                             mAlbumsAdapter.add(media.getAlbum(), null, media);
                             mSongsAdapter.addSeparator(media.getAlbum(), media);
-                            mSongsAdapter.add(media.getTitle(), null, media);
                         }
+                        mSongsAdapter.sortByAlbum();
                         mAlbumsAdapter.notifyDataSetChanged();
                         mSongsAdapter.notifyDataSetChanged();
                         mSwipeRefreshLayout.setRefreshing(false);
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 bc35e28..bfd1818 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
@@ -228,6 +228,16 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
         }
     }
 
+    public void sortByAlbum(){
+        mItems.clear();
+        for (ListItem album : mSeparatorItemMap.values()){
+            mItems.add(album);
+            Collections.sort(album.mMediaList, MediaComparators.byTrackNumber);
+            for (Media media : album.mMediaList)
+                add(media.getTitle(), null, media);
+        }
+    }
+
     /**
      * Remove all the reference to a media in the list items.
      * Remove also all the list items that contain only this media.
-- 
1.9.1



More information about the Android mailing list