Reputation: 11035
In a recyclerView's adapter, when OnBindViewHolder() is called and the viewHolder from the recycler pool is passed in for this position, and the imageView will be updated with image for this position or no image at all for this position.
For the case of there is no image at this position, with Glide version 3, this clear()
is called to clear the imageView:
Glide.clear(this.theImageView)
But when upgrade to Glide 9, it does not have this clear(ImageView)
anymore.
What is the right way to clear the image of the ImageView with Glide 9?
update: the solution
fun ImageView.clear() {
Glide.with(this.context).clear(this)
}
does not work, see Glide's comment:
<p> Note that this will only work if {@link View#setTag(Object)} is not called on this view outside of Glide. </p>
/**
* Cancel any pending loads Glide may have for the view and free any resources that may have been
* loaded for the view.
*
* <p> Note that this will only work if {@link View#setTag(Object)} is not called on this view
* outside of Glide. </p>
*
* @param view The view to cancel loads and free resources for.
* @throws IllegalArgumentException if an object other than Glide's metadata is put as the view's
* tag.
* @see #clear(Target)
*/
public void clear(@NonNull View view) {
clear(new ClearTarget(view));
}
Upvotes: 1
Views: 2978
Reputation: 11035
found a solution, adding a kotlin extension solves the problem:
fun ImageView.clear() {
Glide.with(this.context).clear(this)
}
Upvotes: 1