Clear cover target when setting folder image

To prevent race conditions from recycled views in GridView
This commit is contained in:
Hannes Johansson 2021-08-11 00:32:04 +02:00
parent 2d6fff4182
commit d8a5c4dc52
1 changed files with 4 additions and 1 deletions

View File

@ -72,7 +72,10 @@ public class CoverLoader {
}
public void load() {
CoverTarget coverTarget = new CoverTarget(txtvPlaceholder, imgvCover, textAndImageCombined);
if (resource != 0) {
Glide.with(activity).clear(coverTarget);
imgvCover.setImageResource(resource);
CoverTarget.setPlaceholderVisibility(txtvPlaceholder, textAndImageCombined);
return;
@ -93,7 +96,7 @@ public class CoverLoader {
.apply(options));
}
builder.into(new CoverTarget(txtvPlaceholder, imgvCover, textAndImageCombined));
builder.into(coverTarget);
}
static class CoverTarget extends CustomViewTarget<ImageView, Drawable> {