@@ -246,7 +246,7 @@ public void onPlayerConnected(@NonNull final Player connectedPlayer,
246246 // It will do nothing if the player is not in fullscreen mode
247247 hideSystemUiIfNeeded ();
248248
249- final Optional <MainPlayerUi > playerUi = player .UIs ().get (MainPlayerUi .class );
249+ final Optional <MainPlayerUi > playerUi = player .UIs ().getOpt (MainPlayerUi .class );
250250 if (!player .videoPlayerSelected () && !playAfterConnect ) {
251251 return ;
252252 }
@@ -529,7 +529,7 @@ private void setOnClickListeners() {
529529 binding .overlayPlayPauseButton .setOnClickListener (v -> {
530530 if (playerIsNotStopped ()) {
531531 player .playPause ();
532- player .UIs ().get (VideoPlayerUi .class ).ifPresent (ui -> ui .hideControls (0 , 0 ));
532+ player .UIs ().getOpt (VideoPlayerUi .class ).ifPresent (ui -> ui .hideControls (0 , 0 ));
533533 showSystemUi ();
534534 } else {
535535 autoPlayEnabled = true ; // forcefully start playing
@@ -688,7 +688,7 @@ protected void initListeners() {
688688 @ Override
689689 public boolean onKeyDown (final int keyCode ) {
690690 return isPlayerAvailable ()
691- && player .UIs ().get (VideoPlayerUi .class )
691+ && player .UIs ().getOpt (VideoPlayerUi .class )
692692 .map (playerUi -> playerUi .onKeyDown (keyCode )).orElse (false );
693693 }
694694
@@ -1028,7 +1028,7 @@ private void toggleFullscreenIfInFullscreenMode() {
10281028 // If a user watched video inside fullscreen mode and than chose another player
10291029 // return to non-fullscreen mode
10301030 if (isPlayerAvailable ()) {
1031- player .UIs ().get (MainPlayerUi .class ).ifPresent (playerUi -> {
1031+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (playerUi -> {
10321032 if (playerUi .isFullscreen ()) {
10331033 playerUi .toggleFullscreen ();
10341034 }
@@ -1244,7 +1244,7 @@ private void tryAddVideoPlayerView() {
12441244 // setup the surface view height, so that it fits the video correctly
12451245 setHeightThumbnail ();
12461246
1247- player .UIs ().get (MainPlayerUi .class ).ifPresent (playerUi -> {
1247+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (playerUi -> {
12481248 // sometimes binding would be null here, even though getView() != null above u.u
12491249 if (binding != null ) {
12501250 // prevent from re-adding a view multiple times
@@ -1260,7 +1260,7 @@ private void removeVideoPlayerView() {
12601260 makeDefaultHeightForVideoPlaceholder ();
12611261
12621262 if (player != null ) {
1263- player .UIs ().get (VideoPlayerUi .class ).ifPresent (VideoPlayerUi ::removeViewFromParent );
1263+ player .UIs ().getOpt (VideoPlayerUi .class ).ifPresent (VideoPlayerUi ::removeViewFromParent );
12641264 }
12651265 }
12661266
@@ -1327,7 +1327,7 @@ private void setHeightThumbnail(final int newHeight, final DisplayMetrics metric
13271327 binding .detailThumbnailImageView .setMinimumHeight (newHeight );
13281328 if (isPlayerAvailable ()) {
13291329 final int maxHeight = (int ) (metrics .heightPixels * MAX_PLAYER_HEIGHT );
1330- player .UIs ().get (VideoPlayerUi .class ).ifPresent (ui ->
1330+ player .UIs ().getOpt (VideoPlayerUi .class ).ifPresent (ui ->
13311331 ui .getBinding ().surfaceView .setHeights (newHeight ,
13321332 ui .isFullscreen () ? newHeight : maxHeight ));
13331333 }
@@ -1861,7 +1861,7 @@ public void onServiceStopped() {
18611861 public void onFullscreenStateChanged (final boolean fullscreen ) {
18621862 setupBrightness ();
18631863 if (!isPlayerAndPlayerServiceAvailable ()
1864- || player .UIs ().get (MainPlayerUi .class ).isEmpty ()
1864+ || player .UIs ().getOpt (MainPlayerUi .class ).isEmpty ()
18651865 || getRoot ().map (View ::getParent ).isEmpty ()) {
18661866 return ;
18671867 }
@@ -1890,7 +1890,7 @@ public void onScreenRotationButtonClicked() {
18901890 final boolean isLandscape = DeviceUtils .isLandscape (requireContext ());
18911891 if (DeviceUtils .isTablet (activity )
18921892 && (!globalScreenOrientationLocked (activity ) || isLandscape )) {
1893- player .UIs ().get (MainPlayerUi .class ).ifPresent (MainPlayerUi ::toggleFullscreen );
1893+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (MainPlayerUi ::toggleFullscreen );
18941894 return ;
18951895 }
18961896
@@ -1990,7 +1990,7 @@ public void hideSystemUiIfNeeded() {
19901990 }
19911991
19921992 private boolean isFullscreen () {
1993- return isPlayerAvailable () && player .UIs ().get (VideoPlayerUi .class )
1993+ return isPlayerAvailable () && player .UIs ().getOpt (VideoPlayerUi .class )
19941994 .map (VideoPlayerUi ::isFullscreen ).orElse (false );
19951995 }
19961996
@@ -2067,7 +2067,7 @@ private void checkLandscape() {
20672067 setAutoPlay (true );
20682068 }
20692069
2070- player .UIs ().get (MainPlayerUi .class ).ifPresent (MainPlayerUi ::checkLandscape );
2070+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (MainPlayerUi ::checkLandscape );
20712071 // Let's give a user time to look at video information page if video is not playing
20722072 if (globalScreenOrientationLocked (activity ) && !player .isPlaying ()) {
20732073 player .play ();
@@ -2332,7 +2332,7 @@ && isPlayerAvailable()
23322332 && player .isPlaying ()
23332333 && !isFullscreen ()
23342334 && !DeviceUtils .isTablet (activity )) {
2335- player .UIs ().get (MainPlayerUi .class )
2335+ player .UIs ().getOpt (MainPlayerUi .class )
23362336 .ifPresent (MainPlayerUi ::toggleFullscreen );
23372337 }
23382338 setOverlayLook (binding .appBarLayout , behavior , 1 );
@@ -2346,7 +2346,7 @@ && isPlayerAvailable()
23462346 // Re-enable clicks
23472347 setOverlayElementsClickable (true );
23482348 if (isPlayerAvailable ()) {
2349- player .UIs ().get (MainPlayerUi .class )
2349+ player .UIs ().getOpt (MainPlayerUi .class )
23502350 .ifPresent (MainPlayerUi ::closeItemsList );
23512351 }
23522352 setOverlayLook (binding .appBarLayout , behavior , 0 );
@@ -2357,7 +2357,7 @@ && isPlayerAvailable()
23572357 showSystemUi ();
23582358 }
23592359 if (isPlayerAvailable ()) {
2360- player .UIs ().get (MainPlayerUi .class ).ifPresent (ui -> {
2360+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (ui -> {
23612361 if (ui .isControlsVisible ()) {
23622362 ui .hideControls (0 , 0 );
23632363 }
@@ -2454,7 +2454,7 @@ boolean isPlayerAndPlayerServiceAvailable() {
24542454
24552455 public Optional <View > getRoot () {
24562456 return Optional .ofNullable (player )
2457- .flatMap (player1 -> player1 .UIs ().get (VideoPlayerUi .class ))
2457+ .flatMap (player1 -> player1 .UIs ().getOpt (VideoPlayerUi .class ))
24582458 .map (playerUi -> playerUi .getBinding ().getRoot ());
24592459 }
24602460
0 commit comments