Skip to content

Commit 9fab0ec

Browse files
committed
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.
1 parent 6d69451 commit 9fab0ec

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,9 +607,13 @@ class FeedFragment : BaseStateFragment<FeedState>() {
607607
execOnEnd = {
608608
// Disabled animations would result in immediately hiding the button
609609
// after it showed up
610-
if (DeviceUtils.hasAnimationsAnimatorDurationEnabled(context)) {
611-
// Hide the new items-"popup" after 10s
612-
hideNewItemsLoaded(true, 10000)
610+
// Context can be null in some cases, so we have to make sure it is not null in
611+
// order to avoid a NullPointerException
612+
context?.let {
613+
if (DeviceUtils.hasAnimationsAnimatorDurationEnabled(it)) {
614+
// Hide the new items button after 10s
615+
hideNewItemsLoaded(true, 10000)
616+
}
613617
}
614618
}
615619
)

0 commit comments

Comments
 (0)