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() {
List<T> selected = new ArrayList<>();
selected.addAll(this.selected);
List<T> selected = new ArrayList<>(this.selected);
return selected;
}

View File

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

View File

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

View File

@ -836,8 +836,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
@Override
protected List<Playlist> doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
List<Playlist> playlists = new ArrayList<>();
playlists.addAll(musicService.getPlaylists(false, context, this));
List<Playlist> playlists = new ArrayList<>(musicService.getPlaylists(false, context, this));
// Iterate through and remove all non owned public playlists
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) {
if (cached != null) {
List<Entry> oldList = new ArrayList<>();
oldList.addAll(cached.getChildren());
List<Entry> oldList = new ArrayList<>(cached.getChildren());
oldList.removeAll(dir.getChildren());
// Anything remaining has been removed from server