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); } }
private void updateList() { if (mediaList == null) return; mAlbumsAdapter.clear(); 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); if (!lastAlbumName.equals(media.getAlbum())) { mSongsAdapter.addSeparator(media.getAlbum()); lastAlbumName = media.getAlbum(); } mSongsAdapter.add(media.getTitle(), null, media); } }