@@ -69,26 +69,18 @@ public void onSingleTap(@NotNull final MainPlayer.PlayerType playerType) {
6969 if (DEBUG ) {
7070 Log .d (TAG , "onSingleTap called with playerType = [" + player .getPlayerType () + "]" );
7171 }
72- if (playerType == MainPlayer .PlayerType .POPUP ) {
7372
74- if (player .isControlsVisible ()) {
75- player .hideControls (100 , 100 );
76- } else {
77- player .getPlayPauseButton ().requestFocus ();
78- player .showControlsThenHide ();
79- }
80-
81- } else /* playerType == MainPlayer.PlayerType.VIDEO */ {
73+ if (player .isControlsVisible ()) {
74+ player .hideControls (150 , 0 );
75+ return ;
76+ }
77+ // -- Controls are not visible --
8278
83- if (player .isControlsVisible ()) {
84- player .hideControls (150 , 0 );
85- } else {
86- if (player .getCurrentState () == Player .STATE_COMPLETED ) {
87- player .showControls (0 );
88- } else {
89- player .showControlsThenHide ();
90- }
91- }
79+ // When player is completed show controls and don't hide them later
80+ if (player .getCurrentState () == Player .STATE_COMPLETED ) {
81+ player .showControls (0 );
82+ } else {
83+ player .showControlsThenHide ();
9284 }
9385 }
9486
@@ -103,6 +95,8 @@ public void onScroll(@NotNull final MainPlayer.PlayerType playerType,
10395 + player .getPlayerType () + "], portion = [" + portion + "]" );
10496 }
10597 if (playerType == MainPlayer .PlayerType .VIDEO ) {
98+
99+ // -- Brightness and Volume control --
106100 final boolean isBrightnessGestureEnabled =
107101 PlayerHelper .isBrightnessGestureEnabled (service );
108102 final boolean isVolumeGestureEnabled = PlayerHelper .isVolumeGestureEnabled (service );
@@ -121,15 +115,14 @@ public void onScroll(@NotNull final MainPlayer.PlayerType playerType,
121115 }
122116
123117 } else /* MainPlayer.PlayerType.POPUP */ {
118+
119+ // -- Determine if the ClosingOverlayView (red X) has to be shown or hidden --
124120 final View closingOverlayView = player .getClosingOverlayView ();
125- if (player .isInsideClosingRadius (movingEvent )) {
126- if (closingOverlayView .getVisibility () == View .GONE ) {
127- animate (closingOverlayView , true , 200 );
128- }
129- } else {
130- if (closingOverlayView .getVisibility () == View .VISIBLE ) {
131- animate (closingOverlayView , false , 200 );
132- }
121+ final boolean showClosingOverlayView = player .isInsideClosingRadius (movingEvent );
122+ // Check if an view is in expected state and if not animate it into the correct state
123+ final int expectedVisibility = showClosingOverlayView ? View .VISIBLE : View .GONE ;
124+ if (closingOverlayView .getVisibility () != expectedVisibility ) {
125+ animate (closingOverlayView , showClosingOverlayView , 200 );
133126 }
134127 }
135128 }
@@ -210,11 +203,12 @@ public void onScrollEnd(@NotNull final MainPlayer.PlayerType playerType,
210203 Log .d (TAG , "onScrollEnd called with playerType = ["
211204 + player .getPlayerType () + "]" );
212205 }
213- if (playerType == MainPlayer .PlayerType .VIDEO ) {
214- if (DEBUG ) {
215- Log .d (TAG , "onScrollEnd() called" );
216- }
217206
207+ if (player .isControlsVisible () && player .getCurrentState () == STATE_PLAYING ) {
208+ player .hideControls (DEFAULT_CONTROLS_DURATION , DEFAULT_CONTROLS_HIDE_TIME );
209+ }
210+
211+ if (playerType == MainPlayer .PlayerType .VIDEO ) {
218212 if (player .getVolumeRelativeLayout ().getVisibility () == View .VISIBLE ) {
219213 animate (player .getVolumeRelativeLayout (), false , 200 , SCALE_AND_ALPHA ,
220214 200 );
@@ -223,15 +217,7 @@ public void onScrollEnd(@NotNull final MainPlayer.PlayerType playerType,
223217 animate (player .getBrightnessRelativeLayout (), false , 200 , SCALE_AND_ALPHA ,
224218 200 );
225219 }
226-
227- if (player .isControlsVisible () && player .getCurrentState () == STATE_PLAYING ) {
228- player .hideControls (DEFAULT_CONTROLS_DURATION , DEFAULT_CONTROLS_HIDE_TIME );
229- }
230- } else {
231- if (player .isControlsVisible () && player .getCurrentState () == STATE_PLAYING ) {
232- player .hideControls (DEFAULT_CONTROLS_DURATION , DEFAULT_CONTROLS_HIDE_TIME );
233- }
234-
220+ } else /* Popup-Player */ {
235221 if (player .isInsideClosingRadius (event )) {
236222 player .closePopup ();
237223 } else if (!player .isPopupClosing ()) {
0 commit comments