Fix image viewer

This commit is contained in:
Matéo Duparc 2021-11-07 12:42:52 +01:00
parent 1cab607fa1
commit 01a9c261f5
Signed by untrusted user: hardcoresushi
GPG Key ID: 007F84120107191E

View File

@ -150,8 +150,20 @@ class ImageViewer: FileViewerActivity() {
private fun loadImage(){ private fun loadImage(){
loadWholeFile(filePath)?.let { loadWholeFile(filePath)?.let {
bitmap = BitmapFactory.decodeByteArray(it, 0, it.size) val displayWithGlide = if (it.size < 5_000_000) {
Glide.with(this).load(bitmap).into(binding.imageViewer) true
} else {
val decodedBitmap = BitmapFactory.decodeByteArray(it, 0, it.size)
if (decodedBitmap == null) {
true
} else {
Glide.with(this).load(decodedBitmap).fitCenter().into(binding.imageViewer)
false
}
}
if (displayWithGlide) {
Glide.with(this).load(it).into(binding.imageViewer)
}
fileName = File(filePath).name fileName = File(filePath).name
binding.textFilename.text = fileName binding.textFilename.text = fileName
rotationAngle = 0F rotationAngle = 0F