mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
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
|
target.scaleType = if (cropThumbnails) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
loadJpg(path, target, cropThumbnails)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,14 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
private fun loadImage() {
|
private fun loadImage() {
|
||||||
if (medium.isGif()) {
|
if (medium.isGif()) {
|
||||||
|
loadGif()
|
||||||
|
} else {
|
||||||
|
loadBitmap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun loadGif() {
|
||||||
|
try {
|
||||||
gifDrawable = if (medium.path.startsWith("content://") || medium.path.startsWith("file://")) {
|
gifDrawable = if (medium.path.startsWith("content://") || medium.path.startsWith("file://")) {
|
||||||
GifDrawable(context.contentResolver, Uri.parse(medium.path))
|
GifDrawable(context.contentResolver, Uri.parse(medium.path))
|
||||||
} else {
|
} else {
|
||||||
|
@ -171,7 +179,8 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
view.gif_view.setImageDrawable(gifDrawable)
|
view.gif_view.setImageDrawable(gifDrawable)
|
||||||
} else {
|
} catch (e: Exception) {
|
||||||
|
gifDrawable = null
|
||||||
loadBitmap()
|
loadBitmap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue