Fixed crash in AppUtils.getInitials
This commit is contained in:
parent
ffbc209c69
commit
e19ab356d4
1 changed files with 7 additions and 4 deletions
|
@ -97,12 +97,15 @@ class AppUtils {
|
|||
if (displayName.isEmpty()) return ""
|
||||
|
||||
val split = displayName.toUpperCase(Locale.getDefault()).split(" ")
|
||||
return when (split.size) {
|
||||
0 -> ""
|
||||
1 -> split[0][0].toString()
|
||||
else -> split[0][0].toString() + split[1][0].toString()
|
||||
var initials = ""
|
||||
for (i in split.indices) {
|
||||
if (split[i].isNotEmpty()) {
|
||||
initials += split[i][0]
|
||||
if (initials.length >= 2) break
|
||||
}
|
||||
}
|
||||
return initials
|
||||
}
|
||||
|
||||
fun pixelsToDp(pixels: Float): Float {
|
||||
return TypedValue.applyDimension(
|
||||
|
|
Loading…
Reference in a new issue