AQuery (Android Query) How to actually upload images

I am currently using the Android Query library to download images from a server.

MAIN TRIAL: I want to save images for the first time, and then after loading images from the cache. I saw Cache Control options here using memCache and fileCache . But I did not get, which is better to use for a slow Internet connection and minimal memory usage .

I probably follow the solution with some confusion:

First of all, I used like this :( memCache and fileCache like 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 said thatif image is huge, avoid memory caching

But I have a problem, and the network is slow, and there is not enough memory.

after I tried Image Upload Delay :

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 his cast is NullPointerExceptionas follows:

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 did i use this library for this simple task

Please give me a solution.

Your help will be appreciated.

+4
source share
1 answer

Finally, I got a solution with the following code:

/* Settings of Image */
//set the max number of concurrent network connections, default is 4
AjaxCallback.setNetworkLimit(8);

//set the max number of icons (image width <= 50) to be cached in memory, default is 20
BitmapAjaxCallback.setIconCacheLimit(50);

//set the max number of images (image width > 50) to be cached in memory, default is 20
BitmapAjaxCallback.setCacheLimit(50);

aq = new AQuery(context);

/* Getting Images from Server and stored in cache */
aq.id(holder.prodImageView).progress(convertView.findViewById(R.id.progressBar1)).image(holder.prodImagePath, true, true, 0, R.drawable.no_image, null, AQuery.FADE_IN);

Comment here if you have not received and found no problems.

Thanks.

+4
source

All Articles