I am using ImageLoader in order to load images to a ListView.
This is the code I am using to load the image:
ImageLoader.getInstance().displayImage(url, holder.image, options, animateFirstListener);
When the app is loaded the table is shown well, but the images are not loaded. If I scroll the table down and then up images are loaded properly. All other images are loaded properly. Only the first images presented when the app runs are not loaded for some reason. The rest of the cell data is filled OK.
I added to the listener: AnimateFirstDisplayListener the "onLoadingFailed" method in order to try and understand the problem. It returns the fail error: DECODING_ERROR.
OK. I think I got it. I use this line to build the URL:
String url = "http://www.domain.com/getImage?newsId=" + feedItem.getId() + "&w=" +
holder.image.getWidth() + "&h=" + holder.image.getHeight();
The method: holder.image.getWith() (and getHeight) returns "0" on the initial load. Does anyone has a clue why is it?
The reason for this issue happened because the methods:
holder.image.getWidth()
holder.image.getHeight()
returned: 0. This probably happened since Android didn't have the size yet. The solution I used came from @Sharj's url.