diff --git a/app/src/main/java/com/github/libretube/ui/adapters/WatchHistoryAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/WatchHistoryAdapter.kt index efbb50faa..1c3aa6c4e 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/WatchHistoryAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/WatchHistoryAdapter.kt @@ -21,8 +21,9 @@ class WatchHistoryAdapter( RecyclerView.Adapter() { fun removeFromWatchHistory(position: Int) { + val history = watchHistory[position] query { - DatabaseHolder.Database.watchHistoryDao().delete(watchHistory[position]) + DatabaseHolder.Database.watchHistoryDao().delete(history) } watchHistory.removeAt(position) notifyItemRemoved(position) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/WatchHistoryFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/WatchHistoryFragment.kt index 69a06d390..a74fed717 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/WatchHistoryFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/WatchHistoryFragment.kt @@ -89,7 +89,7 @@ class WatchHistoryFragment : BaseFragment() { // observe changes watchHistoryAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { - override fun onChanged() { + override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) { if (watchHistoryAdapter.itemCount == 0) { binding.watchHistoryRecView.visibility = View.GONE binding.historyEmpty.visibility = View.VISIBLE