我有一组图像,通过Glide加载。有没有办法强制GIF加载Glide是非动画
NSFW的模糊使用glide(wasabeef)位图转换,但有些可以是动画gifs,在这种情况下,第一帧显示模糊,然后动画开始循环(未模糊)。
以下是我已经尝试并不起作用:
DrawableTypeRequest<String> builder = Glide.with(mImage.getContext()).load(...);
if (entry.isNsfw()) {
builder.asBitmap();
}
builder.diskCacheStrategy(DiskCacheStrategy.SOURCE) //it's likely none of this is relevant
.skipMemoryCache(true)
.override(props.getWidth(), props.getHeight());
if (entry.isNsfw()) {
//successfully blurs nsfw images, but still allows unblurred animation
builder.dontAnimate().bitmapTransform(centreCrop, blur);
} else {
builder.centerCrop();
}
builder.crossFade(500) //moving crossfade only into the sfw posts has no effect
.into(mImage);
还没有工作的拦截负载:
builder.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
if (entry.isNsfw()) {
target.onResourceReady(resource, null); //If I add this and return true the image is static, but unblurred
resource.stop(); //if this is called before target, it has no effect
return true;
}
return false; //returning true without calling the target stops any of the images being set on the view
}
});
我怎样才能关闭GIF回放单个图像,同时仍然保持模糊转换?
你有没有试过'onResourceReady'方法返回'true'?返回'false'将执行默认行为。同时检查[this](https://github.com/bumptech/glide/issues/1107#issuecomment-205735933) –
返回true将停止在目标上设置的图像。使用asBitmap也没有效果,我会更新我的示例中的代码,以显示我现在尝试过的其他东西 –