use Glide for loading non-animating gifs

This commit is contained in:
tibbi 2018-01-04 18:05:37 +01:00
parent 327e18f3e2
commit 129858119d

View file

@ -148,19 +148,23 @@ fun Activity.loadImage(path: String, target: MySquareImageView, horizontalScroll
loadJpg(path, target, cropThumbnails) loadJpg(path, target, cropThumbnails)
} }
} else if (path.isGif()) { } else if (path.isGif()) {
try { if (animateGifs) {
val gifDrawable = GifDrawable(path) try {
target.setImageDrawable(gifDrawable) val gifDrawable = GifDrawable(path)
if (animateGifs) { target.setImageDrawable(gifDrawable)
gifDrawable.start() if (animateGifs) {
} else { gifDrawable.start()
gifDrawable.stop() } else {
} gifDrawable.stop()
}
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) {
loadJpg(path, target, cropThumbnails) loadJpg(path, target, cropThumbnails)
} catch (e: OutOfMemoryError) { } catch (e: OutOfMemoryError) {
loadJpg(path, target, cropThumbnails)
}
} else {
loadJpg(path, target, cropThumbnails) loadJpg(path, target, cropThumbnails)
} }
} }