mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Add/remove friend list listener when created/destroyed while app is alive
This commit is contained in:
parent
2580e822f5
commit
cc38e3936b
1 changed files with 12 additions and 0 deletions
|
|
@ -91,6 +91,16 @@ class ContactsManager(private val context: Context) {
|
|||
}
|
||||
}
|
||||
|
||||
private val coreListener: CoreListenerStub = object : CoreListenerStub() {
|
||||
override fun onFriendListCreated(core: Core, friendList: FriendList) {
|
||||
friendList.addListener(friendListListener)
|
||||
}
|
||||
|
||||
override fun onFriendListRemoved(core: Core, friendList: FriendList) {
|
||||
friendList.removeListener(friendListListener)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
initSyncAccount()
|
||||
|
||||
|
|
@ -99,6 +109,7 @@ class ContactsManager(private val context: Context) {
|
|||
groupBitmap = BitmapFactory.decodeResource(context.resources, R.drawable.voip_multiple_contacts_avatar_alt)
|
||||
|
||||
val core = coreContext.core
|
||||
core.addListener(coreListener)
|
||||
for (list in core.friendsLists) {
|
||||
list.addListener(friendListListener)
|
||||
}
|
||||
|
|
@ -224,6 +235,7 @@ class ContactsManager(private val context: Context) {
|
|||
fun destroy() {
|
||||
val core = coreContext.core
|
||||
for (list in core.friendsLists) list.removeListener(friendListListener)
|
||||
core.removeListener(coreListener)
|
||||
}
|
||||
|
||||
private fun initSyncAccount() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue