From 2eec2e9128924bbe708eeb4958191b0d3fe3ff6c Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Fri, 5 Aug 2022 06:19:06 +0530 Subject: [PATCH] Replace coerceIn() with MathUtils.clamp(). --- .../newpipe/player/gesture/PopupPlayerGestureListener.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/gesture/PopupPlayerGestureListener.kt b/app/src/main/java/org/schabi/newpipe/player/gesture/PopupPlayerGestureListener.kt index 01b15f30a..666ea6a46 100644 --- a/app/src/main/java/org/schabi/newpipe/player/gesture/PopupPlayerGestureListener.kt +++ b/app/src/main/java/org/schabi/newpipe/player/gesture/PopupPlayerGestureListener.kt @@ -4,6 +4,7 @@ import android.util.Log import android.view.MotionEvent import android.view.View import android.view.ViewConfiguration +import androidx.core.math.MathUtils import org.schabi.newpipe.MainActivity import org.schabi.newpipe.ktx.AnimationType import org.schabi.newpipe.ktx.animate @@ -234,11 +235,13 @@ class PopupPlayerGestureListener( isMoving = true val diffX = (movingEvent.rawX - initialEvent.rawX) - val posX = (initialPopupX + diffX).coerceIn( + val posX = MathUtils.clamp( + initialPopupX + diffX, 0f, (playerUi.screenWidth - playerUi.popupLayoutParams.width).toFloat() ) val diffY = (movingEvent.rawY - initialEvent.rawY) - val posY = (initialPopupY + diffY).coerceIn( + val posY = MathUtils.clamp( + initialPopupY + diffY, 0f, (playerUi.screenHeight - playerUi.popupLayoutParams.height).toFloat() )