Skip to content

Commit

Permalink
For avatar initials, strip off any names after a comma
Browse files Browse the repository at this point in the history
  • Loading branch information
moezbhatti committed Feb 6, 2020
1 parent 86f764a commit 70f078f
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ class AvatarView @JvmOverloads constructor(
icon.setTint(theme.textPrimary)

if (name?.isNotEmpty() == true) {
val initials = name?.split(" ").orEmpty()
.filter { name -> name.isNotEmpty() }
.map { name -> name[0].toString() }
val initials = name
?.substringBefore(',')
?.split(" ").orEmpty()
.filter { subname -> subname.isNotEmpty() }
.map { subname -> subname[0].toString() }

initial.text = if (initials.size > 1) initials.first() + initials.last() else initials.first()
icon.visibility = GONE
Expand Down

0 comments on commit 70f078f

Please sign in to comment.