So I'm downloading two images using Picasso at the same time, as follows:
Picasso.with(this).load(Constants.SERVER_HOME_PAGE_TOP_IMAGE_URL).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
sLastBitmapLoadedDate = Calendar.getInstance();
int h= (int) (Constants.PAGE_TOP_IMAGE_HEIGHT * densityMultiplier);
int w= (int) (h * bitmap.getWidth()/((double) bitmap.getHeight()));
sTipBitmap = Bitmap.createScaledBitmap(bitmap, w, h, true);
Log.v("Image: ", "one");
topImage.setImageBitmap(sTipBitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
Picasso.with(this).load(Constants.SERVER_HOME_PAGE_BOTTOM_IMAGE_URL).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
sLastBitmapLoadedDate = Calendar.getInstance();
int h= (int) (Constants.PAGE_BOTTOM_IMAGE_HEIGHT * densityMultiplier);
int w= (int) (h * bitmap.getWidth()/((double) bitmap.getHeight()));
sAdBitmap = Bitmap.createScaledBitmap(bitmap, w, h, true);
Log.v("Image: ", "two");
bottomImage.setImageBitmap(sAdBitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
I'm modifying the image size by using Target. So I never hit the onBitMapLoaded on both cases. If i comment out one of the requests, then it will load the image and hit the onBitMapLoaded, where i resize the image.
So I'm for sure going about this the wrong way. If someone could help me out and explain what I am doing wrong.
Thanks!