I am currently using Android Query library for image loading from server.
MAIN PROB: I want to store images first time and then after i want to load images from cache. I have seen here options for Cache Control using memCache and fileCache But i didn't get which is better to use for slow Internet connection and minimum Memory usage.
I have probably following solution with some confusion:
First of all i have used like this:( memCache and fileCache both true
)
aq.id(holder.prodImage).image(holder.prodImagePath, true, true, 0, R.drawable.no_image, aq.getCachedImage(R.drawable.no_image), AQuery.FADE_IN);
But Here he has said that if image is huge, avoid memory caching
But i got problem while network is slow and memory is not sufficient
then after i have tried 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);
}
But its throwing NullPointerException
like following:
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)
what can i do and how i used this library for this simple problem
Please give me Solution.
Your Help would be Appreciated.
Finally got the solution with following code:
Comment here if you didn't get and have any problem.
Thanks.