akashjaindev / ImageLetterIcon

Material letter icon with circle background. Also supports for image for user contact.
Apache License 2.0
213 stars 50 forks source link

Using Picasso or setImageResource with MaterialLetterIcon #6

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi,

I have the following use case:

The flow:

I am using the same ImageView for all 3 cases. The ImageView is a MaterialLetterIcon.

The problem:

Example:

Solutions:

Version of lib:

What solution / approach do you suggest?

Thank you.

akashjaindev commented 7 years ago

hello

using more than one image view is not feasible. So you need to update view in your adapter for each position. I may need to see your adapter class so that I can figure out the issue.

Akash Jain

ghost commented 7 years ago

Hi,

I am not using more than one imageView, that was a solution I tried (to have multiple imageViews and handling their visibility).

I cannot provide the code, but I'll give you the image handling issue. Note: MyPicassoTarget is setting the contact name (letters) in cause of url failure.

class ContactViewHolder extends RecyclerView.ViewHolder {
   public MaterialLetterIcon ivContact;
//more code
}

//more code, this snippet is when inflating the row
if (!contact.isAccepted()) {
   holder.ivContact.setShapeType(MaterialLetterIcon.SHAPE_NORMAL);
   holder.ivContact.setImageResource(R.drawable.my_drawable);
} else {
   if (contact.hasProfilePicture()) {
       MyPicassoTarget target = new MyPicassoTarget(holder.ivContact).setTextIcon(contact.getFullName());
       holder.ivContact.setTag(target);
       Picasso.with(holder.ivContact.getContext()).load(contact.getProfileUrl()).into(target);
   } else {
       holder.ivContact.setShapeColor(ContextCompat.getColor(holder.ivContact.getContext(), R.color.my_color));
       holder.ivContact.setLetter(contact.getFullName());
   }
akashjaindev commented 7 years ago

hello you can use textdrawble as an placeholder for showing for showing drawable while loading image from picasso.

ghost commented 7 years ago

Hi,

Thanks. But what should I use the case without Picasso? This is my main issue now. I'll simplify the code:

if (!contact.isAccepted()) {
   holder.ivContact.setShapeType(MaterialLetterIcon.SHAPE_NORMAL);
   holder.ivContact.setImageResource(R.drawable.my_drawable);
} else {
       holder.ivContact.setShapeColor(ContextCompat.getColor(holder.ivContact.getContext(), R.color.my_color));
       holder.ivContact.setLetter(contact.getFullName());
   }
akashjaindev commented 7 years ago

hello i haven't find any such case but i will check and if there is any issue i will update you. One more thing are you changing shape of imageview according to your condition since as i am seeing you have change shape type only when contact is not accepted.

Akash Jain

akashjaindev commented 7 years ago

hello i have tried in a sample but i am not getting any such problem. Make sure you are using latest library using: compile 'com.github.akashandroid90:imageletter:1.8@aar' Let me know if there is still error. Akash Jain

ghost commented 7 years ago

Hi, I tried using the latest lib you mentioned, still happens. I noticed you mention about the shape changing, I will try and see if this is the cause. The shape should be the same, no matter the condition.

akashjaindev commented 7 years ago

ok. let me know if there is still any issue.