mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-27 19:36:21 +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
|
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
|
@WorkerThread
|
||||||
fun getContactAvatarModelForConferenceInfo(conferenceInfo: ConferenceInfo): ContactAvatarModel {
|
fun getContactAvatarModelForConferenceInfo(conferenceInfo: ConferenceInfo): ContactAvatarModel {
|
||||||
// Do not clean parameters!
|
// Do not clean parameters!
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,6 @@ class ContactsListViewModel @UiThread constructor() : AbstractTopBarViewModel()
|
||||||
coreContext.postOnCoreThread {
|
coreContext.postOnCoreThread {
|
||||||
magicSearch.removeListener(magicSearchListener)
|
magicSearch.removeListener(magicSearchListener)
|
||||||
coreContext.contactsManager.removeListener(contactsListener)
|
coreContext.contactsManager.removeListener(contactsListener)
|
||||||
contactsList.value.orEmpty().forEach(ContactAvatarModel::destroy)
|
|
||||||
}
|
}
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
}
|
}
|
||||||
|
|
@ -139,7 +138,6 @@ class ContactsListViewModel @UiThread constructor() : AbstractTopBarViewModel()
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
fun processMagicSearchResults(results: Array<SearchResult>) {
|
fun processMagicSearchResults(results: Array<SearchResult>) {
|
||||||
Log.i("$TAG Processing [${results.size}] results")
|
Log.i("$TAG Processing [${results.size}] results")
|
||||||
contactsList.value.orEmpty().forEach(ContactAvatarModel::destroy)
|
|
||||||
|
|
||||||
val list = arrayListOf<ContactAvatarModel>()
|
val list = arrayListOf<ContactAvatarModel>()
|
||||||
val favouritesList = arrayListOf<ContactAvatarModel>()
|
val favouritesList = arrayListOf<ContactAvatarModel>()
|
||||||
|
|
@ -149,7 +147,11 @@ class ContactsListViewModel @UiThread constructor() : AbstractTopBarViewModel()
|
||||||
for (result in results) {
|
for (result in results) {
|
||||||
val friend = result.friend
|
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 currentLetter = model.friend.name?.get(0).toString()
|
||||||
val displayLetter = previousLetter.isEmpty() || currentLetter != previousLetter
|
val displayLetter = previousLetter.isEmpty() || currentLetter != previousLetter
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue