fix #1933, show wrong webp files as casual images
This commit is contained in:
parent
6292684ac9
commit
a8f107c37f
1 changed files with 35 additions and 27 deletions
|
@ -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,36 +421,25 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
options.diskCacheStrategy(DiskCacheStrategy.NONE)
|
options.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context == null) {
|
Glide.with(context!!)
|
||||||
return
|
.load(path)
|
||||||
}
|
.apply(options)
|
||||||
|
.listener(object : RequestListener<Drawable> {
|
||||||
val path = getFilePathToShow()
|
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
|
||||||
if (path.isWebP()) {
|
if (activity != null && !activity!!.isDestroyed && !activity!!.isFinishing) {
|
||||||
val drawable = WebPDrawable.fromFile(path)
|
tryLoadingWithPicasso(addZoomableView)
|
||||||
drawable.setLoopLimit(0)
|
|
||||||
mView.gestures_view.setImageDrawable(drawable)
|
|
||||||
} else {
|
|
||||||
Glide.with(context!!)
|
|
||||||
.load(path)
|
|
||||||
.apply(options)
|
|
||||||
.listener(object : RequestListener<Drawable> {
|
|
||||||
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
|
|
||||||
if (activity != null && !activity!!.isDestroyed && !activity!!.isFinishing) {
|
|
||||||
tryLoadingWithPicasso(addZoomableView)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
|
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
|
||||||
mView.gestures_view.controller.settings.isZoomEnabled = mMedium.isRaw() || mCurrentRotationDegrees != 0 || context?.config?.allowZoomingImages == false
|
mView.gestures_view.controller.settings.isZoomEnabled = mMedium.isRaw() || mCurrentRotationDegrees != 0 || context?.config?.allowZoomingImages == false
|
||||||
if (mIsFragmentVisible && addZoomableView) {
|
if (mIsFragmentVisible && addZoomableView) {
|
||||||
scheduleZoomableView()
|
scheduleZoomableView()
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
}).into(mView.gestures_view)
|
return false
|
||||||
}
|
}
|
||||||
|
}).into(mView.gestures_view)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryLoadingWithPicasso(addZoomableView: Boolean) {
|
private fun tryLoadingWithPicasso(addZoomableView: Boolean) {
|
||||||
|
|
Loading…
Reference in a new issue