Use Optional.map correctly and other improvements

This commit is contained in:
Stypox 2023-01-11 14:47:53 +01:00
parent 245406e967
commit 8ea120865c
4 changed files with 19 additions and 23 deletions

View file

@ -255,7 +255,9 @@ public final class VideoDetailFragment
playerUi.ifPresent(MainPlayerUi::toggleFullscreen);
}
if (playAfterConnect || (currentInfo != null && isAutoplayEnabled()
if (playAfterConnect
|| (currentInfo != null
&& isAutoplayEnabled()
&& playerUi.isEmpty())) {
autoPlayEnabled = true; // forcefully start playing
openVideoPlayerAutoFullscreen();
@ -1883,8 +1885,9 @@ public final class VideoDetailFragment
@Override
public void onFullscreenStateChanged(final boolean fullscreen) {
setupBrightness();
if (!isPlayerAndPlayerServiceAvailable() || player.UIs().get(MainPlayerUi.class).isEmpty()
|| getRoot().map(View::getParent).isEmpty()) {
if (!isPlayerAndPlayerServiceAvailable()
|| player.UIs().get(MainPlayerUi.class).isEmpty()
|| getRoot().flatMap(v -> Optional.ofNullable(v.getParent())).isEmpty()) {
return;
}