catch exceptions thrown by GifDrawable, load them as simple jpgs

This commit is contained in:
tibbi 2017-11-02 16:23:20 +01:00
parent 56af281cf4
commit 2ada4af2bf
2 changed files with 11 additions and 2 deletions

View file

@ -157,7 +157,7 @@ fun Activity.loadImage(path: String, target: MySquareImageView, horizontalScroll
target.scaleType = if (cropThumbnails) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER
} catch (e: Exception) {
showErrorToast(e)
loadJpg(path, target, cropThumbnails)
}
}
}

View file

@ -160,6 +160,14 @@ class PhotoFragment : ViewPagerFragment() {
private fun loadImage() {
if (medium.isGif()) {
loadGif()
} else {
loadBitmap()
}
}
private fun loadGif() {
try {
gifDrawable = if (medium.path.startsWith("content://") || medium.path.startsWith("file://")) {
GifDrawable(context.contentResolver, Uri.parse(medium.path))
} else {
@ -171,7 +179,8 @@ class PhotoFragment : ViewPagerFragment() {
}
view.gif_view.setImageDrawable(gifDrawable)
} else {
} catch (e: Exception) {
gifDrawable = null
loadBitmap()
}
}