Skip to content

Instantly share code, notes, and snippets.

@Ray33
Last active May 23, 2018 06:30
Show Gist options
  • Save Ray33/eb3480de7d10866fa0775d176a98c7b8 to your computer and use it in GitHub Desktop.
Save Ray33/eb3480de7d10866fa0775d176a98c7b8 to your computer and use it in GitHub Desktop.
Glide to handle big images
GlideApp.with(context.getApplicationContext()).load(url).fallback(R.drawable.loading)
.into((BaseTarget) new BaseTarget<BitmapDrawable>() {
@Override
public void onResourceReady(@NonNull BitmapDrawable resource, @Nullable Transition<? super BitmapDrawable> transition) {
showNotification(context, newsArticle, ((BitmapDrawable) resource).getBitmap());
}
@Override
public void getSize(@NonNull SizeReadyCallback cb) {
cb.onSizeReady(250, 250);
}
@Override
public void removeCallback(@NonNull SizeReadyCallback cb) {
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
super.onLoadFailed(errorDrawable);
if (loadingTrial==0){
Context ctx = getApplicationContext();
if (ctx != null) {
//retry
renderImageAndInvokeNotification(context, newsArticle, url, false);
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment