load global playlists on main activity
This commit is contained in:
parent
d5e2b95ca3
commit
5fcd9e979a
11 changed files with 76 additions and 157 deletions
|
|
@ -24,7 +24,7 @@ public class M3UWriter implements M3UConstants {
|
|||
if (playlist instanceof AbsSmartPlaylist) {
|
||||
songs = ((AbsSmartPlaylist) playlist).getSongs(context);
|
||||
} else {
|
||||
songs = PlaylistSongLoader.getPlaylistSongList(context, playlist.id);
|
||||
songs = PlaylistSongLoader.getPlaylistSongList(context, playlist.id.hashCode());
|
||||
}
|
||||
|
||||
if (songs.size() > 0) {
|
||||
|
|
|
|||
|
|
@ -40,13 +40,13 @@ public class PlaylistMenuHelper {
|
|||
AddToPlaylistDialog.create(new ArrayList<>(getPlaylistSongs(activity, playlist))).show(activity.getSupportFragmentManager(), "ADD_PLAYLIST");
|
||||
return true;
|
||||
case R.id.action_rename_playlist:
|
||||
RenamePlaylistDialog.create(playlist.id).show(activity.getSupportFragmentManager(), "RENAME_PLAYLIST");
|
||||
RenamePlaylistDialog.create(playlist.id.hashCode()).show(activity.getSupportFragmentManager(), "RENAME_PLAYLIST");
|
||||
return true;
|
||||
case R.id.action_delete_playlist:
|
||||
DeletePlaylistDialog.create(playlist).show(activity.getSupportFragmentManager(), "DELETE_PLAYLIST");
|
||||
return true;
|
||||
case R.id.action_save_playlist:
|
||||
new SavePlaylistAsyncTask(activity).execute(playlist);
|
||||
// TODO remove
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -56,32 +56,6 @@ public class PlaylistMenuHelper {
|
|||
private static List<? extends Song> getPlaylistSongs(@NonNull Activity activity, Playlist playlist) {
|
||||
return playlist instanceof AbsSmartPlaylist ?
|
||||
((AbsSmartPlaylist) playlist).getSongs(activity) :
|
||||
PlaylistSongLoader.getPlaylistSongList(activity, playlist.id);
|
||||
}
|
||||
|
||||
|
||||
private static class SavePlaylistAsyncTask extends WeakContextAsyncTask<Playlist, String, String> {
|
||||
public SavePlaylistAsyncTask(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Playlist... params) {
|
||||
try {
|
||||
return String.format(App.getInstance().getApplicationContext().getString(R.string.saved_playlist_to), PlaylistsUtil.savePlaylist(App.getInstance().getApplicationContext(), params[0]));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return String.format(App.getInstance().getApplicationContext().getString(R.string.failed_to_save_playlist), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String string) {
|
||||
super.onPostExecute(string);
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
Toast.makeText(context, string, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
PlaylistSongLoader.getPlaylistSongList(activity, playlist.id.hashCode());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue