From e9228122364abb02a1caaa99a8e209ad641509b5 Mon Sep 17 00:00:00 2001 From: nift4 Date: Fri, 24 May 2024 12:29:38 +0200 Subject: [PATCH] fix #182 --- .../gramophone/ui/components/FullBottomSheet.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/org/akanework/gramophone/ui/components/FullBottomSheet.kt b/app/src/main/kotlin/org/akanework/gramophone/ui/components/FullBottomSheet.kt index 355d09e68..1229f1c56 100644 --- a/app/src/main/kotlin/org/akanework/gramophone/ui/components/FullBottomSheet.kt +++ b/app/src/main/kotlin/org/akanework/gramophone/ui/components/FullBottomSheet.kt @@ -1147,7 +1147,7 @@ class FullBottomSheet(context: Context, attrs: AttributeSet?, defStyleAttr: Int, private class PlaylistCardAdapter( - private val playlist: MutableList>, + private var playlist: MutableList>, private val activity: MainActivity ) : MyRecyclerView.Adapter() { @@ -1174,12 +1174,13 @@ class FullBottomSheet(context: Context, attrs: AttributeSet?, defStyleAttr: Int, crossfade(true) error(R.drawable.ic_default_cover) } - holder.closeButton.setOnClickListener { - ViewCompat.performHapticFeedback(it, HapticFeedbackConstantsCompat.CONTEXT_CLICK) + holder.closeButton.setOnClickListener { v -> + ViewCompat.performHapticFeedback(v, HapticFeedbackConstantsCompat.CONTEXT_CLICK) val instance = activity.getPlayer() val pos = holder.bindingAdapterPosition instance?.removeMediaItem(playlist[pos].first) - playlist.removeAt(pos) + val idx = playlist.removeAt(pos).first + playlist = playlist.map { it.copy(first = if (it.first > idx) it.first - 1 else it.first) }.toMutableList() notifyItemRemoved(pos) } holder.itemView.setOnClickListener {