mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed ConcurrentModificationException that could happen during contact edition
This commit is contained in:
parent
6cb78c8c59
commit
c556d14fb0
1 changed files with 14 additions and 6 deletions
|
|
@ -262,10 +262,14 @@ class ContactNewOrEditViewModel
|
|||
fun addSipAddress(address: String = "", requestFieldToBeAddedInUi: Boolean = false) {
|
||||
val newModel = NewOrEditNumberOrAddressModel(address, true, "", {
|
||||
if (address.isEmpty()) {
|
||||
addSipAddress(requestFieldToBeAddedInUi = true)
|
||||
coreContext.postOnCoreThread {
|
||||
addSipAddress(requestFieldToBeAddedInUi = true)
|
||||
}
|
||||
}
|
||||
}, { model ->
|
||||
removeModel(model)
|
||||
coreContext.postOnCoreThread {
|
||||
removeModel(model)
|
||||
}
|
||||
})
|
||||
sipAddresses.add(newModel)
|
||||
|
||||
|
|
@ -282,10 +286,14 @@ class ContactNewOrEditViewModel
|
|||
) {
|
||||
val newModel = NewOrEditNumberOrAddressModel(number, false, label, {
|
||||
if (number.isEmpty()) {
|
||||
addPhoneNumber(requestFieldToBeAddedInUi = true)
|
||||
coreContext.postOnCoreThread {
|
||||
addPhoneNumber(requestFieldToBeAddedInUi = true)
|
||||
}
|
||||
}
|
||||
}, { model ->
|
||||
removeModel(model)
|
||||
coreContext.postOnCoreThread {
|
||||
removeModel(model)
|
||||
}
|
||||
})
|
||||
phoneNumbers.add(newModel)
|
||||
|
||||
|
|
@ -294,14 +302,14 @@ class ContactNewOrEditViewModel
|
|||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
@WorkerThread
|
||||
private fun removeModel(model: NewOrEditNumberOrAddressModel) {
|
||||
if (model.isSip) {
|
||||
sipAddresses.remove(model)
|
||||
} else {
|
||||
phoneNumbers.remove(model)
|
||||
}
|
||||
removeNewNumberOrAddressFieldEvent.value = Event(model)
|
||||
removeNewNumberOrAddressFieldEvent.postValue(Event(model))
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue