From d2d52da717c78ddc31c8f5d47dd898e1e67e6e0f Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Mon, 7 Feb 2022 20:04:40 +0100 Subject: [PATCH] Fix crash in TimelineFragment (#2317) --- .../tusky/components/timeline/TimelineFragment.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineFragment.kt index e10f21466..9a932e4c9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineFragment.kt @@ -208,9 +208,11 @@ class TimelineFragment : override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { if (positionStart == 0 && adapter.itemCount != itemCount) { binding.recyclerView.post { - if (isSwipeToRefreshEnabled) { - binding.recyclerView.scrollBy(0, Utils.dpToPx(requireContext(), -30)) - } else binding.recyclerView.scrollToPosition(0) + if (getView() != null) { + if (isSwipeToRefreshEnabled) { + binding.recyclerView.scrollBy(0, Utils.dpToPx(requireContext(), -30)) + } else binding.recyclerView.scrollToPosition(0) + } } } }