8

I'm trying to use Glide within my RecyclerView, and I've got a question regarding the code they used in their documentation. Code is shown below:

public void onBindViewHolder(ViewHolder holder, int position) {
    if (isImagePosition(position)) {
        String url = urls.get(position);
        Glide.with(fragment)
            .load(url)
            .into(holder.imageView);
    } else {
        Glide.with(fragment).clear(holder.imageView);
        holder.imageView.setImageDrawable(specialDrawable);
    }
}

what I don't get is "isImagePosition(position)". What is this? Is this a check to see if the same view is being loaded to the same position when the RecyclerView's data set is updated? If that was the case, how would I implement "isImagePosition(position)"?

My recycler view uses a List ImageUrl.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Chao Li
  • 175
  • 10

1 Answers1

1

If you are using recyclerView you can invoke it in the method ::

override fun onViewRecycled (holder: RecyclerView.ViewHolder) {
   Glide.with (view.context) .clear (imageview)
   super.onViewRecycled (holder)     
 }
ErickAlvz
  • 21
  • 2