有个需求:
DiaLog中用Glide加载一张网图,如果直接调用diaLog.show()方法,当弱网或图片没下载完成时图片不显示,很难看。所以需要图片加载完成后弹出DiaLog。
目前我为Glide设置了RequestListener,但只调用dialog.create(),不调用dialog.show()时,Glide的监听并没有回调。只有调用show()方法时onResourceReady()才执行,有种马后炮的感觉。
public void setListener(RequestListener requestListener){
create();
GlideImageLoader.loadImage(context, Img_url, ImageView,requestListener);
}
用这个 Glide.with(context).asBitmap().load(url).into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } });
https://blog.csdn.net/yoonerloop/article/details/79998353
Glide加载图片的时机不对吧