fix #1124, properly handle playing animated WebP files

This commit is contained in:
tibbi 2020-09-25 21:23:47 +02:00
parent 03a83f5341
commit f3c55e1df8
3 changed files with 28 additions and 18 deletions

View file

@ -77,7 +77,7 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:5.30.12'
implementation 'com.simplemobiletools:commons:5.30.14'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'it.sephiroth.android.exif:library:1.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
@ -92,6 +92,7 @@ dependencies {
implementation 'com.github.tibbi:gestureviews:512f929d82'
implementation 'com.github.tibbi:subsampling-scale-image-view:81c021514c'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.github.penfeizhou.android.animation:awebp:2.4.2'
kapt 'com.github.bumptech.glide:compiler:4.10.0'

View file

@ -81,7 +81,8 @@ fun Activity.launchCamera() {
fun SimpleActivity.launchAbout() {
val licenses = LICENSE_GLIDE or LICENSE_CROPPER or LICENSE_RTL or LICENSE_SUBSAMPLING or LICENSE_PATTERN or LICENSE_REPRINT or LICENSE_GIF_DRAWABLE or
LICENSE_PICASSO or LICENSE_EXOPLAYER or LICENSE_PANORAMA_VIEW or LICENSE_SANSELAN or LICENSE_FILTERS or LICENSE_GESTURE_VIEWS
LICENSE_PICASSO or LICENSE_EXOPLAYER or LICENSE_PANORAMA_VIEW or LICENSE_SANSELAN or LICENSE_FILTERS or LICENSE_GESTURE_VIEWS or
LICENSE_APNG
val faqItems = arrayListOf(
FAQItem(R.string.faq_5_title_commons, R.string.faq_5_text_commons),

View file

@ -36,6 +36,7 @@ import com.davemorrissey.labs.subscaleview.DecoderFactory
import com.davemorrissey.labs.subscaleview.ImageDecoder
import com.davemorrissey.labs.subscaleview.ImageRegionDecoder
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
import com.github.penfeizhou.animation.webp.WebPDrawable
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
@ -405,25 +406,32 @@ class PhotoFragment : ViewPagerFragment() {
return
}
Glide.with(context!!)
.load(getFilePathToShow())
.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)
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)
.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 {
mView.gestures_view.controller.settings.isZoomEnabled = mMedium.isRaw() || mCurrentRotationDegrees != 0 || context?.config?.allowZoomingImages == false
if (mIsFragmentVisible && addZoomableView) {
scheduleZoomableView()
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
if (mIsFragmentVisible && addZoomableView) {
scheduleZoomableView()
}
return false
}
return false
}
}).into(mView.gestures_view)
}).into(mView.gestures_view)
}
}
private fun tryLoadingWithPicasso(addZoomableView: Boolean) {