Question

I am stuck up at one point. I need suggestions for the same. I am creating an application which involves json parsing. After the parsing I am getting data which involves event name, event description, event place, event image url and so on. The data is huge. You can imagine facebook kinda stuff.

Now the problem is the data is getting parsed but because the event image is in the form of url, I need to convert it into Bitmap. I have kept all the process of json parsing and bitmap conversion into one AsyncTask(doInBackground()).

This is taking a lot amount of time. I want something like facebook that the data gets loaded and is shown to the end user but the images load slowly and steadily. (I mean when we scroll facebook, then images don't come up immediately).

I want a similar functionality. I need suggestions.

Was it helpful?

Solution

You can still use an AsyncTask, only you'll need to use two seperate tasks. One for the loading and parsing of the JSON, and one for the loading of the image.

After parsing the JSON, you'll need to start an AsyncTask for every image you're trying to load, making them all load on their own thread. It will show once the item is done loading.

OTHER TIPS

Here is solution for you https://github.com/nostra13/Android-Universal-Image-Loader

You just pass url and imageview resource to loader, and it handles everithing for you. Also support caching. This library is simple and widly used

This concept is called Lazy Loading (AFAIK). You can use already development ImageLoader for this. It will download Image in Background and once it download it will set as background of ImageView. See Custom Downloader

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top