From 4b32890b5f0c3284c2efa56cf5b7ca3ca59460c3 Mon Sep 17 00:00:00 2001 From: Stypox Date: Thu, 27 Oct 2022 18:45:06 +0200 Subject: [PATCH] Fix random crash in SubscriptionFragment --- .../newpipe/local/subscription/SubscriptionFragment.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt index 151e14cab..4ef289155 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt @@ -422,6 +422,12 @@ class SubscriptionFragment : BaseStateFragment() { feedGroupsSortMenuItem.showSortButton = groups.size > 1 feedGroupsSortMenuItem.listViewMode = listViewMode binding.itemsList.post { + if (context == null) { + // since this part was posted to the next UI cycle, the fragment might have been + // removed in the meantime + return@post + } + feedGroupsCarousel.notifyChanged(FeedGroupCarouselItem.PAYLOAD_UPDATE_LIST_VIEW_MODE) feedGroupsSortMenuItem.notifyChanged(GroupsHeader.PAYLOAD_UPDATE_ICONS)