Refactoring: Replace usages of ArrayList<> with List<>Collections refactor (#686)
* First replacements of ArrayList with List * Get rid of ArrayList-Types * Revert irrelevant changes * Fixed stuff noticed by @arkon
This commit is contained in:
parent
60f5c72219
commit
37725948f1
74 changed files with 338 additions and 277 deletions
|
|
@ -22,16 +22,16 @@ public class AddToPlaylistDialog extends DialogFragment {
|
|||
|
||||
@NonNull
|
||||
public static AddToPlaylistDialog create(Song song) {
|
||||
ArrayList<Song> list = new ArrayList<>();
|
||||
List<Song> list = new ArrayList<>();
|
||||
list.add(song);
|
||||
return create(list);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static AddToPlaylistDialog create(ArrayList<Song> songs) {
|
||||
public static AddToPlaylistDialog create(List<Song> songs) {
|
||||
AddToPlaylistDialog dialog = new AddToPlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelableArrayList("songs", songs);
|
||||
args.putParcelableArrayList("songs", new ArrayList<>(songs));
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ public class AddToPlaylistDialog extends DialogFragment {
|
|||
.items(playlistNames)
|
||||
.itemsCallback((materialDialog, view, i, charSequence) -> {
|
||||
//noinspection unchecked
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
final List<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
if (songs == null) return;
|
||||
if (i == 0) {
|
||||
materialDialog.dismiss();
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.kabouzeid.gramophone.model.Song;
|
|||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
|
||||
|
|
@ -29,17 +30,17 @@ public class CreatePlaylistDialog extends DialogFragment {
|
|||
|
||||
@NonNull
|
||||
public static CreatePlaylistDialog create(@Nullable Song song) {
|
||||
ArrayList<Song> list = new ArrayList<>();
|
||||
List<Song> list = new ArrayList<>();
|
||||
if (song != null)
|
||||
list.add(song);
|
||||
return create(list);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static CreatePlaylistDialog create(ArrayList<Song> songs) {
|
||||
public static CreatePlaylistDialog create(List<Song> songs) {
|
||||
CreatePlaylistDialog dialog = new CreatePlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelableArrayList(SONGS, songs);
|
||||
args.putParcelableArrayList(SONGS, new ArrayList<>(songs));
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -63,7 +64,7 @@ public class CreatePlaylistDialog extends DialogFragment {
|
|||
final int playlistId = PlaylistsUtil.createPlaylist(getActivity(), name);
|
||||
if (getActivity() != null) {
|
||||
//noinspection unchecked
|
||||
ArrayList<Song> songs = getArguments().getParcelableArrayList(SONGS);
|
||||
List<Song> songs = getArguments().getParcelableArrayList(SONGS);
|
||||
if (songs != null && !songs.isEmpty()) {
|
||||
PlaylistsUtil.addToPlaylist(getActivity(), songs, playlistId, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.kabouzeid.gramophone.model.Playlist;
|
|||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
|
|
@ -20,16 +21,16 @@ public class DeletePlaylistDialog extends DialogFragment {
|
|||
|
||||
@NonNull
|
||||
public static DeletePlaylistDialog create(Playlist playlist) {
|
||||
ArrayList<Playlist> list = new ArrayList<>();
|
||||
List<Playlist> list = new ArrayList<>();
|
||||
list.add(playlist);
|
||||
return create(list);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static DeletePlaylistDialog create(ArrayList<Playlist> playlists) {
|
||||
public static DeletePlaylistDialog create(List<Playlist> playlists) {
|
||||
DeletePlaylistDialog dialog = new DeletePlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelableArrayList("playlists", playlists);
|
||||
args.putParcelableArrayList("playlists", new ArrayList<>(playlists));
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -38,7 +39,7 @@ public class DeletePlaylistDialog extends DialogFragment {
|
|||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
//noinspection unchecked
|
||||
final ArrayList<Playlist> playlists = getArguments().getParcelableArrayList("playlists");
|
||||
final List<Playlist> playlists = getArguments().getParcelableArrayList("playlists");
|
||||
int title;
|
||||
CharSequence content;
|
||||
//noinspection ConstantConditions
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.kabouzeid.gramophone.model.Song;
|
|||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
|
||||
|
|
@ -20,16 +21,16 @@ public class DeleteSongsDialog extends DialogFragment {
|
|||
|
||||
@NonNull
|
||||
public static DeleteSongsDialog create(Song song) {
|
||||
ArrayList<Song> list = new ArrayList<>();
|
||||
List<Song> list = new ArrayList<>();
|
||||
list.add(song);
|
||||
return create(list);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static DeleteSongsDialog create(ArrayList<Song> songs) {
|
||||
public static DeleteSongsDialog create(List<Song> songs) {
|
||||
DeleteSongsDialog dialog = new DeleteSongsDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelableArrayList("songs", songs);
|
||||
args.putParcelableArrayList("songs", new ArrayList<>(songs));
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -38,7 +39,7 @@ public class DeleteSongsDialog extends DialogFragment {
|
|||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
//noinspection unchecked
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
final List<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
int title;
|
||||
CharSequence content;
|
||||
if (songs.size() > 1) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.kabouzeid.gramophone.model.PlaylistSong;
|
|||
import com.kabouzeid.gramophone.util.PlaylistsUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
|
|
@ -20,16 +21,16 @@ public class RemoveFromPlaylistDialog extends DialogFragment {
|
|||
|
||||
@NonNull
|
||||
public static RemoveFromPlaylistDialog create(PlaylistSong song) {
|
||||
ArrayList<PlaylistSong> list = new ArrayList<>();
|
||||
List<PlaylistSong> list = new ArrayList<>();
|
||||
list.add(song);
|
||||
return create(list);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static RemoveFromPlaylistDialog create(ArrayList<PlaylistSong> songs) {
|
||||
public static RemoveFromPlaylistDialog create(List<PlaylistSong> songs) {
|
||||
RemoveFromPlaylistDialog dialog = new RemoveFromPlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelableArrayList("songs", songs);
|
||||
args.putParcelableArrayList("songs", new ArrayList<>(songs));
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -38,7 +39,7 @@ public class RemoveFromPlaylistDialog extends DialogFragment {
|
|||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
//noinspection unchecked
|
||||
final ArrayList<PlaylistSong> songs = getArguments().getParcelableArrayList("songs");
|
||||
final List<PlaylistSong> songs = getArguments().getParcelableArrayList("songs");
|
||||
int title;
|
||||
CharSequence content;
|
||||
if (songs.size() > 1) {
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public class ScanMediaFolderChooserDialog extends DialogFragment implements Mate
|
|||
final Context applicationContext = getActivity().getApplicationContext();
|
||||
final WeakReference<Activity> activityWeakReference = new WeakReference<>(getActivity());
|
||||
dismiss();
|
||||
new FoldersFragment.ListPathsAsyncTask(getActivity(), paths -> scanPaths(activityWeakReference, applicationContext, paths)).execute(new FoldersFragment.ListPathsAsyncTask.LoadingInfo(parentFolder, FoldersFragment.AUDIO_FILE_FILTER));
|
||||
new FoldersFragment.ArrayListPathsAsyncTask(getActivity(), paths -> scanPaths(activityWeakReference, applicationContext, paths)).execute(new FoldersFragment.ArrayListPathsAsyncTask.LoadingInfo(parentFolder, FoldersFragment.AUDIO_FILE_FILTER));
|
||||
})
|
||||
.onNegative((materialDialog, dialogAction) -> dismiss())
|
||||
.positiveText(R.string.action_scan_directory)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue