private void autoplay() { if (!searchResult.getSongs().isEmpty()) { onSongSelected(searchResult.getSongs().get(0), false, false, true, false); } else if (!searchResult.getAlbums().isEmpty()) { onAlbumSelected(searchResult.getAlbums().get(0), true); } }
private void expandSongs() { songAdapter.clear(); for (MusicDirectory.Entry song : searchResult.getSongs()) { songAdapter.add(song); } songAdapter.notifyDataSetChanged(); mergeAdapter.removeAdapter(moreSongsAdapter); mergeAdapter.notifyDataSetChanged(); }
private void expandArtists() { artistAdapter.clear(); for (Artist artist : searchResult.getArtists()) { artistAdapter.add(artist); } artistAdapter.notifyDataSetChanged(); mergeAdapter.removeAdapter(moreArtistsAdapter); mergeAdapter.notifyDataSetChanged(); }
private void expandAlbums() { albumAdapter.clear(); for (MusicDirectory.Entry album : searchResult.getAlbums()) { albumAdapter.add(album); } albumAdapter.notifyDataSetChanged(); mergeAdapter.removeAdapter(moreAlbumsAdapter); mergeAdapter.notifyDataSetChanged(); }
private void populateList() { mergeAdapter = new MergeAdapter(); mergeAdapter.addView(searchButton, true); if (searchResult != null) { List<Artist> artists = searchResult.getArtists(); if (!artists.isEmpty()) { mergeAdapter.addView(artistsHeading); List<Artist> displayedArtists = new ArrayList<Artist>(artists.subList(0, Math.min(DEFAULT_ARTISTS, artists.size()))); artistAdapter = new ArtistAdapter(this, displayedArtists); mergeAdapter.addAdapter(artistAdapter); if (artists.size() > DEFAULT_ARTISTS) { moreArtistsAdapter = mergeAdapter.addView(moreArtistsButton, true); } } List<MusicDirectory.Entry> albums = searchResult.getAlbums(); if (!albums.isEmpty()) { mergeAdapter.addView(albumsHeading); List<MusicDirectory.Entry> displayedAlbums = new ArrayList<MusicDirectory.Entry>( albums.subList(0, Math.min(DEFAULT_ALBUMS, albums.size()))); albumAdapter = new EntryAdapter(this, getImageLoader(), displayedAlbums, false); mergeAdapter.addAdapter(albumAdapter); if (albums.size() > DEFAULT_ALBUMS) { moreAlbumsAdapter = mergeAdapter.addView(moreAlbumsButton, true); } } List<MusicDirectory.Entry> songs = searchResult.getSongs(); if (!songs.isEmpty()) { mergeAdapter.addView(songsHeading); List<MusicDirectory.Entry> displayedSongs = new ArrayList<MusicDirectory.Entry>( songs.subList(0, Math.min(DEFAULT_SONGS, songs.size()))); songAdapter = new EntryAdapter(this, getImageLoader(), displayedSongs, false); mergeAdapter.addAdapter(songAdapter); if (songs.size() > DEFAULT_SONGS) { moreSongsAdapter = mergeAdapter.addView(moreSongsButton, true); } } boolean empty = searchResult.getArtists().isEmpty() && searchResult.getAlbums().isEmpty() && searchResult.getSongs().isEmpty(); searchButton.setText(empty ? R.string.search_no_match : R.string.search_search); } list.setAdapter(mergeAdapter); }