mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-06-05 21:59:19 +02:00
catch exceptions thrown by GifDrawable, load them as simple jpgs
This commit is contained in:
@@ -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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user