I am loading around 5-10 images through Picasso in a new Target and then using it to place custom markers or GroundOverlay images on Google Map.
The problem is the number of images being loaded is not consistent. It varies between all images getting loaded to partial images loading to none of the images loading in the Bitmap.
onPrepareLoad gets called when a particular image is not loading.
while (count<ts_news_data_id.size()){
int index = il_id_data.indexOf(mainMarkers.get(count));
Log.d("tag_picasso","Picasso");
loadPicasso(il_lat_data.get(index),il_long_data.get(index),count);
count++;
}
loadPicasso method
private void loadPicasso(final Double lat, final Double lng, Integer count){
Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Log.d("tag_bitmap_load","Bitmap Loaded");
getRoundedShape(bitmap, lat,lng);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
Log.d("tag_bitmap_fail","Bitmap Failed");
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
Log.d("tag_bitmap_prepare","Bitmap Prepare");
}
};
Picasso.with(getApplicationContext())
.load(ts_news_data_image.get(count))
.resize(100,100)
.centerCrop()
.into(target);
}
getRoundShape takes care of further customizes the loaded bitmap and then adds a marker or ground overlay on the Google Map.
What should I do to make sure all images load every time?