Android SDK 2.2.1 IRainbowContact.photo is always null
Does anyone have an answer for the issue below that is I'm now facing?
I'm making an Android app and using the SDK version 2.2.1.
I tried to display a photo of each contact but it always null.
The app read the contact list, an array of IRainbowContact then processes each contact, it can read most of the class members such as lastName, mainEmailAddess but photo.
With a simple debug code below I was noticed the filed always null.
*contact is IRainbowContact
contact.photo?.let { Log.d (TAG, "photo is NOT null")}
-
Official comment
Hi,
Since version 2.1.0, we no longer automatically download the contact photo for two reasons:
- to minimise the impact of a cold start
- to let the developer choose his caching strategy
Currently, there are two ways to retrieve the contact photo:
- You can use the method
RainbowSdk.instance().contacts().getAvatarUrl(IRainbowContact, int)
with this url you can download and save the file or use any library like Glide, Picasso etc to display the photo.
- You can try and use our rainbow avatar library to display a photo of an IRainbowContact in a simple way.
// Add dependency
implementation "com.ale.rainbowx:rainbowavatar:0.2.7"
// Use the AvatarCardView
<com.ale.rainbowx.rainbowavatar.AvatarCardView
android:id="@+id/avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:avatarDimension="small"/>
// Display the contact avatar in the AvatarCardView
findViewById(R.id.avatar).displayContact(IRainbowContact)The library will try to display an avatar if it exists on the server side. Or display the initials of that contact if there is none.
If you only need to display the photos, I encourage you to use the rainbow avatar library as this is its purpose.
Jordan.
Comment actions
Please sign in to leave a comment.
Comments
3 comments