Use the designated UNSET value for aspect ratio

PiperOrigin-RevId: 536770380
This commit is contained in:
claincly 2023-05-31 18:18:42 +00:00 committed by Tofunmi Adigun-Hameed
parent 80805b074a
commit f6dbe99c79

View File

@ -119,9 +119,7 @@ public final class Presentation implements MatrixTransformation {
*/ */
public static Presentation createForAspectRatio( public static Presentation createForAspectRatio(
@FloatRange(from = 0, fromInclusive = false) float aspectRatio, @Layout int layout) { @FloatRange(from = 0, fromInclusive = false) float aspectRatio, @Layout int layout) {
checkArgument( checkArgument(aspectRatio > 0, "aspect ratio " + aspectRatio + " must be positive");
aspectRatio == C.LENGTH_UNSET || aspectRatio > 0,
"aspect ratio " + aspectRatio + " must be positive or unset");
checkLayout(layout); checkLayout(layout);
return new Presentation( return new Presentation(
/* width= */ C.LENGTH_UNSET, /* height= */ C.LENGTH_UNSET, aspectRatio, layout); /* width= */ C.LENGTH_UNSET, /* height= */ C.LENGTH_UNSET, aspectRatio, layout);
@ -169,7 +167,7 @@ public final class Presentation implements MatrixTransformation {
private Presentation(int width, int height, float aspectRatio, @Layout int layout) { private Presentation(int width, int height, float aspectRatio, @Layout int layout) {
checkArgument( checkArgument(
(aspectRatio == C.LENGTH_UNSET) || (width == C.LENGTH_UNSET), (aspectRatio == ASPECT_RATIO_UNSET) || (width == C.LENGTH_UNSET),
"width and aspect ratio should not both be set"); "width and aspect ratio should not both be set");
this.requestedWidthPixels = width; this.requestedWidthPixels = width;
@ -195,7 +193,7 @@ public final class Presentation implements MatrixTransformation {
requestedAspectRatio = (float) requestedWidthPixels / requestedHeightPixels; requestedAspectRatio = (float) requestedWidthPixels / requestedHeightPixels;
} }
if (requestedAspectRatio != C.LENGTH_UNSET) { if (requestedAspectRatio != ASPECT_RATIO_UNSET) {
applyAspectRatio(); applyAspectRatio();
} }