I have made sure that I only have one instance of ImageLoader so I know that that is not the issue, for some reason, it only lags when it displays a brand new image loaded from the web. So I'm assuming it has something to do with the fact that the UI stutters because it's decoding the image, but I though Universal Image Loader handled everything asynchronously. Here's what I have for my BaseAdapter's getView method.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
JSONObject thePost = null;
try {
thePost = mPosts.getJSONObject(position).getJSONObject("data");
} catch (Exception e) {
System.out.println("errreoroer");
}
LinearLayout postItem = (LinearLayout) inflater.inflate(R.layout.column_post, parent, false);
String postThumbnailUrl = null;
try {
//parse thumbnail
postThumbnailUrl = thePost.getString("thumbnail");
} catch (Exception e) {}
//grab the post view objects
ImageView postThumbnailView = (ImageView)postItem.findViewById(R.id.thumbnail);
if (!(postThumbnailUrl.equals("self") || postThumbnailUrl.equals("default") || postThumbnailUrl.equals("nsfw")))
mImageLoader.displayImage(postThumbnailUrl, postThumbnailView);
return postItem;
}
I think your issue is not the ImageLoader. It is the fact that you aren't utilizing the convertView that the system is passing back to you, so you are not recycling Views at all you are just inflating a new one for each and every row of your List.
Try changing your getView()
method to make use of the convertView:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LinearLayout postItem = convertView
if(null == postItem){
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
postItem = (LinearLayout) inflater.inflate(R.layout.column_post, parent, false);
}
JSONObject thePost = null;
try {
thePost = mPosts.getJSONObject(position).getJSONObject("data");
} catch (Exception e) {
System.out.println("errreoroer");
}
String postThumbnailUrl = null;
try {
//parse thumbnail
postThumbnailUrl = thePost.getString("thumbnail");
} catch (Exception e) {}
//grab the post view objects
ImageView postThumbnailView = (ImageView)postItem.findViewById(R.id.thumbnail);
if (!(postThumbnailUrl.equals("self") || postThumbnailUrl.equals("default") || postThumbnailUrl.equals("nsfw")))
mImageLoader.displayImage(postThumbnailUrl, postThumbnailView);
return postItem;
}