@@ -244,7 +244,7 @@ public void onServiceConnected(final PlayerService connectedPlayerService,
244244 // It will do nothing if the player is not in fullscreen mode
245245 hideSystemUiIfNeeded ();
246246
247- final Optional <MainPlayerUi > playerUi = player .UIs ().get (MainPlayerUi .class );
247+ final Optional <MainPlayerUi > playerUi = player .UIs ().getOpt (MainPlayerUi .class );
248248 if (!player .videoPlayerSelected () && !playAfterConnect ) {
249249 return ;
250250 }
@@ -520,7 +520,7 @@ private void setOnClickListeners() {
520520 binding .overlayPlayPauseButton .setOnClickListener (v -> {
521521 if (playerIsNotStopped ()) {
522522 player .playPause ();
523- player .UIs ().get (VideoPlayerUi .class ).ifPresent (ui -> ui .hideControls (0 , 0 ));
523+ player .UIs ().getOpt (VideoPlayerUi .class ).ifPresent (ui -> ui .hideControls (0 , 0 ));
524524 showSystemUi ();
525525 } else {
526526 autoPlayEnabled = true ; // forcefully start playing
@@ -679,7 +679,7 @@ protected void initListeners() {
679679 @ Override
680680 public boolean onKeyDown (final int keyCode ) {
681681 return isPlayerAvailable ()
682- && player .UIs ().get (VideoPlayerUi .class )
682+ && player .UIs ().getOpt (VideoPlayerUi .class )
683683 .map (playerUi -> playerUi .onKeyDown (keyCode )).orElse (false );
684684 }
685685
@@ -1019,7 +1019,7 @@ private void toggleFullscreenIfInFullscreenMode() {
10191019 // If a user watched video inside fullscreen mode and than chose another player
10201020 // return to non-fullscreen mode
10211021 if (isPlayerAvailable ()) {
1022- player .UIs ().get (MainPlayerUi .class ).ifPresent (playerUi -> {
1022+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (playerUi -> {
10231023 if (playerUi .isFullscreen ()) {
10241024 playerUi .toggleFullscreen ();
10251025 }
@@ -1235,7 +1235,7 @@ private void tryAddVideoPlayerView() {
12351235 // setup the surface view height, so that it fits the video correctly
12361236 setHeightThumbnail ();
12371237
1238- player .UIs ().get (MainPlayerUi .class ).ifPresent (playerUi -> {
1238+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (playerUi -> {
12391239 // sometimes binding would be null here, even though getView() != null above u.u
12401240 if (binding != null ) {
12411241 // prevent from re-adding a view multiple times
@@ -1251,7 +1251,7 @@ private void removeVideoPlayerView() {
12511251 makeDefaultHeightForVideoPlaceholder ();
12521252
12531253 if (player != null ) {
1254- player .UIs ().get (VideoPlayerUi .class ).ifPresent (VideoPlayerUi ::removeViewFromParent );
1254+ player .UIs ().getOpt (VideoPlayerUi .class ).ifPresent (VideoPlayerUi ::removeViewFromParent );
12551255 }
12561256 }
12571257
@@ -1318,7 +1318,7 @@ private void setHeightThumbnail(final int newHeight, final DisplayMetrics metric
13181318 binding .detailThumbnailImageView .setMinimumHeight (newHeight );
13191319 if (isPlayerAvailable ()) {
13201320 final int maxHeight = (int ) (metrics .heightPixels * MAX_PLAYER_HEIGHT );
1321- player .UIs ().get (VideoPlayerUi .class ).ifPresent (ui ->
1321+ player .UIs ().getOpt (VideoPlayerUi .class ).ifPresent (ui ->
13221322 ui .getBinding ().surfaceView .setHeights (newHeight ,
13231323 ui .isFullscreen () ? newHeight : maxHeight ));
13241324 }
@@ -1851,7 +1851,7 @@ public void onServiceStopped() {
18511851 public void onFullscreenStateChanged (final boolean fullscreen ) {
18521852 setupBrightness ();
18531853 if (!isPlayerAndPlayerServiceAvailable ()
1854- || player .UIs ().get (MainPlayerUi .class ).isEmpty ()
1854+ || player .UIs ().getOpt (MainPlayerUi .class ).isEmpty ()
18551855 || getRoot ().map (View ::getParent ).isEmpty ()) {
18561856 return ;
18571857 }
@@ -1880,7 +1880,7 @@ public void onScreenRotationButtonClicked() {
18801880 final boolean isLandscape = DeviceUtils .isLandscape (requireContext ());
18811881 if (DeviceUtils .isTablet (activity )
18821882 && (!globalScreenOrientationLocked (activity ) || isLandscape )) {
1883- player .UIs ().get (MainPlayerUi .class ).ifPresent (MainPlayerUi ::toggleFullscreen );
1883+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (MainPlayerUi ::toggleFullscreen );
18841884 return ;
18851885 }
18861886
@@ -1980,7 +1980,7 @@ public void hideSystemUiIfNeeded() {
19801980 }
19811981
19821982 private boolean isFullscreen () {
1983- return isPlayerAvailable () && player .UIs ().get (VideoPlayerUi .class )
1983+ return isPlayerAvailable () && player .UIs ().getOpt (VideoPlayerUi .class )
19841984 .map (VideoPlayerUi ::isFullscreen ).orElse (false );
19851985 }
19861986
@@ -2057,7 +2057,7 @@ private void checkLandscape() {
20572057 setAutoPlay (true );
20582058 }
20592059
2060- player .UIs ().get (MainPlayerUi .class ).ifPresent (MainPlayerUi ::checkLandscape );
2060+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (MainPlayerUi ::checkLandscape );
20612061 // Let's give a user time to look at video information page if video is not playing
20622062 if (globalScreenOrientationLocked (activity ) && !player .isPlaying ()) {
20632063 player .play ();
@@ -2322,7 +2322,7 @@ && isPlayerAvailable()
23222322 && player .isPlaying ()
23232323 && !isFullscreen ()
23242324 && !DeviceUtils .isTablet (activity )) {
2325- player .UIs ().get (MainPlayerUi .class )
2325+ player .UIs ().getOpt (MainPlayerUi .class )
23262326 .ifPresent (MainPlayerUi ::toggleFullscreen );
23272327 }
23282328 setOverlayLook (binding .appBarLayout , behavior , 1 );
@@ -2336,7 +2336,7 @@ && isPlayerAvailable()
23362336 // Re-enable clicks
23372337 setOverlayElementsClickable (true );
23382338 if (isPlayerAvailable ()) {
2339- player .UIs ().get (MainPlayerUi .class )
2339+ player .UIs ().getOpt (MainPlayerUi .class )
23402340 .ifPresent (MainPlayerUi ::closeItemsList );
23412341 }
23422342 setOverlayLook (binding .appBarLayout , behavior , 0 );
@@ -2347,7 +2347,7 @@ && isPlayerAvailable()
23472347 showSystemUi ();
23482348 }
23492349 if (isPlayerAvailable ()) {
2350- player .UIs ().get (MainPlayerUi .class ).ifPresent (ui -> {
2350+ player .UIs ().getOpt (MainPlayerUi .class ).ifPresent (ui -> {
23512351 if (ui .isControlsVisible ()) {
23522352 ui .hideControls (0 , 0 );
23532353 }
@@ -2444,7 +2444,7 @@ boolean isPlayerAndPlayerServiceAvailable() {
24442444
24452445 public Optional <View > getRoot () {
24462446 return Optional .ofNullable (player )
2447- .flatMap (player1 -> player1 .UIs ().get (VideoPlayerUi .class ))
2447+ .flatMap (player1 -> player1 .UIs ().getOpt (VideoPlayerUi .class ))
24482448 .map (playerUi -> playerUi .getBinding ().getRoot ());
24492449 }
24502450
0 commit comments