【发布时间】:2018-03-19 01:20:55
【问题描述】:
- 我使用 Universal Image Loader 从服务器加载图像并将其缓存到内存中以便快速加载。
- 但从服务器端使用相同的 URL 更新图像。
- 例如,www.example.com/xyz.png 是图像的 URL,当他们需要更新图像时,他们返回相同的 URL 和不同的图像。
- 在这种情况下,Universal Image Loader 返回先前缓存在内存中的图像(我认为它使用其相关 URL 缓存了图像)。
- 因此,如果 URL 返回不同的图像,我需要更改图像。
这是我用来加载图片的代码
DisplayImageOption.java
public class DisplayImageOption {
public static DisplayImageOptions getDisplayImage() {
// .displayer(new RoundedBitmapDisplayer(0))
return new DisplayImageOptions.Builder()
.showImageOnLoading(R.mipmap.icon_place_holder)
.showImageForEmptyUri(R.mipmap.icon_place_holder)
.showImageOnFail(R.mipmap.icon_place_holder)
.cacheInMemory(true)
.cacheOnDisk(true)
.considerExifParams(true).build();
}
public static DisplayImageOptions getDisplayRoundedImage() {
return new DisplayImageOptions.Builder()
.showImageOnLoading(R.mipmap.icon_place_holder)
.showImageForEmptyUri(R.mipmap.icon_place_holder)
.showImageOnFail(R.mipmap.icon_place_holder)
.cacheInMemory(true)
.cacheOnDisk(true)
.considerExifParams(true)
.displayer(new RoundedBitmapDisplayer(100)).build();
}
}
图片加载代码
ImageLoader.getInstance().displayImage(url, imageView, DisplayImageOption.getDisplayImage());
谢谢
【问题讨论】:
标签: android universal-image-loader