[Android] Playlist: fix delete in search

Duncan McNamara git at videolan.org
Tue Aug 30 06:25:42 UTC 2022


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Tue Aug 16 15:51:41 2022 +0200| [6d9b81d1a7e007a67da01fb4856147b6278501d2] | committer: Nicolas Pomepuy

Playlist: fix delete in search

To delete a playlist track requires it's position in the playlist.
When deleting from results of a search it will use the position in the
search results for deletion, and not the position in the playlist,
deleting the wrong track. This just get's the index in the playlist
tracks from media before deleting.

Fixes #2652

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

 .../vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
index 85b59146b..d421ba0b8 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/HeaderMediaListActivity.kt
@@ -476,8 +476,9 @@ open class HeaderMediaListActivity : AudioPlayerContainerActivity(), IEventsHand
             val tracks = withContext(Dispatchers.IO) { playlist.tracks }
             withContext(Dispatchers.IO) {
                 for ((index, playlistIndex) in indexes.sortedBy { it }.withIndex()) {
-                    itemsRemoved[playlistIndex] = tracks[playlistIndex].id
-                    playlist.remove(playlistIndex - index)
+                    val trueIndex = viewModel.playlist.tracks.indexOf(list[index])
+                    itemsRemoved[trueIndex] = tracks[playlistIndex].id
+                    playlist.remove(trueIndex)
                 }
             }
             var removedMessage = if (indexes.size>1) getString(R.string.removed_from_playlist_anonymous) else getString(R.string.remove_playlist_item,list.first().title)



More information about the Android mailing list