Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide play queue button in VideoDetailsFragment when queue is empty #9109

Merged
merged 1 commit into from
Nov 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ && isAutoplayEnabled()
autoPlayEnabled = true; // forcefully start playing
openVideoPlayerAutoFullscreen();
}
updateOverlayPlayQueueButtonVisibility();
}

@Override
Expand Down Expand Up @@ -337,6 +338,8 @@ public void onResume() {

activity.sendBroadcast(new Intent(ACTION_VIDEO_FRAGMENT_RESUMED));

updateOverlayPlayQueueButtonVisibility();

setupBrightness();

if (tabSettingsChanged) {
Expand Down Expand Up @@ -1820,6 +1823,14 @@ public void onQueueUpdate(final PlayQueue queue) {
+ title + "], playQueue = [" + playQueue + "]");
}

// Register broadcast receiver to listen to playQueue changes
// and hide the overlayPlayQueueButton when the playQueue is empty / destroyed.
if (playQueue != null && playQueue.getBroadcastReceiver() != null) {
playQueue.getBroadcastReceiver().subscribe(
event -> updateOverlayPlayQueueButtonVisibility()
);
}

// This should be the only place where we push data to stack.
// It will allow to have live instance of PlayQueue with actual information about
// deleted/added items inside Channel/Playlist queue and makes possible to have
Expand Down Expand Up @@ -1926,6 +1937,7 @@ public void onServiceStopped() {
currentInfo.getUploaderName(),
currentInfo.getThumbnailUrl());
}
updateOverlayPlayQueueButtonVisibility();
}

@Override
Expand Down Expand Up @@ -2392,6 +2404,18 @@ public void onSlide(@NonNull final View bottomSheet, final float slideOffset) {
});
}

private void updateOverlayPlayQueueButtonVisibility() {
final boolean isPlayQueueEmpty =
player == null // no player => no play queue :)
|| player.getPlayQueue() == null
|| player.getPlayQueue().isEmpty();
if (binding != null) {
// binding is null when rotating the device...
binding.overlayPlayQueueButton.setVisibility(
isPlayQueueEmpty ? View.GONE : View.VISIBLE);
}
}

private void updateOverlayData(@Nullable final String overlayTitle,
@Nullable final String uploader,
@Nullable final String thumbnailUrl) {
Expand Down