1
0
mirror of https://github.com/TwidereProject/Twidere-Android synced 2025-01-31 17:04:59 +01:00

supports conversation name

This commit is contained in:
Mariotaku Lee 2017-02-13 14:06:40 +08:00
parent 39d77df300
commit 3842396f36
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
2 changed files with 8 additions and 5 deletions

View File

@ -29,14 +29,16 @@ fun ParcelableMessageConversation.applyFrom(message: ParcelableMessage, details:
val ParcelableMessageConversation.timestamp: Long
get() = if (message_timestamp > 0) message_timestamp else local_timestamp
fun ParcelableMessageConversation.getConversationName(context: Context): Pair<String, String?> {
fun ParcelableMessageConversation.getConversationName(context: Context,
manager: UserColorNameManager): Pair<String, String?> {
if (conversation_type == ConversationType.ONE_TO_ONE) {
val user = this.user ?: return Pair(context.getString(R.string.direct_messages), null)
return Pair(user.name, user.screen_name)
}
return Pair(participants.joinToString(separator = ", ") {
it.name
}, null)
if (conversation_name != null) {
return Pair(conversation_name, null)
}
return Pair(participants.joinToString(separator = ", ") { manager.getDisplayName(it, false) }, null)
}
fun ParcelableMessageConversation.getSummaryText(context: Context, manager: UserColorNameManager,

View File

@ -54,7 +54,8 @@ class MessageEntryViewHolder(itemView: View, val adapter: MessagesEntriesAdapter
} else {
content.drawEnd()
}
val (name, secondaryName) = conversation.getConversationName(itemView.context)
val (name, secondaryName) = conversation.getConversationName(itemView.context,
adapter.userColorNameManager)
this.time.time = conversation.timestamp
this.name.name = name
this.name.screenName = secondaryName