I have an Android app that allows the user to upload profile pics. They are stored 300px X 300px on the server.
In the app, I use them in either 40dp X 40dp or sometimes 100dp X 100dp. The 40dp's images are in ListView
's. I actually use a very popular third party LazyList
to store the images (using an ImageLoader
class) in a cache. Here is the exact library.
I simply show image in my adapter
like this:
imageLoader.DisplayImage(profileUrl, holder.iv1);
I take the web URL and display it directly into the ImageView
40dp x 40dp.
Sometimes I notice image degradation. Where the image is partially loaded, then is corrupted.
One theory is that going from a large image on the server and trying to store it in a small area in the actual app, then doing this many times in a ListView
, is causing some loading issues.
The question: What is the best way to handle this situation when you have a much larger image in the server than you need to display? I am assuming I may need to use BitMapFactory
or a similar class to build a new image. But I am not sure. I feel like I am missing a step.
Here is an example of an image in a ListView
that has become corrupted, notice this does not happen to all. (And yes that is Tobias from Arrested Development.)
Follow-up: And how do we take in consideration file size for xxhdpi
, xhdpi
, etc when the image is coming from server and not the resources folder?