[Android] Use specific dialog for playlist deletion

Geoffrey Métais git at videolan.org
Wed May 13 17:15:12 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed May 13 17:14:05 2015 +0200| [6e9637f800f76a2a0f4fe4c91cf40b23911dda3a] | committer: Geoffrey Métais

Use specific dialog for playlist deletion

Fixes #14357  Common delete dialog was deleting provided path anyway

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=6e9637f800f76a2a0f4fe4c91cf40b23911dda3a
---

 vlc-android/res/values/strings.xml                    |    1 +
 .../src/org/videolan/vlc/gui/CommonDialogs.java       |   17 +++++++++++++++++
 .../videolan/vlc/gui/audio/AudioBrowserFragment.java  |    5 ++---
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 4399e0b..6645373 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -37,6 +37,7 @@
     <string name="set_song">Set as ringtone</string>
     <string name="info">Information</string>
     <string name="confirm_delete">Delete the file \'%1$s\'?</string>
+    <string name="confirm_delete_playlist">Delete playlist \'%1$s\'?</string>
     <string name="ringtone_set">The file \'%1$s\' was set as the ringtone.</string>
     <string name="ringtone_error">An error occurred while setting the ringtone.</string>
     <string name="pause">Pause</string>
diff --git a/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java b/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java
index 68863a4..56b1cb8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java
+++ b/vlc-android/src/org/videolan/vlc/gui/CommonDialogs.java
@@ -64,6 +64,23 @@ public class CommonDialogs {
                 });
     }
 
+    public static AlertDialog deletePlaylist(final Context context,
+                                          final String name,
+                                          final VLCRunnable runnable) {
+
+        return confirmDialog(
+                context,
+                context.getResources().getString(R.string.confirm_delete_playlist,
+                        name),
+                new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int whichButton) {
+                        if (runnable != null)
+                            runnable.run();
+                    }
+                });
+    }
+
     public static AlertDialog confirmDialog(final Context context,
             final String confirmationString,
             final DialogInterface.OnClickListener callback) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index fee060f..2fcfa26 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -437,14 +437,13 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
             List<MediaWrapper> mediaList = adapter.getMedias(groupPosition);
             if (adapter.getCount() <= groupPosition || mediaList == null || mediaList.isEmpty())
                 return false;
-            AlertDialog alertDialog = CommonDialogs.deleteMedia(
+            AlertDialog alertDialog = CommonDialogs.deletePlaylist(
                     getActivity(),
-                    mediaList.get(0).getLocation(),
                     adapter.getItem(groupPosition).mTitle,
                     new VLCRunnable(adapter.getItem(groupPosition)) {
                         @Override
                         public void run(Object o) {
-                            AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem)o;
+                            AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem) o;
                             if (!MediaDatabase.getInstance().playlistExists(listItem.mTitle)) {
                                 MediaWrapper media = listItem.mMediaList.get(0);
                                 mMediaLibrary.getMediaItems().remove(media);



More information about the Android mailing list