@@ -243,7 +243,7 @@ public void onServiceConnected(final Player connectedPlayer,
243243 // It will do nothing if the player is not in fullscreen mode
244244 hideSystemUiIfNeeded ();
245245
246- final Optional <MainPlayerUi > playerUi = player .UIs ().get (MainPlayerUi .class );
246+ final Optional <MainPlayerUi > playerUi = player .UIs ().getOpt (MainPlayerUi .class );
247247 if (!player .videoPlayerSelected () && !playAfterConnect ) {
248248 return ;
249249 }
@@ -519,7 +519,7 @@ private void setOnClickListeners() {
519519 binding .overlayPlayPauseButton .setOnClickListener (v -> {
520520 if (playerIsNotStopped ()) {
521521 player .playPause ();
522- player .UIs ().get (VideoPlayerUi .class ).ifPresent (ui -> ui .hideControls (0 , 0 ));
522+ player .UIs ().getOpt (VideoPlayerUi .class ).ifPresent (ui -> ui .hideControls (0 , 0 ));
523523 showSystemUi ();
524524 } else {
525525 autoPlayEnabled = true ; // forcefully start playing
@@ -678,7 +678,7 @@ protected void initListeners() {
678678 @ Override
679679 public boolean onKeyDown (final int keyCode ) {
680680 return isPlayerAvailable ()
681- && player .UIs ().get (VideoPlayerUi .class )
681+ && player .UIs ().getOpt (VideoPlayerUi .class )
682682 .map (playerUi -> playerUi .onKeyDown (keyCode )).orElse (false );
683683 }
684684
@@ -1018,7 +1018,7 @@ private void toggleFullscreenIfInFullscreenMode() {
10181018 // If a user watched video inside fullscreen mode and than chose another player
10191019 // return to non-fullscreen mode
10201020 if (isPlayerAvailable ()) {
1021- player .UIs ().get (MainPlayerUi .class ).ifPresent (playerUi -> {
1021+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (playerUi -> {
10221022 if (playerUi .isFullscreen ()) {
10231023 playerUi .toggleFullscreen ();
10241024 }
@@ -1234,7 +1234,7 @@ private void tryAddVideoPlayerView() {
12341234 // setup the surface view height, so that it fits the video correctly
12351235 setHeightThumbnail ();
12361236
1237- player .UIs ().get (MainPlayerUi .class ).ifPresent (playerUi -> {
1237+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (playerUi -> {
12381238 // sometimes binding would be null here, even though getView() != null above u.u
12391239 if (binding != null ) {
12401240 // prevent from re-adding a view multiple times
@@ -1250,7 +1250,7 @@ private void removeVideoPlayerView() {
12501250 makeDefaultHeightForVideoPlaceholder ();
12511251
12521252 if (player != null ) {
1253- player .UIs ().get (VideoPlayerUi .class ).ifPresent (VideoPlayerUi ::removeViewFromParent );
1253+ player .UIs ().getOpt (VideoPlayerUi .class ).ifPresent (VideoPlayerUi ::removeViewFromParent );
12541254 }
12551255 }
12561256
@@ -1317,7 +1317,7 @@ private void setHeightThumbnail(final int newHeight, final DisplayMetrics metric
13171317 binding .detailThumbnailImageView .setMinimumHeight (newHeight );
13181318 if (isPlayerAvailable ()) {
13191319 final int maxHeight = (int ) (metrics .heightPixels * MAX_PLAYER_HEIGHT );
1320- player .UIs ().get (VideoPlayerUi .class ).ifPresent (ui ->
1320+ player .UIs ().getOpt (VideoPlayerUi .class ).ifPresent (ui ->
13211321 ui .getBinding ().surfaceView .setHeights (newHeight ,
13221322 ui .isFullscreen () ? newHeight : maxHeight ));
13231323 }
@@ -1848,7 +1848,7 @@ public void onServiceStopped() {
18481848 public void onFullscreenStateChanged (final boolean fullscreen ) {
18491849 setupBrightness ();
18501850 if (!isPlayerAndPlayerServiceAvailable ()
1851- || player .UIs ().get (MainPlayerUi .class ).isEmpty ()
1851+ || player .UIs ().getOpt (MainPlayerUi .class ).isEmpty ()
18521852 || getRoot ().map (View ::getParent ).isEmpty ()) {
18531853 return ;
18541854 }
@@ -1877,7 +1877,7 @@ public void onScreenRotationButtonClicked() {
18771877 final boolean isLandscape = DeviceUtils .isLandscape (requireContext ());
18781878 if (DeviceUtils .isTablet (activity )
18791879 && (!globalScreenOrientationLocked (activity ) || isLandscape )) {
1880- player .UIs ().get (MainPlayerUi .class ).ifPresent (MainPlayerUi ::toggleFullscreen );
1880+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (MainPlayerUi ::toggleFullscreen );
18811881 return ;
18821882 }
18831883
@@ -1977,7 +1977,7 @@ public void hideSystemUiIfNeeded() {
19771977 }
19781978
19791979 private boolean isFullscreen () {
1980- return isPlayerAvailable () && player .UIs ().get (VideoPlayerUi .class )
1980+ return isPlayerAvailable () && player .UIs ().getOpt (VideoPlayerUi .class )
19811981 .map (VideoPlayerUi ::isFullscreen ).orElse (false );
19821982 }
19831983
@@ -2054,7 +2054,7 @@ private void checkLandscape() {
20542054 setAutoPlay (true );
20552055 }
20562056
2057- player .UIs ().get (MainPlayerUi .class ).ifPresent (MainPlayerUi ::checkLandscape );
2057+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (MainPlayerUi ::checkLandscape );
20582058 // Let's give a user time to look at video information page if video is not playing
20592059 if (globalScreenOrientationLocked (activity ) && !player .isPlaying ()) {
20602060 player .play ();
@@ -2319,7 +2319,7 @@ && isPlayerAvailable()
23192319 && player .isPlaying ()
23202320 && !isFullscreen ()
23212321 && !DeviceUtils .isTablet (activity )) {
2322- player .UIs ().get (MainPlayerUi .class )
2322+ player .UIs ().getOpt (MainPlayerUi .class )
23232323 .ifPresent (MainPlayerUi ::toggleFullscreen );
23242324 }
23252325 setOverlayLook (binding .appBarLayout , behavior , 1 );
@@ -2333,7 +2333,7 @@ && isPlayerAvailable()
23332333 // Re-enable clicks
23342334 setOverlayElementsClickable (true );
23352335 if (isPlayerAvailable ()) {
2336- player .UIs ().get (MainPlayerUi .class )
2336+ player .UIs ().getOpt (MainPlayerUi .class )
23372337 .ifPresent (MainPlayerUi ::closeItemsList );
23382338 }
23392339 setOverlayLook (binding .appBarLayout , behavior , 0 );
@@ -2344,7 +2344,7 @@ && isPlayerAvailable()
23442344 showSystemUi ();
23452345 }
23462346 if (isPlayerAvailable ()) {
2347- player .UIs ().get (MainPlayerUi .class ).ifPresent (ui -> {
2347+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (ui -> {
23482348 if (ui .isControlsVisible ()) {
23492349 ui .hideControls (0 , 0 );
23502350 }
@@ -2441,7 +2441,7 @@ boolean isPlayerAndPlayerServiceAvailable() {
24412441
24422442 public Optional <View > getRoot () {
24432443 return Optional .ofNullable (player )
2444- .flatMap (player1 -> player1 .UIs ().get (VideoPlayerUi .class ))
2444+ .flatMap (player1 -> player1 .UIs ().getOpt (VideoPlayerUi .class ))
24452445 .map (playerUi -> playerUi .getBinding ().getRoot ());
24462446 }
24472447
0 commit comments