From f9109ebc81e5c7d9a01b63c4b68d2dc46b030f1c Mon Sep 17 00:00:00 2001 From: Stypox Date: Sun, 28 Aug 2022 18:35:21 +0200 Subject: [PATCH] Use player.getThumbnail() instead of field in VideoPlayerUi --- .../newpipe/player/ui/VideoPlayerUi.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/ui/VideoPlayerUi.java b/app/src/main/java/org/schabi/newpipe/player/ui/VideoPlayerUi.java index a972d2f71..1709755f2 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ui/VideoPlayerUi.java +++ b/app/src/main/java/org/schabi/newpipe/player/ui/VideoPlayerUi.java @@ -109,7 +109,6 @@ public abstract class VideoPlayerUi extends PlayerUi private final Handler controlsVisibilityHandler = new Handler(Looper.getMainLooper()); @Nullable private SurfaceHolderCallback surfaceHolderCallback; boolean surfaceIsSetup = false; - @Nullable private Bitmap thumbnail = null; /*////////////////////////////////////////////////////////////////////////// @@ -385,9 +384,7 @@ public abstract class VideoPlayerUi extends PlayerUi @Override public void destroy() { super.destroy(); - if (binding != null) { - binding.endScreen.setImageBitmap(null); - } + binding.endScreen.setImageDrawable(null); deinitPlayerSeekOverlay(); deinitListeners(); } @@ -422,12 +419,10 @@ public abstract class VideoPlayerUi extends PlayerUi public void onBroadcastReceived(final Intent intent) { super.onBroadcastReceived(intent); if (Intent.ACTION_CONFIGURATION_CHANGED.equals(intent.getAction())) { - // When the orientation changed, the screen height might be smaller. - // If the end screen thumbnail is not re-scaled, - // it can be larger than the current screen height - // and thus enlarging the whole player. - // This causes the seekbar to be ouf the visible area. - updateEndScreenThumbnail(); + // When the orientation changes, the screen height might be smaller. If the end screen + // thumbnail is not re-scaled, it can be larger than the current screen height and thus + // enlarging the whole player. This causes the seekbar to be out of the visible area. + updateEndScreenThumbnail(player.getThumbnail()); } } //endregion @@ -449,11 +444,10 @@ public abstract class VideoPlayerUi extends PlayerUi @Override public void onThumbnailLoaded(@Nullable final Bitmap bitmap) { super.onThumbnailLoaded(bitmap); - thumbnail = bitmap; - updateEndScreenThumbnail(); + updateEndScreenThumbnail(bitmap); } - private void updateEndScreenThumbnail() { + private void updateEndScreenThumbnail(@Nullable final Bitmap thumbnail) { if (thumbnail == null) { // remove end screen thumbnail binding.endScreen.setImageDrawable(null);