我正在使用nostra13通用图像加载器从不同社交媒体的api加载图像。 以下是我的适配器类的代码。
imageLoader.displayImage(objects.get(position).getFeedImageUrl(),viewHolder.image, defaultOption, new SimpleImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
viewHolder.spinner.setVisibility(View.VISIBLE);
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
String message = null;
switch (failReason.getType()) {
case IO_ERROR:
message = "Input/Output error";
break;
case DECODING_ERROR:
message = "Image can't be decoded";
break;
case NETWORK_DENIED:
message = "Downloads are denied";
break;
case OUT_OF_MEMORY:
message = "Out Of Memory error";
break;
case UNKNOWN:
message = "Unknown error";
break;
}
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
viewHolder.spinner.setVisibility(View.GONE);
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
viewHolder.spinner.setVisibility(View.GONE);
}
});
}
问题是我在加载照片时显示微调器,并且在onLoadingComplete
中显示。我设置了可见性,但在照片加载完成时仍然可以看到微调器。当我滚动我的列表并回到相同的位置时,只有微调器的可见性消失了。
构造函数中图像加载器的初始化如下:
public MyAdapter(Context context, ArrayList<Model> objects) {
// TODO Auto-generated constructor stub
this.objects=objects;
this.context=context;
defaultOption = new DisplayImageOptions.Builder()
.resetViewBeforeLoading(true)
.showImageForEmptyUri(R.drawable.whitebackground)
.showStubImage(R.drawable.whitebackground)
.showImageOnLoading(R.drawable.whitebackground)
.imageScaleType(ImageScaleType.EXACTLY)
.bitmapConfig(Bitmap.Config.RGB_565)
.considerExifParams(true)
.displayer(new FadeInBitmapDisplayer(300))
.cacheInMemory(true)
.cacheOnDisc(true)
.build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.threadPriority(Thread.MAX_PRIORITY)
.defaultDisplayImageOptions(defaultOption)
.tasksProcessingOrder(QueueProcessingType.FIFO)
.build();
ImageLoader.getInstance().init(config);
imageLoader = ImageLoader.getInstance();
mFont = Typeface.createFromAsset(context.getAssets(), "Beatles Light Light.ttf");
}