mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Avoid setting invalid states to bottom sheet callback
This commit is contained in:
parent
500acce178
commit
ca0f56eea8
@ -180,6 +180,8 @@ public final class VideoDetailFragment
|
|||||||
@State
|
@State
|
||||||
int bottomSheetState = BottomSheetBehavior.STATE_EXPANDED;
|
int bottomSheetState = BottomSheetBehavior.STATE_EXPANDED;
|
||||||
@State
|
@State
|
||||||
|
int lastStableBottomSheetState = BottomSheetBehavior.STATE_EXPANDED;
|
||||||
|
@State
|
||||||
protected boolean autoPlayEnabled = true;
|
protected boolean autoPlayEnabled = true;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -269,7 +271,7 @@ public final class VideoDetailFragment
|
|||||||
|
|
||||||
public static VideoDetailFragment getInstanceInCollapsedState() {
|
public static VideoDetailFragment getInstanceInCollapsedState() {
|
||||||
final VideoDetailFragment instance = new VideoDetailFragment();
|
final VideoDetailFragment instance = new VideoDetailFragment();
|
||||||
instance.bottomSheetState = BottomSheetBehavior.STATE_COLLAPSED;
|
instance.updateBottomSheetState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1170,7 +1172,7 @@ public final class VideoDetailFragment
|
|||||||
// doesn't tell which state it was settling to, and thus the bottom sheet settles to
|
// doesn't tell which state it was settling to, and thus the bottom sheet settles to
|
||||||
// STATE_COLLAPSED. This can be solved by manually setting the state that will be
|
// STATE_COLLAPSED. This can be solved by manually setting the state that will be
|
||||||
// restored (i.e. bottomSheetState) to STATE_EXPANDED.
|
// restored (i.e. bottomSheetState) to STATE_EXPANDED.
|
||||||
bottomSheetState = BottomSheetBehavior.STATE_EXPANDED;
|
updateBottomSheetState(BottomSheetBehavior.STATE_EXPANDED);
|
||||||
// toggle landscape in order to open directly in fullscreen
|
// toggle landscape in order to open directly in fullscreen
|
||||||
onScreenRotationButtonClicked();
|
onScreenRotationButtonClicked();
|
||||||
}
|
}
|
||||||
@ -2284,7 +2286,9 @@ public final class VideoDetailFragment
|
|||||||
|
|
||||||
final FrameLayout bottomSheetLayout = activity.findViewById(R.id.fragment_player_holder);
|
final FrameLayout bottomSheetLayout = activity.findViewById(R.id.fragment_player_holder);
|
||||||
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetLayout);
|
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetLayout);
|
||||||
bottomSheetBehavior.setState(bottomSheetState);
|
bottomSheetBehavior.setState(lastStableBottomSheetState);
|
||||||
|
updateBottomSheetState(lastStableBottomSheetState);
|
||||||
|
|
||||||
final int peekHeight = getResources().getDimensionPixelSize(R.dimen.mini_player_height);
|
final int peekHeight = getResources().getDimensionPixelSize(R.dimen.mini_player_height);
|
||||||
if (bottomSheetState != BottomSheetBehavior.STATE_HIDDEN) {
|
if (bottomSheetState != BottomSheetBehavior.STATE_HIDDEN) {
|
||||||
manageSpaceAtTheBottom(false);
|
manageSpaceAtTheBottom(false);
|
||||||
@ -2300,7 +2304,7 @@ public final class VideoDetailFragment
|
|||||||
bottomSheetCallback = new BottomSheetBehavior.BottomSheetCallback() {
|
bottomSheetCallback = new BottomSheetBehavior.BottomSheetCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onStateChanged(@NonNull final View bottomSheet, final int newState) {
|
public void onStateChanged(@NonNull final View bottomSheet, final int newState) {
|
||||||
bottomSheetState = newState;
|
updateBottomSheetState(newState);
|
||||||
|
|
||||||
switch (newState) {
|
switch (newState) {
|
||||||
case BottomSheetBehavior.STATE_HIDDEN:
|
case BottomSheetBehavior.STATE_HIDDEN:
|
||||||
@ -2441,4 +2445,12 @@ public final class VideoDetailFragment
|
|||||||
return player.UIs().get(VideoPlayerUi.class)
|
return player.UIs().get(VideoPlayerUi.class)
|
||||||
.map(playerUi -> playerUi.getBinding().getRoot());
|
.map(playerUi -> playerUi.getBinding().getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateBottomSheetState(final int newState) {
|
||||||
|
bottomSheetState = newState;
|
||||||
|
if (newState != BottomSheetBehavior.STATE_DRAGGING
|
||||||
|
&& newState != BottomSheetBehavior.STATE_SETTLING) {
|
||||||
|
lastStableBottomSheetState = newState;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user