I am using Picasso for background loading of images (list view and ImagePager). I can set loading image and errorimage with Picasso, but I am unable to show a "loading in progress" Image during background loading.
Has anybody an idea how to get this done? In my PagerAdapter Class I have the following method:
@Override
public Object instantiateItem(ViewGroup container, int position) {
ImageView imageView = new ImageView(context);
int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_medium);
imageView.setPadding(padding, padding, padding, padding);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
// Set default Image before loading real image
imageView.setImageResource(R.drawable.img_def);
imageView.setId(imgViewId);
imageView.setClickable(true);
imageView.setOnClickListener(this);
((ViewPager) container).addView(imageView, 0);
// Set default Image before loading real image
Picasso.with(context).load(R.drawable.img_def).into(imageView);
// Load real image with Picasso and show error image if failed
Picasso.with(context).load(GalImgUrls[position]).error(R.drawable.no_img).into(imageView);
return imageView;
}
However, it does not show the "loading..." image. Any solutions/ideas?
Thanks!
Image loading using Picasso is very easy, you can do it like this way Picasso. get(). load("http://i.imgur.com/DvpvklR.png").into(imageView); and in their website you can get every details. In your case you can parse every image URL and use RecyclerView to show them along with Picasso.
You can use a placeholder image by using the *.placeholder(R.drawable.image_name)* in your Picasso call like: Picasso.with(context) .load(imageUrl) .placeholder(R.drawable.image_name) If you want to use a progress bar instead of a placeholder image you can create a callback inside the .into function.
Glide is faster and the results of Picasso and Coil are similar. But what about when we are loading from the cache. As you can see in the images below we have the best times for Glide in most of the cases.
Looks like I found a solution myself. Use "placeholder" image:
Picasso.with(context).load(tnu).error(R.drawable.no_img).placeholder(R.drawable.img_def).into(holder.immoPic);
Works like charm....
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