@@ -4,7 +4,7 @@ import android.util.Log
44import android.view.MotionEvent
55import android.view.View
66import android.view.ViewConfiguration
7- import androidx.core.math.MathUtils
7+ import androidx.core.view.isVisible
88import org.schabi.newpipe.MainActivity
99import org.schabi.newpipe.ktx.AnimationType
1010import org.schabi.newpipe.ktx.animate
@@ -235,14 +235,16 @@ class PopupPlayerGestureListener(
235235 isMoving = true
236236
237237 val diffX = (movingEvent.rawX - initialEvent.rawX)
238- val posX = MathUtils .clamp(
239- initialPopupX + diffX,
240- 0f , (playerUi.screenWidth - playerUi.popupLayoutParams.width).toFloat()
238+ val posX = (initialPopupX + diffX).coerceIn(
239+ 0f ,
240+ (playerUi.screenWidth - playerUi.popupLayoutParams.width).toFloat()
241+ .coerceAtLeast(0f )
241242 )
242243 val diffY = (movingEvent.rawY - initialEvent.rawY)
243- val posY = MathUtils .clamp(
244- initialPopupY + diffY,
245- 0f , (playerUi.screenHeight - playerUi.popupLayoutParams.height).toFloat()
244+ val posY = (initialPopupY + diffY).coerceIn(
245+ 0f ,
246+ (playerUi.screenHeight - playerUi.popupLayoutParams.height).toFloat()
247+ .coerceAtLeast(0f )
246248 )
247249
248250 playerUi.popupLayoutParams.x = posX.toInt()
@@ -251,8 +253,7 @@ class PopupPlayerGestureListener(
251253 // -- Determine if the ClosingOverlayView (red X) has to be shown or hidden --
252254 val showClosingOverlayView: Boolean = playerUi.isInsideClosingRadius(movingEvent)
253255 // Check if an view is in expected state and if not animate it into the correct state
254- val expectedVisibility = if (showClosingOverlayView) View .VISIBLE else View .GONE
255- if (binding.closingOverlay.visibility != expectedVisibility) {
256+ if (binding.closingOverlay.isVisible != showClosingOverlayView) {
256257 binding.closingOverlay.animate(showClosingOverlayView, 200 )
257258 }
258259
0 commit comments