[Android] Fix playlist saving

Geoffrey Métais git at videolan.org
Thu Jan 5 17:56:21 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan  5 16:11:37 2017 +0100| [d6177c594f60102c080b293598f8287c66839bb3] | committer: Geoffrey Métais

Fix playlist saving

> https://code.videolan.org/videolan/vlc-android/commit/d6177c594f60102c080b293598f8287c66839bb3
---

 .../org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java    | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
index b6c20f5..26694ed 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
@@ -49,6 +49,7 @@ import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.gui.audio.AudioBrowserAdapter;
 import org.videolan.vlc.interfaces.IEventsHandler;
+import org.videolan.vlc.util.Util;
 
 import java.util.ArrayList;
 import java.util.LinkedList;
@@ -58,7 +59,7 @@ public class SavePlaylistDialog extends DialogFragment implements View.OnClickLi
     public final static String TAG = "VLC/SavePlaylistDialog";
 
     public static final String KEY_TRACKS = "PLAYLIST_TRACKS";
-    public static final String KEY_NEW_TRACKS = "PLAYLIST_TRACKS";
+    public static final String KEY_NEW_TRACKS = "PLAYLIST_NEW_TRACKS";
 
     EditText mEditText;
     RecyclerView mListView;
@@ -142,17 +143,17 @@ public class SavePlaylistDialog extends DialogFragment implements View.OnClickLi
         VLCApplication.runBackground(new Runnable() {
             public void run() {
                 final String name = mEditText.getText().toString().trim();
-                boolean addTracks = mNewTrack != null;
+                boolean addTracks = !Util.isListEmpty(mNewTrack);
                 Playlist playlist = mMedialibrary.getPlaylist(mPlaylistId);
                 boolean exists = playlist != null;
                 ArrayList<MediaWrapper> tracks;
+                if (!exists)
+                    playlist = mMedialibrary.createPlaylist(name);
                 if (addTracks) {
-                    if (!exists)
-                        playlist = mMedialibrary.createPlaylist(name);
                     tracks = mNewTrack;
                 } else {//Save a playlist
-                    if (exists)
-                        playlist.delete(mMedialibrary);
+                    for (MediaWrapper mw : playlist.getTracks(mMedialibrary))
+                        playlist.remove(mMedialibrary, mw.getId());
                     tracks = mTracks;
                 }
                 LinkedList<Long> ids = new LinkedList<>();



More information about the Android mailing list