I have GridView in which images are being downloaded from server, I have used lazy loading methodology for asynchronously adding images to grid.
I can see getView method being called many times and inconsistently for positions of grid view till images are being downloaded for position.
Now, when i scroll gridview, images which are already downloaded for position are now getting replaced by other images.
But after all images are downloaded for position, it works fine.
I know and have read previous post for getView inconsistent call, but still not able to resolve issue.
`@Override public View getView(final int position, View convertView, final ViewGroup viewGroup) { ViewHolder viewHolder;
if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.ondemand_grid_item,
null);
viewHolder = new ViewHolder();
viewHolder.title = ((TextView) convertView
.findViewById(R.id.ondemand_grid_item_title));
viewHolder.image = ((ImageView) convertView
.findViewById(R.id.ondemand_grid_item_image));
viewHolder.iconImage = ((ImageView) convertView
.findViewById(R.id.on_demand_trailer_icon));
viewHolder.showSelectedImage = (ImageView) convertView.findViewById(R.id.ondemand_grid_item_img);
viewHolder.showSelectedImage.setVisibility(View.INVISIBLE);
viewHolder.showSelectedImage.setSelected(true);
viewHolder.seasonNumber = (TextView) convertView.findViewById(R.id.ondemand_grid_item_season);
viewHolder.seasonNumber.setVisibility(View.INVISIBLE);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
final OnDemandItem onDemandItem = getItem(position);
imageLoader.DisplayImage(onDemandItem.getPosterUrl(), viewHolder.image, onDemandItem.getGenrePlaceHolder());
showHideTrailerIcon(viewHolder, onDemandItem);
if (onDemandItem.getType() == AssetTypeEnum.SERIE) {
if (onDemandItem.getSeasonNumber() != null && !"".equals(onDemandItem.getSeasonNumber())) {
viewHolder.seasonNumber.setVisibility(View.VISIBLE);
viewHolder.seasonNumber.setText("Seizoen " + onDemandItem.getSeasonNumber());
}
}
viewHolder.title.setText(onDemandItem.getTitle());
if (selectedOndemandItemId == onDemandItem.getId()) {
convertView.findViewById(R.id.ondemand_grid_item_img).setVisibility(View.VISIBLE);
} else {
ImageView showSelectedImage = (ImageView) convertView.findViewById(R.id.ondemand_grid_item_img);
if (showSelectedImage != null) {
showSelectedImage.setVisibility(View.INVISIBLE);
}
}
return convertView;
}`
Where: imageLoader.DisplayImage(onDemandItem.getPosterUrl(), viewHolder.image, onDemandItem.getGenrePlaceHolder()); is image asynchronous download method