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: hardcoresushi
GPG Key ID: 007F84120107191E
1 changed files with 14 additions and 2 deletions

View File

@ -150,8 +150,20 @@ class ImageViewer: FileViewerActivity() {
private fun loadImage(){
loadWholeFile(filePath)?.let {
bitmap = BitmapFactory.decodeByteArray(it, 0, it.size)
Glide.with(this).load(bitmap).into(binding.imageViewer)
val displayWithGlide = if (it.size < 5_000_000) {
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
binding.textFilename.text = fileName
rotationAngle = 0F