В адаптере recyclerView, когда вызывается OnBindViewHolder (), и viewHolder из пула переработчика передается для этой позиции, и imageView будет обновляться с изображением для этой позиции или без изображения для этой позиции.
В случае отсутствия изображения в этой позиции, в Glide версии 3 это clear()
вызывается для очистки imageView:
Glide.clear(this.theImageView)
Но при обновлении до Glide 9 это делаетбольше нет clear(ImageView)
.
Как правильно очистить изображение в ImageView с помощью Glide 9?
обновление : решение
fun ImageView.clear() {
Glide.with(this.context).clear(this)
}
не работает, см. Комментарий Glide:
<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));
}