I'm using the ParseQueryAdapter to set up a listview with data from my Parse sever. I have 3 rows in my table, two doesn't contain an image and one does. If an image doesn't exist on the server, I set my own default image from my resources. But when the listview finishes its loading, two of the rows have the same image (the one from the server).
*In debug, I see the first two rows get the default image, and only then when I the image from the server is loaded, the first row also get it.
This is my getItemView from the ParseQueryAdapter:
@Override
public View getItemView(ParseGame parseGame, View v, ViewGroup parent) {
View view = v;
ViewHolder holder;
if (v == null) {
view = View.inflate(getContext(), R.layout.shared_games_listview_layout, null);
holder = new ViewHolder();
holder.image = (ParseImageView) view.findViewById(R.id.imageViewParseImage);
holder.type = (TextView) view.findViewById(R.id.textViewType);
holder.name = (TextView) view.findViewById(R.id.textViewName);
holder.level = (TextView) view.findViewById(R.id.textViewLevel);
view.setTag(holder);
}
else {
holder = (ViewHolder) view.getTag();
}
super.getItemView(parseGame, v, parent);
ParseFile photoFile = parseGame.getParseFile("gameImage");
if (photoFile != null) {
holder.image.setParseFile(photoFile);
holder.image.loadInBackground();
}
else {
int width = imageWidth;
int height = imageHeight;
if (parseGame.getType().equals(Game.GameType.PUZZLE.toString())) {
int resId = R.drawable.puzzle_default;
holder.image.setImageBitmap(imageUtils.getBitmap(resId, width, height));
}
else {
holder.image.setImageResource(R.drawable.default_image);
}
}
}
And this is the holder:
public static class ViewHolder {
public ParseImageView image;
public TextView type;
public TextView name;
public TextView level;
}
What should I do so that each row will get its own image?