Fixed concurrent modification exception that can happen
This commit is contained in:
parent
8cf401f7ab
commit
766891301c
1 changed files with 15 additions and 7 deletions
|
@ -25,6 +25,7 @@ import android.content.ContentResolver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.database.ContentObserver
|
import android.database.ContentObserver
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.AsyncTask
|
||||||
import android.os.AsyncTask.THREAD_POOL_EXECUTOR
|
import android.os.AsyncTask.THREAD_POOL_EXECUTOR
|
||||||
import android.provider.ContactsContract
|
import android.provider.ContactsContract
|
||||||
import android.util.Patterns
|
import android.util.Patterns
|
||||||
|
@ -290,15 +291,18 @@ class ContactsManager(private val context: Context) {
|
||||||
|
|
||||||
val contact: Contact = friend.userData as Contact
|
val contact: Contact = friend.userData as Contact
|
||||||
Log.d("[Contacts Manager] Received presence information for contact $contact")
|
Log.d("[Contacts Manager] Received presence information for contact $contact")
|
||||||
for (listener in contactsUpdatedListeners) {
|
|
||||||
listener.onContactUpdated(contact)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (corePreferences.storePresenceInNativeContact && PermissionHelper.get().hasWriteContactsPermission()) {
|
if (corePreferences.storePresenceInNativeContact && PermissionHelper.get().hasWriteContactsPermission()) {
|
||||||
if (contact is NativeContact) {
|
if (contact is NativeContact) {
|
||||||
storePresenceInNativeContact(contact)
|
storePresenceInNativeContact(contact)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (loadContactsTask?.status == AsyncTask.Status.RUNNING) {
|
||||||
|
Log.w("[Contacts Manager] Async contacts loader running, skip onContactUpdated listener notify")
|
||||||
|
} else {
|
||||||
|
for (listener in contactsUpdatedListeners) {
|
||||||
|
listener.onContactUpdated(contact)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!sipContacts.contains(contact)) {
|
if (!sipContacts.contains(contact)) {
|
||||||
sipContacts.add(contact)
|
sipContacts.add(contact)
|
||||||
|
@ -317,6 +321,13 @@ class ContactsManager(private val context: Context) {
|
||||||
val contact: Contact = friend.userData as Contact
|
val contact: Contact = friend.userData as Contact
|
||||||
if (contact is NativeContact) {
|
if (contact is NativeContact) {
|
||||||
storePresenceInNativeContact(contact)
|
storePresenceInNativeContact(contact)
|
||||||
|
if (loadContactsTask?.status == AsyncTask.Status.RUNNING) {
|
||||||
|
Log.w("[Contacts Manager] Async contacts loader running, skip onContactUpdated listener notify")
|
||||||
|
} else {
|
||||||
|
for (listener in contactsUpdatedListeners) {
|
||||||
|
listener.onContactUpdated(contact)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,9 +348,6 @@ class ContactsManager(private val context: Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deferred.await()
|
deferred.await()
|
||||||
for (listener in contactsUpdatedListeners) {
|
|
||||||
listener.onContactUpdated(contact)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue