private HashSet getOpenedPlaylists() { HashSet<String> myHashSet = new HashSet<>(); for (AbstractSong data : getAllItems()) { if (data.getClass() == PlaylistData.class && ((PlaylistData) data).isExpanded()) { myHashSet.add(String.valueOf(data.getId())); } } return myHashSet; }
public void updatePlaylist() { ArrayList<AbstractSong> playlists = getPlaylists(); for (AbstractSong playlistData : playlists) { ((PlaylistData) playlistData) .setSongs( ((PlaylistData) playlistData) .getSongsFromPlaylist(getContext(), playlistData.getId())); } updateAdapter(playlists); }
private void setOpened() { ArrayList<AbstractSong> allItems = getAllItems(); HashSet<String> myHashSet = (HashSet<String>) MusicApp.getSharedPreferences().getStringSet(PREF_LAST_OPENED, new HashSet<String>()); for (AbstractSong data : getAllItems()) { if (data.getClass() == PlaylistData.class && myHashSet.contains(String.valueOf(data.getId()))) { if (((PlaylistData) data).getSongs().size() == 0 || ((PlaylistData) data).isExpanded()) continue; allItems.addAll(allItems.indexOf(data) + 1, ((PlaylistData) data).getSongs()); ((PlaylistData) data).setExpanded(true); } } updateAdapter(allItems); }