File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
app/src/main/java/com/github/libretube/ui/adapters Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -52,8 +52,8 @@ class DownloadsAdapter(
5252
5353 @SuppressLint(" SetTextI18n" )
5454 override fun onBindViewHolder (holder : DownloadsViewHolder , position : Int ) {
55- val download = getItem(holder.bindingAdapterPosition).download
56- val items = getItem(holder.bindingAdapterPosition).downloadItems
55+ val downloadWithItems = getItem(holder.bindingAdapterPosition)
56+ val (download, items, _) = downloadWithItems
5757
5858 holder.binding.apply {
5959 fileSize.isVisible = true
@@ -130,7 +130,11 @@ class DownloadsAdapter(
130130 DELETE_DOWNLOAD_REQUEST_KEY ,
131131 activity
132132 ) { _, _ ->
133- showDeleteDialog(root.context, position)
133+ // the position might have changed in the meanwhile if an other item was deleted
134+ // apparently [onBindViewHolder] is only retriggered if the item changes, but
135+ // not if the position changes (which would lead to IndexOutOfBounds here)
136+ val realPosition = currentList.indexOf(downloadWithItems)
137+ showDeleteDialog(root.context, realPosition)
134138 }
135139 DownloadOptionsBottomSheet ()
136140 .apply {
You can’t perform that action at this time.
0 commit comments