[Android] Fix playlist saving

Geoffrey Métais git at videolan.org
Thu Jan 5 16:12:52 CET 2017


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

Fix playlist saving

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

 .../src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java     | 9 +++++----
 1 file changed, 5 insertions(+), 4 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..f5c7a52 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,7 +143,7 @@ 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;
@@ -151,8 +152,8 @@ public class SavePlaylistDialog extends DialogFragment implements View.OnClickLi
                         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