-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use range-limiting methods. #8651
Use range-limiting methods. #8651
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch ;-)
app/src/main/java/org/schabi/newpipe/player/ui/PopupPlayerUi.java
Outdated
Show resolved
Hide resolved
d26d7e3
to
c34da64
Compare
Co-authored-by: Stypox <stypox@pm.me>
c34da64
to
394eb92
Compare
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again some code style issues I fixed myself, but this is ready (I tested, for example, the popup and found no issues)
// Use 1/4 of the width for the preview | ||
final int newWidth = MathUtils.clamp(Math.round(baseViewWidthSupplier.getAsInt() / 4f), | ||
DeviceUtils.dpToPx(10, context), | ||
// Scaling more than that factor looks really pixelated -> max | ||
Math.round(srcWidth * 2.5f)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Use 1/4 of the width for the preview | |
final int newWidth = MathUtils.clamp(Math.round(baseViewWidthSupplier.getAsInt() / 4f), | |
DeviceUtils.dpToPx(10, context), | |
// Scaling more than that factor looks really pixelated -> max | |
Math.round(srcWidth * 2.5f)); | |
final int newWidth = MathUtils.clamp( | |
// Use 1/4 of the width for the preview | |
Math.round(baseViewWidthSupplier.getAsInt() / 4f), | |
// But have a min width of 10dp | |
DeviceUtils.dpToPx(10, context), | |
// And scaling more than that factor looks really pixelated -> max | |
Math.round(srcWidth * 2.5f)); |
public int interpolateOutOfBoundsScroll(@NonNull final RecyclerView recyclerView, | ||
final int viewSize, final int viewSizeOutOfBounds, | ||
final int totalSize, final long msSinceStartScroll) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public int interpolateOutOfBoundsScroll(@NonNull final RecyclerView recyclerView, | |
final int viewSize, final int viewSizeOutOfBounds, | |
final int totalSize, final long msSinceStartScroll) { | |
public int interpolateOutOfBoundsScroll(@NonNull final RecyclerView recyclerView, | |
final int viewSize, | |
final int viewSizeOutOfBounds, | |
final int totalSize, | |
final long msSinceStartScroll) { |
I got a crash while testing #8656 related to this PR:
So this PR introduced possible crashes. Could you revert all usages of range-limiting methods in cases where the two extrema are not surely one smaller than the other? |
Sure. |
What is it?
Description of the changes in your PR
MathUtils.clamp()
and Kotlin'scoerceIn()
.Fixes the following issue(s)
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.
Due diligence