Reputation: 1144
So I am trying to load about 25 images at once using the AsyncTask class.
In short I'm calling this inside the AsyncTask to download the image from the server:
Url = new URL(url);
HttpURLConnection urlConnection = (HttpURLConnection) Url.openConnection();
bitmap = BitmapFactory.decodeStream(urlConnection.getInputStream());
urlConnection.disconnect();
As you can see in this video, it results in poor performance. Presumably because it is loading the images one at a time as the AsyncTask queues each of them up, I think?
http://www.youtube.com/watch?v=7dqVqLn5Ibs
So the solution would be to load them all asynchronously, but I dont know how I would achieve this without needed a whole lot of new code?
Upvotes: 0
Views: 502
Reputation: 12536
You can do that easily using Universal image loader. It loads each image in separate thread.It is very easy to use and takes care of most of the things like caching..etc.
Ex usage:
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.init(ImageLoaderConfiguration.createDefault(context));
imageLoader.displayImage(imageUrl, imageView);
Upvotes: 1