我已经加载图像后立即做一些东西。我使用SimpleImageLoadingListener
来侦听回调方法,但奇怪的是onLoadingComplete
永远不会被调用,但onLoadingStarted
会。我检查过没有调用图像加载失败或取消方法 - 这意味着没有错误。任何人都可以指出原因和步骤来纠正它。谢谢。onLoadingComplete通用图像加载器不叫
public View getView(int position, View convertView, ViewGroup parent) {
ImageView img = new ImageView(mContext);
img.setLayoutParams(new Gallery.LayoutParams(coverflowWidth, coverflowHeight));
img.setScaleType(ScaleType.CENTER_INSIDE);
img.setTag(position);
ImageLoader.getInstance().displayImage(imageURL, img, options, new SimpleImageLoadingListener()
{
boolean cacheFound;
@Override
public void onLoadingStarted(String url, View view) {
List<String> memCache = MemoryCacheUtil.findCacheKeysForImageUri(url, ImageLoader.getInstance().getMemoryCache());
cacheFound = !memCache.isEmpty();
if (!cacheFound) {
File discCache = DiscCacheUtil.findInCache(url, ImageLoader.getInstance().getDiscCache());
if (discCache != null) {
cacheFound = discCache.exists();
}
}
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
//never gets called
ImageView image = (ImageView) view;
if (cacheFound) {
image.setImageBitmap(loadedImage);
}
else
{
ImageLoader.getInstance().displayImage(imageURL, image, options, null);
}
}
});
return img;
}