From 5b2d502f8914df2777f24593d83718efbcdac906 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 10 Apr 2023 13:34:19 +0200 Subject: [PATCH] Fix crashes in downloads fragment --- .../com/github/libretube/ui/fragments/DownloadsFragment.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/DownloadsFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/DownloadsFragment.kt index 6b8a2e6bf..e84691cd6 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/DownloadsFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/DownloadsFragment.kt @@ -113,6 +113,7 @@ class DownloadsFragment : Fragment() { object : RecyclerView.AdapterDataObserver() { override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) { super.onItemRangeRemoved(positionStart, itemCount) + val binding = _binding ?: return if (binding.downloads.adapter?.itemCount == 0) { binding.downloads.visibility = View.GONE binding.downloadsEmpty.visibility = View.VISIBLE @@ -150,7 +151,7 @@ class DownloadsFragment : Fragment() { val index = downloads.indexOfFirst { it.downloadItems.any { item -> item.id == id } } - val view = binding.downloads.findViewHolderForAdapterPosition(index) as? DownloadsViewHolder + val view = _binding?.downloads?.findViewHolderForAdapterPosition(index) as? DownloadsViewHolder view?.binding?.apply { when (status) {