Vad*_*ovs 9 android universal-image-loader
我正在尝试使用UIL将图像加载到位图.我需要加载多个图像,我注意到在某些情况下图像网址可能是相同的.在这种情况下,只加载第一张图像.如何避免在UIL中取消请求?
代码在循环中运行3次:
ImageSize targetSize = new ImageSize(70, 70);
ImageLoader.getInstance().loadImage("http://icons.iconarchive.com/icons/yellowicon/game-stars/256/Mario-icon.png", targetSize, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
Log.e("tag", "onLoadingStarted");
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
Log.e("tag", "onLoadingFailed");
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
Log.e("tag", "onLoadingComplete");
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
Log.e("tag", "onLoadingCancelled");
}
});
Run Code Online (Sandbox Code Playgroud)
日志是:
onLoadingStarted
onLoadingStarted
onLoadingStarted
onLoadingComplete
onLoadingCancelled
onLoadingCancelled
Run Code Online (Sandbox Code Playgroud)
nos*_*a13 14
UIL取消displayImage(...)同一ImageView的上一个任务.
UIL取消loadImage(...)相同URL的先前任务.
实际上,对于这两种情况,UIL都在ImageAware内部进行操作并进行比较ImageAware.getId()以决定是否取消任务.
在您的情况下,为了防止任务取消,您可以这样做:
ImageSize targetSize = new ImageSize(70, 70);
ImageAware imageAware = new NonViewAware(targetSize, ViewScaleType.CROP);
ImageLoader.getInstance().displayImage("http://icons...", imageAware, ...);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2998 次 |
| 最近记录: |