mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 04:39:54 +01:00
[android] Fix view recycling issue of image previews
This commit is contained in:
@@ -18,6 +18,7 @@ import org.briarproject.briar.R;
|
|||||||
import org.briarproject.briar.android.conversation.glide.GlideApp;
|
import org.briarproject.briar.android.conversation.glide.GlideApp;
|
||||||
|
|
||||||
import static android.view.View.INVISIBLE;
|
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.engine.DiskCacheStrategy.NONE;
|
||||||
import static com.bumptech.glide.load.resource.bitmap.DownsampleStrategy.FIT_CENTER;
|
import static com.bumptech.glide.load.resource.bitmap.DownsampleStrategy.FIT_CENTER;
|
||||||
import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
|
import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
|
||||||
@@ -38,31 +39,37 @@ class ImagePreviewViewHolder extends ViewHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void bind(ImagePreviewItem item) {
|
void bind(ImagePreviewItem item) {
|
||||||
if (item.getItem() == null) return; // shows progress bar
|
if (item.getItem() == null) {
|
||||||
GlideApp.with(imageView)
|
progressBar.setVisibility(VISIBLE);
|
||||||
.load(item.getItem())
|
GlideApp.with(imageView)
|
||||||
.diskCacheStrategy(NONE)
|
.clear(imageView);
|
||||||
.error(ERROR_RES)
|
} else {
|
||||||
.downsample(FIT_CENTER)
|
GlideApp.with(imageView)
|
||||||
.transition(withCrossFade())
|
.load(item.getItem())
|
||||||
.addListener(new RequestListener<Drawable>() {
|
.diskCacheStrategy(NONE)
|
||||||
@Override
|
.error(ERROR_RES)
|
||||||
public boolean onLoadFailed(@Nullable GlideException e,
|
.downsample(FIT_CENTER)
|
||||||
Object model, Target<Drawable> target,
|
.transition(withCrossFade())
|
||||||
boolean isFirstResource) {
|
.addListener(new RequestListener<Drawable>() {
|
||||||
progressBar.setVisibility(INVISIBLE);
|
@Override
|
||||||
return false;
|
public boolean onLoadFailed(@Nullable GlideException e,
|
||||||
}
|
Object model, Target<Drawable> target,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
progressBar.setVisibility(INVISIBLE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onResourceReady(Drawable resource,
|
public boolean onResourceReady(Drawable resource,
|
||||||
Object model, Target<Drawable> target,
|
Object model, Target<Drawable> target,
|
||||||
DataSource dataSource, boolean isFirstResource) {
|
DataSource dataSource,
|
||||||
progressBar.setVisibility(INVISIBLE);
|
boolean isFirstResource) {
|
||||||
return false;
|
progressBar.setVisibility(INVISIBLE);
|
||||||
}
|
return false;
|
||||||
})
|
}
|
||||||
.into(imageView);
|
})
|
||||||
|
.into(imageView);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user