Browse Source

always coerce aspect ratio

pull/5114/head
Conny Duck 10 months ago
parent
commit
7045e223d9
No known key found for this signature in database
  1. 5
      app/src/main/java/com/keylesspalace/tusky/util/AttachmentHelper.kt

5
app/src/main/java/com/keylesspalace/tusky/util/AttachmentHelper.kt

@ -28,9 +28,8 @@ fun List<Attachment>.aspectRatios(): List<Double> {
return map { attachment -> return map { attachment ->
// clamp ratio between 2:1 & 1:2, defaulting to 16:9 // clamp ratio between 2:1 & 1:2, defaulting to 16:9
val size = (attachment.meta?.small ?: attachment.meta?.original) ?: return@map 1.7778 val size = (attachment.meta?.small ?: attachment.meta?.original) ?: return@map 1.7778
if (size.aspect > 0) return@map size.aspect if (size.aspect > 0) return@map size.aspect.coerceIn(0.5, 2.0)
if (size.width == 0 || size.height == 0) return@map 1.7778 if (size.width == 0 || size.height == 0) return@map 1.7778
val aspect = size.width.toDouble() / size.height (size.width.toDouble() / size.height).coerceIn(0.5, 2.0)
aspect.coerceIn(0.5, 2.0)
} }
} }

Loading…
Cancel
Save