Merge pull request #8737 from Isira-Seneviratne/Fix_coerceIn

Replace coerceIn() with MathUtils.clamp().
This commit is contained in:
Stypox 2022-08-06 11:16:06 +02:00 committed by GitHub
commit 816154c7cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import android.util.Log
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View
import android.view.ViewConfiguration import android.view.ViewConfiguration
import androidx.core.math.MathUtils
import org.schabi.newpipe.MainActivity import org.schabi.newpipe.MainActivity
import org.schabi.newpipe.ktx.AnimationType import org.schabi.newpipe.ktx.AnimationType
import org.schabi.newpipe.ktx.animate import org.schabi.newpipe.ktx.animate
@ -234,11 +235,13 @@ class PopupPlayerGestureListener(
isMoving = true isMoving = true
val diffX = (movingEvent.rawX - initialEvent.rawX) val diffX = (movingEvent.rawX - initialEvent.rawX)
val posX = (initialPopupX + diffX).coerceIn( val posX = MathUtils.clamp(
initialPopupX + diffX,
0f, (playerUi.screenWidth - playerUi.popupLayoutParams.width).toFloat() 0f, (playerUi.screenWidth - playerUi.popupLayoutParams.width).toFloat()
) )
val diffY = (movingEvent.rawY - initialEvent.rawY) val diffY = (movingEvent.rawY - initialEvent.rawY)
val posY = (initialPopupY + diffY).coerceIn( val posY = MathUtils.clamp(
initialPopupY + diffY,
0f, (playerUi.screenHeight - playerUi.popupLayoutParams.height).toFloat() 0f, (playerUi.screenHeight - playerUi.popupLayoutParams.height).toFloat()
) )