Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Glide - What is "isImagePosition(position)" in their documentation?

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.

like image 505
Chao Li Avatar asked May 30 '18 06:05

Chao Li


1 Answers

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)     
 }
like image 124
ErickAlvz Avatar answered Nov 15 '22 00:11

ErickAlvz