Extract logic for creating username into a separate method in the TelegramUiHelper
This commit is contained in:
parent
ce3afc5a38
commit
dfcaa846fd
1 changed files with 12 additions and 7 deletions
|
@ -88,6 +88,17 @@ object TelegramUiHelper {
|
|||
else -> 0
|
||||
}
|
||||
|
||||
fun getUserName(user: TdApi.User): String {
|
||||
var name = "${user.firstName} ${user.lastName}".trim()
|
||||
if (name.isEmpty()) {
|
||||
name = user.username
|
||||
}
|
||||
if (name.isEmpty()) {
|
||||
name = user.phoneNumber
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
fun messageToLocationItem(
|
||||
helper: TelegramHelper,
|
||||
chat: TdApi.Chat,
|
||||
|
@ -129,13 +140,7 @@ object TelegramUiHelper {
|
|||
return LocationItem().apply {
|
||||
chatId = chat.id
|
||||
chatTitle = chat.title
|
||||
name = "${user.firstName} ${user.lastName}".trim()
|
||||
if (name.isEmpty()) {
|
||||
name = user.username
|
||||
}
|
||||
if (name.isEmpty()) {
|
||||
name = user.phoneNumber
|
||||
}
|
||||
name = TelegramUiHelper.getUserName(user)
|
||||
latLon = LatLon(content.location.latitude, content.location.longitude)
|
||||
photoPath = helper.getUserPhotoPath(user)
|
||||
placeholderId = R.drawable.img_user_picture
|
||||
|
|
Loading…
Reference in a new issue