@@ -1060,12 +1060,11 @@ private void buildQualityMenu() {
10601060 qualityPopupMenu .getMenu ().add (POPUP_MENU_ID_QUALITY , i , Menu .NONE , MediaFormat
10611061 .getNameById (videoStream .getFormatId ()) + " " + videoStream .getResolution ());
10621062 }
1063- final VideoStream selectedVideoStream = player .getSelectedVideoStream ();
1064- if (selectedVideoStream != null ) {
1065- binding .qualityTextView .setText (selectedVideoStream .getResolution ());
1066- }
10671063 qualityPopupMenu .setOnMenuItemClickListener (this );
10681064 qualityPopupMenu .setOnDismissListener (this );
1065+
1066+ player .getSelectedVideoStream ()
1067+ .ifPresent (s -> binding .qualityTextView .setText (s .getResolution ()));
10691068 }
10701069
10711070 private void buildPlaybackSpeedMenu () {
@@ -1171,12 +1170,9 @@ private void onQualityClicked() {
11711170 qualityPopupMenu .show ();
11721171 isSomePopupMenuVisible = true ;
11731172
1174- final VideoStream videoStream = player .getSelectedVideoStream ();
1175- if (videoStream != null ) {
1176- //noinspection SetTextI18n
1177- binding .qualityTextView .setText (MediaFormat .getNameById (videoStream .getFormatId ())
1178- + " " + videoStream .getResolution ());
1179- }
1173+ player .getSelectedVideoStream ()
1174+ .map (s -> MediaFormat .getNameById (s .getFormatId ()) + " " + s .getResolution ())
1175+ .ifPresent (binding .qualityTextView ::setText );
11801176 }
11811177
11821178 /**
@@ -1232,10 +1228,9 @@ public void onDismiss(@Nullable final PopupMenu menu) {
12321228 Log .d (TAG , "onDismiss() called with: menu = [" + menu + "]" );
12331229 }
12341230 isSomePopupMenuVisible = false ; //TODO check if this works
1235- final VideoStream selectedVideoStream = player .getSelectedVideoStream ();
1236- if (selectedVideoStream != null ) {
1237- binding .qualityTextView .setText (selectedVideoStream .getResolution ());
1238- }
1231+ player .getSelectedVideoStream ()
1232+ .ifPresent (s -> binding .qualityTextView .setText (s .getResolution ()));
1233+
12391234 if (player .isPlaying ()) {
12401235 hideControls (DEFAULT_CONTROLS_DURATION , 0 );
12411236 hideSystemUIIfNeeded ();
0 commit comments