1.MVP
2.Glide 4.0
// 4.0版本
RequestOptions options = new RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.error(R.drawable.ic_empty_picture);
Glide.with(context).load(imgurl).apply(options).thumbnail(0.1f)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
loading.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
loading.setVisibility(View.GONE);
return false;
}
}).into(imageView);
// 3.7版本
/* Glide.with(context).load(imgurl)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.error(R.drawable.ic_empty_picture)
.thumbnail(0.1f)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
loading.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
loading.setVisibility(View.GONE);
return false;
}
})
.into(imageView);*/