Fix redundant addAll

This commit is contained in:
Andrew Rabert 2018-04-24 00:35:58 -04:00
parent b7b90ea8d5
commit 4fed3bd3a3
5 changed files with 5 additions and 10 deletions

View File

@ -315,8 +315,7 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH
} }
public List<T> getSelected() { public List<T> getSelected() {
List<T> selected = new ArrayList<>(); List<T> selected = new ArrayList<>(this.selected);
selected.addAll(this.selected);
return selected; return selected;
} }

View File

@ -97,8 +97,7 @@ public class DownloadFragment extends SelectRecyclerFragment<DownloadFile> imple
return new ArrayList<>(); return new ArrayList<>();
} }
List<DownloadFile> songList = new ArrayList<>(); List<DownloadFile> songList = new ArrayList<>(downloadService.getBackgroundDownloads());
songList.addAll(downloadService.getBackgroundDownloads());
currentRevision = downloadService.getDownloadListUpdateRevision(); currentRevision = downloadService.getDownloadListUpdateRevision();
return songList; return songList;
} }

View File

@ -177,7 +177,6 @@ public class SelectArtistFragment extends SelectRecyclerFragment<Serializable> i
items.addAll(entries); items.addAll(entries);
} else { } else {
List<Artist> artists = new ArrayList<>(); List<Artist> artists = new ArrayList<>();
items = new ArrayList<>();
MusicDirectory dir = musicService.getMusicDirectory(groupId, groupName, refresh, context, listener); MusicDirectory dir = musicService.getMusicDirectory(groupId, groupName, refresh, context, listener);
for (Entry entry : dir.getChildren(true, false)) { for (Entry entry : dir.getChildren(true, false)) {
Artist artist = new Artist(); Artist artist = new Artist();
@ -189,7 +188,7 @@ public class SelectArtistFragment extends SelectRecyclerFragment<Serializable> i
Indexes indexes = new Indexes(); Indexes indexes = new Indexes();
//indexes.setArtists = artists; //indexes.setArtists = artists;
indexes.sortChildren(context); indexes.sortChildren(context);
items.addAll(indexes.getArtists()); items = new ArrayList<>(indexes.getArtists());
entries = dir.getChildren(false, true); entries = dir.getChildren(false, true);
items.addAll(entries); items.addAll(entries);

View File

@ -836,8 +836,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
@Override @Override
protected List<Playlist> doInBackground() throws Throwable { protected List<Playlist> doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context); MusicService musicService = MusicServiceFactory.getMusicService(context);
List<Playlist> playlists = new ArrayList<>(); List<Playlist> playlists = new ArrayList<>(musicService.getPlaylists(false, context, this));
playlists.addAll(musicService.getPlaylists(false, context, this));
// Iterate through and remove all non owned public playlists // Iterate through and remove all non owned public playlists
Iterator<Playlist> it = playlists.iterator(); Iterator<Playlist> it = playlists.iterator();

View File

@ -659,8 +659,7 @@ public class CachedMusicService implements MusicService {
private void deleteRemovedEntries(Context context, MusicDirectory dir, MusicDirectory cached) { private void deleteRemovedEntries(Context context, MusicDirectory dir, MusicDirectory cached) {
if (cached != null) { if (cached != null) {
List<Entry> oldList = new ArrayList<>(); List<Entry> oldList = new ArrayList<>(cached.getChildren());
oldList.addAll(cached.getChildren());
oldList.removeAll(dir.getChildren()); oldList.removeAll(dir.getChildren());
// Anything remaining has been removed from server // Anything remaining has been removed from server