Closed RainlyTree closed 1 year ago
viewScope.launch { val circleCrop: Transformation = CenterInside() val drawable = withContext(Dispatchers.IO) { Glide.with(context) .asDrawable() .load(url) .optionalTransform( WebpDrawable::class.java, WebpDrawableTransformation(circleCrop) ) .skipMemoryCache(true) .submit() .get() } val webpDrawable = drawable as? WebpDrawable webpDrawable?.loopCount = -1 webpDrawable?.start() withContext(Dispatchers.Main) { setImageDrawable(webpDrawable ?: drawable) } } 代码如上 这样加载的webp会出现每次播放第二遍播放到一半被重置 而且可能会出现com.bumptech.glide.integration.webp.decoder.WebpFrameLoader.onFrameReady (WebpFrameLoader.java:295)方法返回空的情况 是我哪里写的有问题吗
Glide.with(context) 接口应该不支持在子线程调用,需要绑定View/Fragment的生命周期
viewScope.launch { val circleCrop: Transformation = CenterInside()
val drawable = withContext(Dispatchers.IO) {
Glide.with(context)
.asDrawable()
.load(url)
.optionalTransform(
WebpDrawable::class.java,
WebpDrawableTransformation(circleCrop)
)
.skipMemoryCache(true)
.submit()
.get()
}
val webpDrawable = drawable as? WebpDrawable
webpDrawable?.loopCount = -1
webpDrawable?.start()
withContext(Dispatchers.Main) {
setImageDrawable(webpDrawable ?: drawable)
}
}
代码如上 这样加载的webp会出现每次播放第二遍播放到一半被重置 而且可能会出现com.bumptech.glide.integration.webp.decoder.WebpFrameLoader.onFrameReady (WebpFrameLoader.java:295)方法返回空的情况 是我哪里写的有问题吗