mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 03:28:52 +01:00
Only store necessary strings in AvatarView, instead of realm model (contact or recipient)
This commit is contained in:
@@ -18,12 +18,10 @@
|
||||
*/
|
||||
package model
|
||||
|
||||
import android.telephony.PhoneNumberUtils
|
||||
import io.realm.RealmList
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.Index
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import java.util.*
|
||||
|
||||
open class Conversation : RealmObject() {
|
||||
|
||||
@@ -38,9 +36,5 @@ open class Conversation : RealmObject() {
|
||||
var me: Boolean = false
|
||||
var draft: String = ""
|
||||
|
||||
fun getTitle() = recipients.joinToString { recipient ->
|
||||
recipient.contact?.name?.takeIf { it.isNotBlank() }
|
||||
?: PhoneNumberUtils.formatNumber(recipient.address, Locale.getDefault().country)
|
||||
?: recipient.address
|
||||
}
|
||||
fun getTitle() = recipients.joinToString { recipient -> recipient.getDisplayName() }
|
||||
}
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
*/
|
||||
package model
|
||||
|
||||
import android.telephony.PhoneNumberUtils
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import java.util.*
|
||||
|
||||
open class Recipient : RealmObject() {
|
||||
|
||||
@@ -28,4 +30,11 @@ open class Recipient : RealmObject() {
|
||||
var contact: Contact? = null
|
||||
var lastUpdate: Long = 0
|
||||
|
||||
/**
|
||||
* Return a string that can be displayed to represent the name of this contact
|
||||
*/
|
||||
fun getDisplayName(): String = contact?.name?.takeIf { it.isNotBlank() }
|
||||
?: PhoneNumberUtils.formatNumber(address, Locale.getDefault().country)
|
||||
?: address
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user