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) { 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 priority = if (mIsFragmentVisible) Priority.IMMEDIATE else Priority.NORMAL
val options = RequestOptions() val options = RequestOptions()
.signature(getFilePathToShow().getFileSignature()) .signature(getFilePathToShow().getFileSignature())
@ -402,16 +421,6 @@ class PhotoFragment : ViewPagerFragment() {
options.diskCacheStrategy(DiskCacheStrategy.NONE) 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!!) Glide.with(context!!)
.load(path) .load(path)
.apply(options) .apply(options)
@ -432,7 +441,6 @@ class PhotoFragment : ViewPagerFragment() {
} }
}).into(mView.gestures_view) }).into(mView.gestures_view)
} }
}
private fun tryLoadingWithPicasso(addZoomableView: Boolean) { private fun tryLoadingWithPicasso(addZoomableView: Boolean) {
var pathToLoad = if (getFilePathToShow().startsWith("content://")) getFilePathToShow() else "file://${getFilePathToShow()}" var pathToLoad = if (getFilePathToShow().startsWith("content://")) getFilePathToShow() else "file://${getFilePathToShow()}"