Commit 6e9637f8 authored by Geoffrey Métais's avatar Geoffrey Métais

Use specific dialog for playlist deletion

Fixes #14357  Common delete dialog was deleting provided path anyway
parent d22a1060
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
<string name="set_song">Set as ringtone</string> <string name="set_song">Set as ringtone</string>
<string name="info">Information</string> <string name="info">Information</string>
<string name="confirm_delete">Delete the file \'%1$s\'?</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_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="ringtone_error">An error occurred while setting the ringtone.</string>
<string name="pause">Pause</string> <string name="pause">Pause</string>
......
...@@ -64,6 +64,23 @@ public class CommonDialogs { ...@@ -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, public static AlertDialog confirmDialog(final Context context,
final String confirmationString, final String confirmationString,
final DialogInterface.OnClickListener callback) { final DialogInterface.OnClickListener callback) {
......
...@@ -437,14 +437,13 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR ...@@ -437,14 +437,13 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
List<MediaWrapper> mediaList = adapter.getMedias(groupPosition); List<MediaWrapper> mediaList = adapter.getMedias(groupPosition);
if (adapter.getCount() <= groupPosition || mediaList == null || mediaList.isEmpty()) if (adapter.getCount() <= groupPosition || mediaList == null || mediaList.isEmpty())
return false; return false;
AlertDialog alertDialog = CommonDialogs.deleteMedia( AlertDialog alertDialog = CommonDialogs.deletePlaylist(
getActivity(), getActivity(),
mediaList.get(0).getLocation(),
adapter.getItem(groupPosition).mTitle, adapter.getItem(groupPosition).mTitle,
new VLCRunnable(adapter.getItem(groupPosition)) { new VLCRunnable(adapter.getItem(groupPosition)) {
@Override @Override
public void run(Object o) { public void run(Object o) {
AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem)o; AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem) o;
if (!MediaDatabase.getInstance().playlistExists(listItem.mTitle)) { if (!MediaDatabase.getInstance().playlistExists(listItem.mTitle)) {
MediaWrapper media = listItem.mMediaList.get(0); MediaWrapper media = listItem.mMediaList.get(0);
mMediaLibrary.getMediaItems().remove(media); mMediaLibrary.getMediaItems().remove(media);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment