[Android] SavePlaylistDialog: Prevent NPE

Geoffrey Métais git at videolan.org
Tue Oct 3 12:06:36 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Oct  3 09:53:42 2017 +0200| [e4a0c157dc7ad0a9dcc3bdefddfd26c8df8707d8] | committer: Geoffrey Métais

SavePlaylistDialog: Prevent NPE

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

 .../src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java        | 6 ++++--
 1 file changed, 4 insertions(+), 2 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 1bd6efa72..2379fa34d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
@@ -148,7 +148,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 = !Tools.isArrayEmpty(mNewTrack);
+                final boolean addTracks = !Tools.isArrayEmpty(mNewTrack);
                 Playlist playlist = mMedialibrary.getPlaylist(mPlaylistId);
                 boolean exists = playlist != null;
                 MediaWrapper[] tracks;
@@ -163,7 +163,9 @@ public class SavePlaylistDialog extends DialogFragment implements View.OnClickLi
                         playlist.remove(mw.getId());
                     tracks = mTracks;
                 }
-                LinkedList<Long> ids = new LinkedList<>();
+                if (tracks == null)
+                    return;
+                final LinkedList<Long> ids = new LinkedList<>();
                 for (MediaWrapper mw : tracks) {
                     long id = mw.getId();
                     if (id == 0) {



More information about the Android mailing list