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 93fecfca2..324ee37a8 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 @@ -742,20 +742,19 @@ public final class VideoDetailFragment && player.getPlayQueue() != null && player.videoPlayerSelected() && player.getPlayQueue().previous()) { - return true; + return true; // no code here, as previous() was used in the if } + // That means that we are on the start of the stack, - // return false to let the MainActivity handle the onBack if (stack.size() <= 1) { restoreDefaultOrientation(); - - return false; + return false; // let MainActivity handle the onBack (e.g. to minimize the mini player) } + // Remove top stack.pop(); // Get stack item from the new top - assert stack.peek() != null; - setupFromHistoryItem(stack.peek()); + setupFromHistoryItem(Objects.requireNonNull(stack.peek())); return true; } @@ -1432,17 +1431,15 @@ public final class VideoDetailFragment //////////////////////////////////////////////////////////////////////////*/ private void restoreDefaultOrientation() { - if (!isPlayerAvailable() || !player.videoPlayerSelected() || activity == null) { - return; + if (isPlayerAvailable() && player.videoPlayerSelected()) { + toggleFullscreenIfInFullscreenMode(); } - toggleFullscreenIfInFullscreenMode(); - // This will show systemUI and pause the player. // User can tap on Play button and video will be in fullscreen mode again // Note for tablet: trying to avoid orientation changes since it's not easy // to physically rotate the tablet every time - if (!DeviceUtils.isTablet(activity)) { + if (activity != null && !DeviceUtils.isTablet(activity)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } }