1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00

Merge pull request #9109 from TeamNewPipe/fix/overlayPlayQueueButton

Hide play queue button in VideoDetailsFragment when queue is empty
This commit is contained in:
Stypox 2022-11-05 20:28:14 +01:00 committed by GitHub
commit 9472c36cbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -248,6 +248,7 @@ public final class VideoDetailFragment
autoPlayEnabled = true; // forcefully start playing autoPlayEnabled = true; // forcefully start playing
openVideoPlayerAutoFullscreen(); openVideoPlayerAutoFullscreen();
} }
updateOverlayPlayQueueButtonVisibility();
} }
@Override @Override
@ -337,6 +338,8 @@ public final class VideoDetailFragment
activity.sendBroadcast(new Intent(ACTION_VIDEO_FRAGMENT_RESUMED)); activity.sendBroadcast(new Intent(ACTION_VIDEO_FRAGMENT_RESUMED));
updateOverlayPlayQueueButtonVisibility();
setupBrightness(); setupBrightness();
if (tabSettingsChanged) { if (tabSettingsChanged) {
@ -1820,6 +1823,14 @@ public final class VideoDetailFragment
+ title + "], playQueue = [" + playQueue + "]"); + 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. // 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 // 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 // deleted/added items inside Channel/Playlist queue and makes possible to have
@ -1926,6 +1937,7 @@ public final class VideoDetailFragment
currentInfo.getUploaderName(), currentInfo.getUploaderName(),
currentInfo.getThumbnailUrl()); currentInfo.getThumbnailUrl());
} }
updateOverlayPlayQueueButtonVisibility();
} }
@Override @Override
@ -2392,6 +2404,18 @@ public final class VideoDetailFragment
}); });
} }
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, private void updateOverlayData(@Nullable final String overlayTitle,
@Nullable final String uploader, @Nullable final String uploader,
@Nullable final String thumbnailUrl) { @Nullable final String thumbnailUrl) {