From 81fb44c45c8acf6d235e8afff31f348bccf8e2b7 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Thu, 21 Jul 2022 06:56:51 +0530 Subject: [PATCH 1/2] Remove uses of setBottomSheetCallback(). --- .../fragments/detail/VideoDetailFragment.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 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 f4838482b..4ad270c50 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 @@ -208,6 +208,8 @@ public final class VideoDetailFragment private Player player; private final PlayerHolder playerHolder = PlayerHolder.getInstance(); + private BottomSheetBehavior.BottomSheetCallback bottomSheetCallback; + /*////////////////////////////////////////////////////////////////////////// // Service management //////////////////////////////////////////////////////////////////////////*/ @@ -386,7 +388,7 @@ public final class VideoDetailFragment disposables.clear(); positionSubscriber = null; currentWorker = null; - bottomSheetBehavior.setBottomSheetCallback(null); + bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallback); if (activity.isFinishing()) { playQueue = null; @@ -2289,7 +2291,7 @@ public final class VideoDetailFragment } } - bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { + bottomSheetCallback = new BottomSheetBehavior.BottomSheetCallback() { @Override public void onStateChanged(@NonNull final View bottomSheet, final int newState) { bottomSheetState = newState; @@ -2343,12 +2345,14 @@ public final class VideoDetailFragment } if (isPlayerAvailable()) { player.UIs().get(MainPlayerUi.class).ifPresent(ui -> { - if (ui.isControlsVisible()) { - ui.hideControls(0, 0); - } + if (ui.isControlsVisible()) { + ui.hideControls(0, 0); + } }); } break; + case BottomSheetBehavior.STATE_HALF_EXPANDED: + break; } } @@ -2356,7 +2360,9 @@ public final class VideoDetailFragment public void onSlide(@NonNull final View bottomSheet, final float slideOffset) { setOverlayLook(binding.appBarLayout, behavior, slideOffset); } - }); + }; + + bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallback); // User opened a new page and the player will hide itself activity.getSupportFragmentManager().addOnBackStackChangedListener(() -> { From 8a896114c110ba4fb6441465fbb88317e597666f Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Mon, 1 Aug 2022 08:25:24 +0530 Subject: [PATCH 2/2] Apply code review change. --- .../schabi/newpipe/fragments/detail/VideoDetailFragment.java | 3 +-- 1 file changed, 1 insertion(+), 2 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 4ad270c50..9d13cb931 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 @@ -192,6 +192,7 @@ public final class VideoDetailFragment private Disposable positionSubscriber = null; private BottomSheetBehavior bottomSheetBehavior; + private BottomSheetBehavior.BottomSheetCallback bottomSheetCallback; private BroadcastReceiver broadcastReceiver; /*////////////////////////////////////////////////////////////////////////// @@ -208,8 +209,6 @@ public final class VideoDetailFragment private Player player; private final PlayerHolder playerHolder = PlayerHolder.getInstance(); - private BottomSheetBehavior.BottomSheetCallback bottomSheetCallback; - /*////////////////////////////////////////////////////////////////////////// // Service management //////////////////////////////////////////////////////////////////////////*/