Skip to content

Commit ed7a36e

Browse files
committed
Improve code readability a bit.
1 parent e0e721c commit ed7a36e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/media/VideoCompressorHelper.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class VideoCompressorHelper(
2727
fun getOutputSize(inputSize: Size): Size {
2828
val resultMajor = min(inputSize.major(), maxSize)
2929
val aspectRatio = inputSize.major().toFloat() / inputSize.minor().toFloat()
30-
return if (inputSize.width >= inputSize.height) {
30+
return if (inputSize.isLandscape()) {
3131
Size(resultMajor, (resultMajor / aspectRatio).roundToInt())
3232
} else {
3333
Size((resultMajor / aspectRatio).roundToInt(), resultMajor)
@@ -46,5 +46,6 @@ class VideoCompressorHelper(
4646
}
4747
}
4848

49-
internal fun Size.major(): Int = if (width > height) width else height
50-
internal fun Size.minor(): Int = if (width < height) width else height
49+
private fun Size.isLandscape(): Boolean = width > height
50+
private fun Size.major(): Int = if (isLandscape()) width else height
51+
private fun Size.minor(): Int = if (isLandscape()) height else width

0 commit comments

Comments
 (0)