Skip to content

Commit 2eec2e9

Browse files
Replace coerceIn() with MathUtils.clamp().
1 parent 1a8f396 commit 2eec2e9

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/gesture/PopupPlayerGestureListener.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.util.Log
44
import android.view.MotionEvent
55
import android.view.View
66
import android.view.ViewConfiguration
7+
import androidx.core.math.MathUtils
78
import org.schabi.newpipe.MainActivity
89
import org.schabi.newpipe.ktx.AnimationType
910
import org.schabi.newpipe.ktx.animate
@@ -234,11 +235,13 @@ class PopupPlayerGestureListener(
234235
isMoving = true
235236

236237
val diffX = (movingEvent.rawX - initialEvent.rawX)
237-
val posX = (initialPopupX + diffX).coerceIn(
238+
val posX = MathUtils.clamp(
239+
initialPopupX + diffX,
238240
0f, (playerUi.screenWidth - playerUi.popupLayoutParams.width).toFloat()
239241
)
240242
val diffY = (movingEvent.rawY - initialEvent.rawY)
241-
val posY = (initialPopupY + diffY).coerceIn(
243+
val posY = MathUtils.clamp(
244+
initialPopupY + diffY,
242245
0f, (playerUi.screenHeight - playerUi.popupLayoutParams.height).toFloat()
243246
)
244247

0 commit comments

Comments
 (0)