Merge pull request #1499 from Bnyro/master

fix crashes when removing recview items
This commit is contained in:
Bnyro 2022-10-05 21:56:16 +02:00 committed by GitHub
commit bdfc8ccf6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 2 deletions

View File

@ -66,6 +66,7 @@ class DownloadsAdapter(
files.removeAt(position) files.removeAt(position)
notifyItemRemoved(position) notifyItemRemoved(position)
notifyItemRangeChanged(position, itemCount)
} }
} }
} }

View File

@ -104,6 +104,7 @@ class PlaylistsAdapter(
playlists.removeAt(position) playlists.removeAt(position)
activity.runOnUiThread { activity.runOnUiThread {
notifyItemRemoved(position) notifyItemRemoved(position)
notifyItemRangeChanged(position, itemCount)
} }
} }
} catch (e: Exception) { } catch (e: Exception) {

View File

@ -32,14 +32,14 @@ class SearchHistoryAdapter(
historyText.text = historyQuery historyText.text = historyQuery
deleteHistory.setOnClickListener { deleteHistory.setOnClickListener {
val itemIndex = historyList.indexOf(historyQuery)
historyList -= historyQuery historyList -= historyQuery
query { query {
Database.searchHistoryDao().delete( Database.searchHistoryDao().delete(
SearchHistoryItem(query = historyQuery) SearchHistoryItem(query = historyQuery)
) )
} }
notifyItemRemoved(itemIndex) notifyItemRemoved(position)
notifyItemRangeChanged(position, itemCount)
} }
root.setOnClickListener { root.setOnClickListener {

View File

@ -24,6 +24,7 @@ class WatchHistoryAdapter(
DatabaseHelper.removeFromWatchHistory(position) DatabaseHelper.removeFromWatchHistory(position)
watchHistory.removeAt(position) watchHistory.removeAt(position)
notifyItemRemoved(position) notifyItemRemoved(position)
notifyItemRangeChanged(position, itemCount)
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WatchHistoryViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WatchHistoryViewHolder {