Improved performances upon presence reception by reducing number of unecessary listener notification
This commit is contained in:
parent
8485dea251
commit
90c7528540
3 changed files with 4 additions and 22 deletions
|
@ -50,20 +50,12 @@ open class GenericContactData(private val sipAddress: Address) : ContactDataInte
|
|||
final override val displayName: MutableLiveData<String> = MutableLiveData<String>()
|
||||
final override val securityLevel: MutableLiveData<ChatRoomSecurityLevel> = MutableLiveData<ChatRoomSecurityLevel>()
|
||||
|
||||
private val contactsUpdatedListener = object : ContactsUpdatedListenerStub() {
|
||||
override fun onContactUpdated(friend: Friend) {
|
||||
contactLookup()
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
securityLevel.value = ChatRoomSecurityLevel.ClearText
|
||||
coreContext.contactsManager.addListener(contactsUpdatedListener)
|
||||
contactLookup()
|
||||
}
|
||||
|
||||
open fun destroy() {
|
||||
coreContext.contactsManager.removeListener(contactsUpdatedListener)
|
||||
}
|
||||
|
||||
private fun contactLookup() {
|
||||
|
@ -79,24 +71,11 @@ abstract class GenericContactViewModel(private val sipAddress: Address) : Messag
|
|||
final override val displayName: MutableLiveData<String> = MutableLiveData<String>()
|
||||
final override val securityLevel: MutableLiveData<ChatRoomSecurityLevel> = MutableLiveData<ChatRoomSecurityLevel>()
|
||||
|
||||
private val contactsUpdatedListener = object : ContactsUpdatedListenerStub() {
|
||||
override fun onContactUpdated(friend: Friend) {
|
||||
contactLookup()
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
securityLevel.value = ChatRoomSecurityLevel.ClearText
|
||||
coreContext.contactsManager.addListener(contactsUpdatedListener)
|
||||
contactLookup()
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
coreContext.contactsManager.removeListener(contactsUpdatedListener)
|
||||
|
||||
super.onCleared()
|
||||
}
|
||||
|
||||
private fun contactLookup() {
|
||||
displayName.value = LinphoneUtils.getDisplayName(sipAddress)
|
||||
contact.value = coreContext.contactsManager.findContactByAddress(sipAddress)
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.linphone.R
|
|||
import org.linphone.core.Factory
|
||||
import org.linphone.core.Friend
|
||||
import org.linphone.core.GlobalState
|
||||
import org.linphone.core.SubscribePolicy
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
import org.linphone.utils.PhoneNumberUtils
|
||||
|
@ -136,7 +137,10 @@ class ContactLoader : LoaderManager.LoaderCallbacks<Cursor> {
|
|||
friend.starred = starred
|
||||
friend.nativeUri =
|
||||
"${ContactsContract.Contacts.CONTENT_LOOKUP_URI}/$lookupKey"
|
||||
|
||||
// Disable short term presence
|
||||
friend.isSubscribesEnabled = false
|
||||
friend.incSubscribePolicy = SubscribePolicy.SPDeny
|
||||
}
|
||||
|
||||
when (mime) {
|
||||
|
|
|
@ -283,7 +283,6 @@ class ContactsManager(private val context: Context) {
|
|||
val id = friend.refKey
|
||||
if (id != null) {
|
||||
storePresenceInNativeContact(friend)
|
||||
notifyListeners(friend)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue