Commit c06bf994 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Handle odd usernames with dots such as ..., .Foo., .., Foo.. which as causing...

Handle odd usernames with dots such as ..., .Foo., .., Foo.. which as causing a crash when building the default avatar image
parent e315b760
...@@ -69,8 +69,11 @@ object UserAvatarHelper { ...@@ -69,8 +69,11 @@ object UserAvatarHelper {
} }
val splitUsername = username.split(".") val splitUsername = username.split(".")
if (splitUsername.size > 1) { val splitCount = splitUsername.size
return (splitUsername[0].substring(0, 1) + splitUsername[splitUsername.size - 1].substring(0, 1)).toUpperCase() if (splitCount > 1 && splitUsername[0].isNotEmpty() && splitUsername[1].isNotEmpty()) {
val firstInitial = splitUsername[0].substring(0, 1)
val secondInitial = splitUsername[1].substring(0, 1)
return (firstInitial + secondInitial).toUpperCase()
} else { } else {
if (username.length > 1) { if (username.length > 1) {
return username.substring(0, 2).toUpperCase() return username.substring(0, 2).toUpperCase()
......
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