4
我目前使用Android Query库从服务器加载图像。AQuery(Android Query)如何实际加载图像
主要问题: 我想要第一次存储图像,然后我想从缓存中加载图像后。 我一直在使用MEMCACHE和fileCache这里看到选项Cache Control但我没有得到这是更好地使用互联网连接速度较慢和最小内存使用。
我可能已经在与一些混乱的解决方案:
,首先我用这样的:(MEMCACHE和fileCache都true
)
aq.id(holder.prodImage).image(holder.prodImagePath, true, true, 0, R.drawable.no_image, aq.getCachedImage(R.drawable.no_image), AQuery.FADE_IN);
但Here他说, if image is huge, avoid memory caching
但我得到了问题,而网络很慢记忆是不够的
然后我试图Delay Image Loading后:
if(aq.shouldDelay(position, convertView, parent, holder.prodImagePath)){
aq.id(holder.prodImage).image(R.drawable.no_image);
} else {
aq.id(holder.prodImage).progress(view.findViewById(R.id.progressBar1)).image(holder.prodImagePath, false, true, 0, 0, null, AQuery.FADE_IN);
}
但它扔NullPointerException
类似以下内容:
12-10 12:11:26.492: E/AndroidRuntime(23309): java.lang.NullPointerException
12-10 12:11:26.492: E/AndroidRuntime(23309): at com.androidquery.util.Common.shouldDelay(Common.java:328)
12-10 12:11:26.492: E/AndroidRuntime(23309): at com.androidquery.util.Common.shouldDelay(Common.java:340)
12-10 12:11:26.492: E/AndroidRuntime(23309): at com.androidquery.AbstractAQuery.shouldDelay(AbstractAQuery.java:2389)
12-10 12:11:26.492: E/AndroidRuntime(23309): at com.salesman.fragments.ProductFragment$MyGridViewAdapter.getView(ProductFragment.java:423)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.AbsListView.obtainView(AbsListView.java:2477)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.GridView.makeAndAddView(GridView.java:1331)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.GridView.makeRow(GridView.java:331)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.GridView.fillDown(GridView.java:283)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.GridView.fillGap(GridView.java:243)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5549)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4693)
我能做些什么,我怎么使用这个库本简单问题
请给我解决方案。
您的帮助将被赞赏。
我们如何从缓存中检索图像或检查它是否存在含有aquery的缓存中。 – user2779311
@ user2779311'aq.getCachedImage(“your url”);' 返回图片请求缓存的位图。如果URL未被缓存,则返回null。 –
完美的解决方案... – Kamlesh