mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed contacts list issue when changing filter
This commit is contained in:
parent
ac1ae71f11
commit
b66a40fa41
2 changed files with 28 additions and 3 deletions
|
|
@ -218,6 +218,29 @@ class ContactsManager @UiThread constructor(context: Context) {
|
|||
return avatar
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun getContactAvatarModelForFriend(friend: Friend?): ContactAvatarModel {
|
||||
if (friend == null) {
|
||||
val fakeFriend = coreContext.core.createFriend()
|
||||
return ContactAvatarModel(fakeFriend)
|
||||
}
|
||||
|
||||
val address = friend.address ?: friend.addresses.firstOrNull()
|
||||
?: return ContactAvatarModel(friend)
|
||||
|
||||
val clone = address.clone()
|
||||
clone.clean()
|
||||
val key = clone.asStringUriOnly()
|
||||
|
||||
val foundInMap = if (avatarsMap.keys.contains(key)) avatarsMap[key] else null
|
||||
if (foundInMap != null) return foundInMap
|
||||
|
||||
val avatar = ContactAvatarModel(friend)
|
||||
avatarsMap[key] = avatar
|
||||
|
||||
return avatar
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun getContactAvatarModelForConferenceInfo(conferenceInfo: ConferenceInfo): ContactAvatarModel {
|
||||
// Do not clean parameters!
|
||||
|
|
|
|||
|
|
@ -106,7 +106,6 @@ class ContactsListViewModel @UiThread constructor() : AbstractTopBarViewModel()
|
|||
coreContext.postOnCoreThread {
|
||||
magicSearch.removeListener(magicSearchListener)
|
||||
coreContext.contactsManager.removeListener(contactsListener)
|
||||
contactsList.value.orEmpty().forEach(ContactAvatarModel::destroy)
|
||||
}
|
||||
super.onCleared()
|
||||
}
|
||||
|
|
@ -139,7 +138,6 @@ class ContactsListViewModel @UiThread constructor() : AbstractTopBarViewModel()
|
|||
@WorkerThread
|
||||
fun processMagicSearchResults(results: Array<SearchResult>) {
|
||||
Log.i("$TAG Processing [${results.size}] results")
|
||||
contactsList.value.orEmpty().forEach(ContactAvatarModel::destroy)
|
||||
|
||||
val list = arrayListOf<ContactAvatarModel>()
|
||||
val favouritesList = arrayListOf<ContactAvatarModel>()
|
||||
|
|
@ -149,7 +147,11 @@ class ContactsListViewModel @UiThread constructor() : AbstractTopBarViewModel()
|
|||
for (result in results) {
|
||||
val friend = result.friend
|
||||
|
||||
val model = coreContext.contactsManager.getContactAvatarModelForAddress(result.address)
|
||||
val model = if (friend != null) {
|
||||
coreContext.contactsManager.getContactAvatarModelForFriend(friend)
|
||||
} else {
|
||||
coreContext.contactsManager.getContactAvatarModelForAddress(result.address)
|
||||
}
|
||||
|
||||
val currentLetter = model.friend.name?.get(0).toString()
|
||||
val displayLetter = previousLetter.isEmpty() || currentLetter != previousLetter
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue