chore(android): migrate AspectRatioFrameLayout to Kotlin (#3985)

* Rename .java to .kt

* chore(android): migrate AspectRatioFrameLayout to Kotlin

* chore: refactor setter and getter of class

* fix: use field
This commit is contained in:
Seyed Mostafa Hasani
2024-07-11 11:36:22 +03:30
committed by GitHub
parent 66dcf32b56
commit 452e42f1dd
3 changed files with 100 additions and 152 deletions

View File

@@ -236,7 +236,7 @@ public final class ExoPlayerView extends FrameLayout implements AdViewProvider {
Format format = group.getTrackFormat(0);
// update aspect ratio !
layout.setAspectRatio(format.height == 0 ? 1 : (format.width * format.pixelWidthHeightRatio) / format.height);
layout.setVideoAspectRatio(format.height == 0 ? 1 : (format.width * format.pixelWidthHeightRatio) / format.height);
return;
}
}
@@ -258,13 +258,13 @@ public final class ExoPlayerView extends FrameLayout implements AdViewProvider {
@Override
public void onVideoSizeChanged(VideoSize videoSize) {
boolean isInitialRatio = layout.getAspectRatio() == 0;
boolean isInitialRatio = layout.getVideoAspectRatio() == 0;
if (videoSize.height == 0 || videoSize.width == 0) {
// When changing video track we receive an ghost state with height / width = 0
// No need to resize the view in that case
return;
}
layout.setAspectRatio((videoSize.width * videoSize.pixelWidthHeightRatio) / videoSize.height);
layout.setVideoAspectRatio((videoSize.width * videoSize.pixelWidthHeightRatio) / videoSize.height);
// React native workaround for measuring and layout on initial load.
if (isInitialRatio) {