[Android] Audio browser: sort the songs by album in the AlbumsSongs panel and add separators with the album titles as discussed
Adrien Maglo
git at videolan.org
Fri Dec 6 11:59:35 CET 2013
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Fri Dec 6 11:59:25 2013 +0100| [3437f96f110fb1f17b9eed6478ce0a84507669eb] | committer: Adrien Maglo
Audio browser: sort the songs by album in the AlbumsSongs panel and add separators with the album titles as discussed
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=3437f96f110fb1f17b9eed6478ce0a84507669eb
---
.../org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java | 10 ++++++----
.../org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java | 5 +++++
2 files changed, 11 insertions(+), 4 deletions(-)
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 d8f0024..633c1de 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -153,14 +153,16 @@ public class AudioAlbumsSongsFragment extends SherlockFragment {
mSongsAdapter.clear();
Collections.sort(mediaList, MediaComparators.byAlbum);
+ String lastAlbumName = new String();
+
for (int i = 0; i < mediaList.size(); ++i) {
Media media = mediaList.get(i);
mAlbumsAdapter.add(media.getAlbum(), null, media);
- }
- Collections.sort(mediaList, MediaComparators.byName);
- for (int i = 0; i < mediaList.size(); ++i) {
- Media media = mediaList.get(i);
+ if (!lastAlbumName.equals(media.getAlbum())) {
+ mSongsAdapter.addSeparator(media.getAlbum());
+ lastAlbumName = media.getAlbum();
+ }
mSongsAdapter.add(media.getTitle(), null, media);
}
}
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 b7c75cb..abd6ae0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
@@ -122,6 +122,11 @@ public class AudioBrowserListAdapter extends BaseAdapter {
}
}
+ public void addSeparator(String title) {
+ ListItem item = new ListItem(title, null, null, true);
+ mItems.add(item);
+ }
+
public void clear() {
mMediaItemMap.clear();
mItems.clear();
More information about the Android
mailing list