コード例 #1
0
 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);
   }
 }
コード例 #2
0
  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);
    }
  }