fix #1933, show wrong webp files as casual images

This commit is contained in:
tibbi 2020-10-10 22:29:25 +02:00
parent 6292684ac9
commit a8f107c37f

View file

@ -389,6 +389,25 @@ class PhotoFragment : ViewPagerFragment() {
}
private fun loadBitmap(addZoomableView: Boolean = true) {
if (context == null) {
return
}
val path = getFilePathToShow()
if (path.isWebP()) {
val drawable = WebPDrawable.fromFile(path)
if (drawable.intrinsicWidth == 0) {
loadWithGlide(path, addZoomableView)
} else {
drawable.setLoopLimit(0)
mView.gestures_view.setImageDrawable(drawable)
}
} else {
loadWithGlide(path, addZoomableView)
}
}
private fun loadWithGlide(path: String, addZoomableView: Boolean) {
val priority = if (mIsFragmentVisible) Priority.IMMEDIATE else Priority.NORMAL
val options = RequestOptions()
.signature(getFilePathToShow().getFileSignature())
@ -402,16 +421,6 @@ class PhotoFragment : ViewPagerFragment() {
options.diskCacheStrategy(DiskCacheStrategy.NONE)
}
if (context == null) {
return
}
val path = getFilePathToShow()
if (path.isWebP()) {
val drawable = WebPDrawable.fromFile(path)
drawable.setLoopLimit(0)
mView.gestures_view.setImageDrawable(drawable)
} else {
Glide.with(context!!)
.load(path)
.apply(options)
@ -432,7 +441,6 @@ class PhotoFragment : ViewPagerFragment() {
}
}).into(mView.gestures_view)
}
}
private fun tryLoadingWithPicasso(addZoomableView: Boolean) {
var pathToLoad = if (getFilePathToShow().startsWith("content://")) getFilePathToShow() else "file://${getFilePathToShow()}"