Display first letter of id if display name is empty

This commit is contained in:
Benoit Marty 2019-12-16 11:08:48 +01:00
parent cecef5b8da
commit 0a0eda3e34
1 changed files with 5 additions and 10 deletions

View File

@ -69,16 +69,11 @@ class AvatarRenderer @Inject constructor(private val activeSessionHolder: Active
is MatrixItem.UserItem -> ContextCompat.getColor(context, getColorFromUserId(matrixItem.id))
else -> ContextCompat.getColor(context, getColorFromRoomId(matrixItem.id))
}
return if (matrixItem.displayName.isNullOrBlank()) {
TextDrawable.builder().buildRound("", avatarColor)
} else {
val firstLetter = matrixItem.firstLetterOfDisplayName()
TextDrawable.builder()
.beginConfig()
.bold()
.endConfig()
.buildRound(firstLetter, avatarColor)
}
return TextDrawable.builder()
.beginConfig()
.bold()
.endConfig()
.buildRound(matrixItem.firstLetterOfDisplayName(), avatarColor)
}
// PRIVATE API *********************************************************************************