GetStream / avatarview-android

✨ Supports loading profile images with fractional styles, shapes, borders, indicators, and initials for Android.
https://getstream.github.io/avatarview-android/
Apache License 2.0
432 stars 26 forks source link

TextDrawable is not being loaded #18

Closed pmrzygweb closed 2 years ago

pmrzygweb commented 2 years ago

I am using this library for name initials placeholder - https://github.com/amulyakhare/TextDrawable However, AvatarView doesn't load TextDrawable somehow Any help is appreciated

skydoves commented 2 years ago

Hi @pmrzygweb, Thank you for reporting this issue. Unfortunately, the TextDrawable you suggested is not supported by Coil and Glide. AvatarView uses Coil and Glide to load network or local images. I would like to suggest just you should implement by overlapping the AvatarView in your layout.

pmrzygweb commented 2 years ago

@skydoves Thanks for your reply. The problem is that I can overlay it for single icon but no way for group icons (more than 2 users)

pmrzygweb commented 2 years ago

@skydoves Do you have any suggestion?

skydoves commented 2 years ago

Hi @pmrzygweb, You can use the TextDrawable because Coil does not support it.

There is one way but it's a bit complicated.

  1. Build a custom AvatarBitmapFactory. You can just copy the StreamAvatarBitmapFactory with some modifications.
  2. As you can reference here, you can load the image by passing Avatar to the loadImage.
  3. Put the initials relevant data as the extra data according to the URLs. So you can take out the extra data from the custom AvatarBitmapFactory and it will draw your initials with the extra data.

You can finally implement the result below:

image

This is quite a complicated way, but this is the only way to accomplish it for now.

skydoves commented 2 years ago

I'll review this if we can support it as an independent artifact in the future!