From 01f52ec8805fe36e93b2935f8f0b1e27cddb0b53 Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Wed, 15 Nov 2023 00:37:05 +0100 Subject: [PATCH] Fix crash when setting the masking of the new feed items button if the context is null As the fragment context can be null in some cases, we have to make sure that the context is not null before calling DeviceUtils.hasAnimationsAnimatorDurationEnabled. If the context is null, the button will now not be hidden automatically. --- .../java/org/schabi/newpipe/local/feed/FeedFragment.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt index 83882d35f..0b61f45fb 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt @@ -607,9 +607,13 @@ class FeedFragment : BaseStateFragment() { execOnEnd = { // Disabled animations would result in immediately hiding the button // after it showed up - if (DeviceUtils.hasAnimationsAnimatorDurationEnabled(context)) { - // Hide the new items-"popup" after 10s - hideNewItemsLoaded(true, 10000) + // Context can be null in some cases, so we have to make sure it is not null in + // order to avoid a NullPointerException + context?.let { + if (DeviceUtils.hasAnimationsAnimatorDurationEnabled(it)) { + // Hide the new items button after 10s + hideNewItemsLoaded(true, 10000) + } } } )