本文介绍了在Glide-4中找不到GlideDrawableImageViewTarget的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么在Glide4 +中找不到GlideDrawableImageViewTarget
?有什么选择?
Why GlideDrawableImageViewTarget
is not found in Glide4+? What is the alternative?
我的代码:
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
Glide.with(getContext())
.load(R.drawable.loader_gif_image)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.into(new GlideDrawableImageViewTarget(imageView));
}
推荐答案
更新
Glide.with(this)
.load("")
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
.into(new DrawableImageViewTarget(imageView));
// or use this
Glide.with(this)
.load("")
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
.into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
imageView.setImageDrawable(resource);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
尝试一下
Glide.with(this)
.load(R.drawable.ic_favorite)
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
.into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
imageView.setImageDrawable(resource);
}
});
尝试一下
Glide.with(this)
.load(R.drawable.ic_favorite)
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
.into(new Target<Drawable>() {
@Override
public void onLoadStarted(@Nullable Drawable placeholder) {
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
}
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
imageView.setImageDrawable(resource);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
@Override
public void getSize(@NonNull SizeReadyCallback cb) {
}
@Override
public void removeCallback(@NonNull SizeReadyCallback cb) {
}
@Override
public void setRequest(@Nullable Request request) {
}
@Nullable
@Override
public Request getRequest() {
return null;
}
@Override
public void onStart() {
}
@Override
public void onStop() {
}
@Override
public void onDestroy() {
}
});
这篇关于在Glide-4中找不到GlideDrawableImageViewTarget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!