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.
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)
}
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