Commit 95fcf7b9 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

avatar: handle null bitmap

Change-Id: Ibc4601b40dbcd7c2ade6df360a5ff76fc88a07ae
parent eaddf85b
......@@ -96,7 +96,7 @@ object AvatarFactory {
.map { d -> BitmapUtils.drawableToBitmap(d, size) }
}
private fun getDrawable(context: Context, photo: Bitmap, profileName: String?, username: String?, id: String): Drawable {
private fun getDrawable(context: Context, photo: Bitmap?, profileName: String?, username: String?, id: String): Drawable {
return AvatarDrawable.Builder()
.withPhoto(photo)
.withName(if (TextUtils.isEmpty(profileName)) username else profileName)
......@@ -107,12 +107,12 @@ object AvatarFactory {
fun clearCache() {}
private fun <T> getGlideRequest(context: Context, request: RequestBuilder<T>, photo: Bitmap, profileName: String?, username: String?, id: String): RequestBuilder<T> {
private fun <T> getGlideRequest(context: Context, request: RequestBuilder<T>, photo: Bitmap?, profileName: String?, username: String?, id: String): RequestBuilder<T> {
return request.load(getDrawable(context, photo, profileName, username, id))
}
private fun getGlideAvatar(context: Context, manager: RequestManager, contact: Contact): RequestBuilder<Drawable> {
return getGlideRequest(context, manager.asDrawable(), contact.photo as Bitmap, contact.profileName, contact.username, contact.primaryNumber)
return getGlideRequest(context, manager.asDrawable(), contact.photo as Bitmap?, contact.profileName, contact.username, contact.primaryNumber)
}
private fun getGlideAvatar(context: Context, contact: Contact): RequestBuilder<Drawable> {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment