您最终可以检查 ImageAware 的 Loader 是否显示图像
代码 displayImage(String,ImageView) 如下
public void displayImage(String uri, ImageView imageView) {
this.displayImage(uri, (ImageAware)(new ImageViewAware(imageView)), (DisplayImageOptions)null, (ImageLoadingListener)null, (ImageLoadingProgressListener)null);
}
而ImageAware扩展了抽象类ViewAware,这里面有两个重要的方法
protected abstract void setImageDrawableInto(Drawable var1, View var2);
protected abstract void setImageBitmapInto(Bitmap var1, View var2);
查看ImageAware实现的两种方法
protected void setImageDrawableInto(Drawable drawable, View view) {
((ImageView)view).setImageDrawable(drawable);
if(drawable instanceof AnimationDrawable) {
((AnimationDrawable)drawable).start();
}
}
protected void setImageBitmapInto(Bitmap bitmap, View view) {
((ImageView)view).setImageBitmap(bitmap);
}
所以你可以看到 ImageView 使用 setImageBitmap 显示位图,而其他视图将使用 setBackground,这是我的类其他观点
public class CustomViewAware extends ViewAware {
public CustomViewAware(View view) {
super(view);
}
@Override
protected void setImageDrawableInto(Drawable drawable, View view) {
view.setBackgroundDrawable(drawable);
}
@Override
protected void setImageBitmapInto(Bitmap bitmap, View view) {
view.setBackgroundDrawable(new BitmapDrawable(bitmap));
}