[android] Fix view recycling issue of image previews

parent 9d9bc4ca
......@@ -18,6 +18,7 @@ import org.briarproject.briar.R;
import org.briarproject.briar.android.conversation.glide.GlideApp;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static com.bumptech.glide.load.engine.DiskCacheStrategy.NONE;
import static com.bumptech.glide.load.resource.bitmap.DownsampleStrategy.FIT_CENTER;
import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
......@@ -38,7 +39,11 @@ class ImagePreviewViewHolder extends ViewHolder {
}
void bind(ImagePreviewItem item) {
if (item.getItem() == null) return; // shows progress bar
if (item.getItem() == null) {
progressBar.setVisibility(VISIBLE);
GlideApp.with(imageView)
.clear(imageView);
} else {
GlideApp.with(imageView)
.load(item.getItem())
.diskCacheStrategy(NONE)
......@@ -57,12 +62,14 @@ class ImagePreviewViewHolder extends ViewHolder {
@Override
public boolean onResourceReady(Drawable resource,
Object model, Target<Drawable> target,
DataSource dataSource, boolean isFirstResource) {
DataSource dataSource,
boolean isFirstResource) {
progressBar.setVisibility(INVISIBLE);
return false;
}
})
.into(imageView);
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment