Last active
May 23, 2018 06:30
-
-
Save Ray33/eb3480de7d10866fa0775d176a98c7b8 to your computer and use it in GitHub Desktop.
Glide to handle big images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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