Merge pull request #8747 from Isira-Seneviratne/Range_limit

Use range-limiting methods in more places.
This commit is contained in:
Stypox 2022-10-28 10:34:04 +02:00 committed by GitHub
commit fd1237698d
4 changed files with 11 additions and 13 deletions

View file

@ -7,6 +7,7 @@ import android.view.View.OnTouchListener
import android.widget.ProgressBar
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.math.MathUtils
import androidx.core.view.isVisible
import org.schabi.newpipe.MainActivity
import org.schabi.newpipe.R
@ -18,8 +19,6 @@ import org.schabi.newpipe.player.helper.PlayerHelper
import org.schabi.newpipe.player.ui.MainPlayerUi
import org.schabi.newpipe.util.ThemeHelper.getAndroidDimenPx
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
/**
* GestureListener for the player
@ -114,7 +113,7 @@ class MainPlayerGestureListener(
// Update progress bar
val oldBrightness = layoutParams.screenBrightness
bar.progress = (bar.max * max(0f, min(1f, oldBrightness))).toInt()
bar.progress = (bar.max * MathUtils.clamp(oldBrightness, 0f, 1f)).toInt()
bar.incrementProgressBy(distanceY.toInt())
// Update brightness

View file

@ -291,7 +291,7 @@ public final class PopupPlayerUi extends VideoPlayerUi {
}
final float minimumWidth = context.getResources().getDimension(R.dimen.popup_minimum_width);
final int actualWidth = Math.min((int) Math.max(width, minimumWidth), screenWidth);
final int actualWidth = MathUtils.clamp(width, (int) minimumWidth, screenWidth);
final int actualHeight = (int) getMinimumVideoHeight(width);
if (DEBUG) {
Log.d(TAG, "updatePopupSize() updated values:"