mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Use in-memory thumbnail APIs when possible (#3817)
* Use in-memory thumbnail APIs when possible * Make an exception for animated image types. Also add `TimelineItemImageContent.thumbnailMediaRequestData` lazy property. * Try simplifying the logic a bit more.
This commit is contained in:
committed by
GitHub
parent
bee708cf3e
commit
2873a6829b
@@ -38,6 +38,7 @@ object MimeTypes {
|
||||
fun String?.normalizeMimeType() = if (this == BadJpg) Jpeg else this
|
||||
|
||||
fun String?.isMimeTypeImage() = this?.startsWith("image/").orFalse()
|
||||
fun String?.isMimeTypeAnimatedImage() = this == Gif || this == WebP
|
||||
fun String?.isMimeTypeVideo() = this?.startsWith("video/").orFalse()
|
||||
fun String?.isMimeTypeAudio() = this?.startsWith("audio/").orFalse()
|
||||
fun String?.isMimeTypeApplication() = this?.startsWith("application/").orFalse()
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ class RustMediaLoader(
|
||||
withContext(mediaDispatcher) {
|
||||
runCatching {
|
||||
source.toRustMediaSource().use { source ->
|
||||
innerClient.getMediaContent(source).toUByteArray().toByteArray()
|
||||
innerClient.getMediaContent(source)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class RustMediaLoader(
|
||||
mediaSource = mediaSource,
|
||||
width = width.toULong(),
|
||||
height = height.toULong()
|
||||
).toUByteArray().toByteArray()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -37,3 +37,9 @@ data class MediaRequestData(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Max width a thumbnail can have according to [the spec](https://spec.matrix.org/v1.10/client-server-api/#thumbnails). */
|
||||
const val MAX_THUMBNAIL_WIDTH = 800L
|
||||
|
||||
/** Max height a thumbnail can have according to [the spec](https://spec.matrix.org/v1.10/client-server-api/#thumbnails). */
|
||||
const val MAX_THUMBNAIL_HEIGHT = 600L
|
||||
|
||||
Reference in New Issue
Block a user