aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-06-04 21:52:15 -0700
committerScott Jackson <daneren2005@gmail.com>2013-06-04 21:52:15 -0700
commita0504c6185434789ebed8f67808b069a9c1bfbc7 (patch)
tree357af1ad94f8e8d62167ec53cb7f5d2514969eed /subsonic-android/src
parentfce836130ece465927bdd7deeef4ce2c7881a598 (diff)
downloaddsub-a0504c6185434789ebed8f67808b069a9c1bfbc7.tar.gz
dsub-a0504c6185434789ebed8f67808b069a9c1bfbc7.tar.bz2
dsub-a0504c6185434789ebed8f67808b069a9c1bfbc7.zip
Added ability to create new playlist from add to playlist menu
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java55
1 files changed, 54 insertions, 1 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index 2fcdc00f..0ff795e2 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -627,6 +627,7 @@ public class SubsonicFragment extends SherlockFragment {
@Override
protected void done(final List<Playlist> playlists) {
List<String> names = new ArrayList<String>();
+ names.add("Create New");
for(Playlist playlist: playlists) {
names.add(playlist.getName());
}
@@ -635,7 +636,12 @@ public class SubsonicFragment extends SherlockFragment {
builder.setTitle("Add to Playlist")
.setItems(names.toArray(new CharSequence[names.size()]), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
- addToPlaylist(playlists.get(which), songs);
+
+ if(which > 0) {
+ addToPlaylist(playlists.get(which - 1), songs);
+ } else {
+ createNewPlaylist(songs);
+ }
}
});
AlertDialog dialog = builder.create();
@@ -683,6 +689,53 @@ public class SubsonicFragment extends SherlockFragment {
}
}.execute();
}
+
+ private void createNewPlaylist(final List<MusicDirectory.Entry> songs) {
+ View layout = context.getLayoutInflater().inflate(R.layout.save_playlist, null);
+ final EditText playlistNameView = (EditText) layout.findViewById(R.id.save_playlist_name);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setTitle(R.string.download_playlist_title)
+ .setMessage(R.string.download_playlist_name)
+ .setView(layout)
+ .setPositiveButton(R.string.common_save, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ createNewPlaylist(songs, String.valueOf(playlistNameView.getText()));
+ }
+ })
+ .setNegativeButton(R.string.common_cancel, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ dialog.cancel();
+ }
+ })
+ .setCancelable(true);
+
+ AlertDialog dialog = builder.create();
+ dialog.show();
+ }
+ private void createNewPlaylist(final List<MusicDirectory.Entry> songs, final String name) {
+ new SilentBackgroundTask<Void>(context) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ musicService.createPlaylist(null, name, songs, context, null);
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ Util.toast(context, R.string.download_playlist_done);
+ }
+
+ @Override
+ protected void error(Throwable error) {
+ String msg = context.getResources().getString(R.string.download_playlist_error) + " " + getErrorMessage(error);
+ Util.toast(context, msg);
+ }
+ }.execute();
+ }
public void displaySongInfo(final MusicDirectory.Entry song) {
Integer bitrate = null;