From 0a05534c848a5b32d67ce3df7060a037ce686c1c Mon Sep 17 00:00:00 2001 From: Eric Lemieux Date: Mon, 28 Dec 2020 15:20:17 -0500 Subject: [PATCH] Fix null pointer exception in play button method When the play queue was null, and this method was called a null pointer exception would be thrown. This change adds an additional check to see if the play queue is not null before making additional changes. --- .../newpipe/player/VideoPlayerImpl.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index a304b4430..06cbcd780 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -1071,11 +1071,25 @@ public class VideoPlayerImpl extends VideoPlayer private void animatePlayButtons(final boolean show, final int duration) { animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, show, duration); - if (playQueue.getIndex() > 0 || !show) { - animateView(playPreviousButton, AnimationUtils.Type.SCALE_AND_ALPHA, show, duration); + + boolean showQueueButtons = show; + if (playQueue == null) { + showQueueButtons = false; } - if (playQueue.getIndex() + 1 < playQueue.getStreams().size() || !show) { - animateView(playNextButton, AnimationUtils.Type.SCALE_AND_ALPHA, show, duration); + + if (!showQueueButtons || playQueue.getIndex() > 0) { + animateView( + playPreviousButton, + AnimationUtils.Type.SCALE_AND_ALPHA, + showQueueButtons, + duration); + } + if (!showQueueButtons || playQueue.getIndex() + 1 < playQueue.getStreams().size()) { + animateView( + playNextButton, + AnimationUtils.Type.SCALE_AND_ALPHA, + showQueueButtons, + duration); } }