我正在使用Universal Image Loader加载我的应用中的所有图片。 我在加载图片时遇到NullReferenceException:
09-05 09:04:20.376 2704-2737/com.caliatys.mockupbuilder D/ImageLoader﹕ Start display image task [file:///mnt/sdcard/Caliatys.Catalog_ECOGAZ_romania/ECOGAZ SA M2DCn V2.jpg_1024x720]
09-05 09:04:20.376 2704-2737/com.caliatys.mockupbuilder D/ImageLoader﹕ Load image from disk cache [file:///mnt/sdcard/Caliatys.Catalog_ECOGAZ_romania/ECOGAZ SA M2DCn V2.jpg_1024x720]
09-05 09:04:20.376 2704-2737/com.caliatys.mockupbuilder E/ImageLoader﹕ null
java.lang.NullPointerException
at com.nostra13.universalimageloader.core.assist.ViewScaleType.fromImageView(ViewScaleType.java:59)
at com.nostra13.universalimageloader.core.imageaware.ImageViewAware.getScaleType(ImageViewAware.java:105)
at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:261)
at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:222)
at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:135)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
但奇怪的是,在另一个页面中,完全相同的图像装载得很好:
09-05 09:05:13.136 2704-2737/com.caliatys.mockupbuilder D/ImageLoader﹕ Start display image task [file:///mnt/sdcard/Caliatys.Catalog_ECOGAZ_romania/ECOGAZ SA M2DCn V2.jpg_1024x720]
09-05 09:05:13.136 2704-2737/com.caliatys.mockupbuilder D/ImageLoader﹕ Load image from disk cache [file:///mnt/sdcard/Caliatys.Catalog_ECOGAZ_romania/ECOGAZ SA M2DCn V2.jpg_1024x720]
任何想法为什么有时候图像没有显示,这个空的例外?
答案 0 :(得分:0)
我已经解决了这个问题:)
以下是我对ViewScaleType.java的更新:
public static ViewScaleType fromImageView(ImageView imageView)
{
if (imageView != null && imageView.getScaleType() != null)
{
switch (imageView.getScaleType())
{
case FIT_CENTER:
case FIT_XY:
case FIT_START:
case FIT_END:
case CENTER_INSIDE:
return FIT_INSIDE;
case MATRIX:
case CENTER:
case CENTER_CROP:
default:
return CROP;
}
}
return FIT_INSIDE;
}