[Android] Sort in Artist AlbumSongs by tracknumber

Geoffrey Métais git at videolan.org
Tue Dec 9 15:23:18 CET 2014


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Dec  8 14:54:18 2014 +0100| [6e1d14c70c79eac978b22a439834fd6b033ddd99] | committer: Geoffrey Métais

Sort in Artist AlbumSongs by tracknumber

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

 .../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.



More information about the Android mailing list