catch exceptions thrown by GifDrawable, load them as simple jpgs
This commit is contained in:
parent
56af281cf4
commit
2ada4af2bf
2 changed files with 11 additions and 2 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue