Skip to content

Instantly share code, notes, and snippets.

Created October 13, 2016 15:19
Show Gist options
  • Save anonymous/ccef4ceff58275fcb51b70b8f2074207 to your computer and use it in GitHub Desktop.
Save anonymous/ccef4ceff58275fcb51b70b8f2074207 to your computer and use it in GitHub Desktop.
void bind(String url, DrawableRequestBuilder<String> thumbnailRequest) {
target.setModel(url); // update target's cache
Glide.with(imageView.getContext())
.load(url)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
if (BuildConfig.DEBUG)
Log.e("IMAGE_EXCEPTION", "Exception " + e.toString());
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
})
// .placeholder(R.drawable.github_232_progress)
.thumbnail(thumbnailRequest)
.centerCrop() // needs explicit transformation, because we're using a custom target
.into(target)
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment