From 4eddd2c3d1e246d92e8da81e335c3dc10fc1e68c Mon Sep 17 00:00:00 2001 From: Stypox Date: Tue, 19 Jul 2022 20:01:46 +0200 Subject: [PATCH] Fix random NullPointerException when adding video player view --- .../newpipe/fragments/detail/VideoDetailFragment.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 55a6f5d5b..cc8007596 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -1313,9 +1313,11 @@ public final class VideoDetailFragment // Prevent from re-adding a view multiple times new Handler(Looper.getMainLooper()).post(() -> player.UIs().get(MainPlayerUi.class).ifPresent(playerUi -> { - playerUi.removeViewFromParent(); - binding.playerPlaceholder.addView(playerUi.getBinding().getRoot()); - playerUi.setupVideoSurfaceIfNeeded(); + if (binding != null) { + playerUi.removeViewFromParent(); + binding.playerPlaceholder.addView(playerUi.getBinding().getRoot()); + playerUi.setupVideoSurfaceIfNeeded(); + } })); }