I'm working with Glide for server loading images. I need to load image before some dialog shows.
What is the best approach?
EDIT: This is an example from my code:
On my dialog class
@Override
protected void onCreate(final Bundle savedInstanceState) {
setContentView(R.layout.dialog_alert);
ButterKnife.bind(this);
int size = mActivity.getResources().getDimensionPixelSize(R.dimen.product_icon);
String productThumbnailUrl = api.getThumbnailUrl(mProduct.getImage(), size, size);
Glide.with(mActivity)
.load(productThumbnailUrl)
.placeholder(R.drawable.icon_default)
.into(mImage);
}
On my activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
[...]
AlertProduct dialog = new AlertProduct(this, product);
dialog.show();
}
Loading into targets should do what you want.
If you simply want to load a Bitmap so that you can interact with it in some special way other than displaying it directly to the user, maybe to show in a notification, or upload as a profile photo, Glide has you covered.
SimpleTarget provides reasonable default implementations for the much larger Target interface and let's you focus on handling the result of your load.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With