Skip to content

Commit a23f941

Browse files
committed
Simplified some code and added some comments
1 parent b0a10f0 commit a23f941

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public void onScroll(@NotNull final MainPlayer.PlayerType playerType,
9999
+ player.getPlayerType() + "], portion = [" + portion + "]");
100100
}
101101
if (playerType == MainPlayer.PlayerType.VIDEO) {
102+
103+
// -- Brightness and Volume control --
102104
final boolean isBrightnessGestureEnabled =
103105
PlayerHelper.isBrightnessGestureEnabled(service);
104106
final boolean isVolumeGestureEnabled = PlayerHelper.isVolumeGestureEnabled(service);
@@ -117,15 +119,14 @@ public void onScroll(@NotNull final MainPlayer.PlayerType playerType,
117119
}
118120

119121
} else /* MainPlayer.PlayerType.POPUP */ {
122+
123+
// -- Determine if the ClosingOverlayView (red X) has to be shown or hidden --
120124
final View closingOverlayView = player.getClosingOverlayView();
121-
if (player.isInsideClosingRadius(movingEvent)) {
122-
if (closingOverlayView.getVisibility() == View.GONE) {
123-
animate(closingOverlayView, true, 200);
124-
}
125-
} else {
126-
if (closingOverlayView.getVisibility() == View.VISIBLE) {
127-
animate(closingOverlayView, false, 200);
128-
}
125+
final boolean showClosingOverlayView = player.isInsideClosingRadius(movingEvent);
126+
// Check if an view is in expected state and if not animate it into the correct state
127+
final int expectedVisibility = showClosingOverlayView ? View.VISIBLE : View.GONE;
128+
if (closingOverlayView.getVisibility() != expectedVisibility) {
129+
animate(closingOverlayView, showClosingOverlayView, 200);
129130
}
130131
}
131132
}

0 commit comments

Comments
 (0)