Suppose I have a recyclerView Adapter which is used to populate views including imageView . When i first load adapter then recycler view items are getting displayed properly . But if i update imageView and textview resource in adapter datasource and call notifyDataSetChanged() method then only textview is getting updated and not imageView . Can anyone help me with this ? Thanks in advance .
For Example - This is the first time i add all the elements in an empty arraylist inside fragment and update using notifyDataSetChanged() method . Till now everything is fine and images are loading correctly in adapter .
Below is the getMethod()
if(remindersListResponse.code == 200)
{
if(remindersListResponse.data != null)
{
photoContactList.clear();
photoContactList.addAll(remindersListResponse.data);
photoContactsAdapter.notifyDataSetChanged();
}
}
Now if i call getMethod again on click of some button in fragment and use notifyDataSetChanged() method . Then only text gets updated in adapter items but not images instead they get disappear .
This is my adapter onBindViewHolder(...) method
@Override
public void onBindViewHolder(@NonNull final ViewHolder viewHolder, int i) {
final PhotoContactsResponse.Result photoContactDetail = photoContactList.get(i);
viewHolder.photoContactName.setText(photoContactDetail.name);
if(photoContactDetail.image!=null && !photoContactDetail.image.isEmpty()) {
viewHolder.addPhotoText.setVisibility(View.GONE);
Picasso.with(context)
.load(Constants.WEB_SERVICE_BASE_URL_FOR_IMAGE+photoContactDetail.image)
.networkPolicy(NetworkPolicy.NO_CACHE)
.memoryPolicy(MemoryPolicy.NO_CACHE)
.into(viewHolder.photoContactImage);
}
else
{
viewHolder.addPhotoText.setVisibility(View.VISIBLE);
viewHolder.photoContactImage.setVisibility(View.GONE);
}
}
This is my model class
public static class Result{
public int id;
public String name;
public String number;
public String image;
public int index;
}