Piasy / BigImageViewer

Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling Scale Image View, Fresco, Glide, and Picasso. Even with gif and webp support! 🍻
MIT License
3.98k stars 400 forks source link

Wrong image on recyclerview #107

Closed SmasSive closed 6 years ago

SmasSive commented 6 years ago

Hi! First of all thanks for this great lib! 👍

I'm using BIV like a gallery, in a recyclerview with a viewpager behaviour and the viewholder is basically a BigImageView, the question is that when I'm paginating there is a page that shows a previous image while progress is shown and once the right image is ready, it is shown correctly.

What I expect is that while the image is downloading, no previous image is shown but only the progress.

I've tried to do a cancel() in the onViewRecycled method of the adapter but with no success... I've read also that another solution could be to do a setImageDrawable(null) but AFAIK I don't have access to the ImageView right?

What can I do? If you need more info please ask me! Thanks a lot!!!

SmasSive commented 6 years ago

I've managed this by doing the following:

Adapter

  override fun onViewRecycled(holder: GlideGalleryViewHolder) {
    holder.clear()
  }

ViewHolder

  fun clear() {
    itemView.itemImage.ssiv.recycle()
  }

But I don't know if it's a good practice or it's ok. Could you please give me your opinion? Thanks!

Piasy commented 6 years ago

I think that's a good way to solve this problem.

Piasy commented 6 years ago

@SmasSive I think calling ssiv.recycle() at onBindViewHolder is another option.

batadamnjanovic commented 1 year ago

Did anyone managed to recycle() a ssiv in RecyclerView with ViewPager successfully?

Calling ssiv.recycle() does not work as expected.

batadamnjanovic commented 1 year ago

I was managed to make it work by hiding a BigImageView in onBindViewHolder and to show it when onMainImageShown callback is triggered. ssiv.recycle() didn't work for me.