Avoid Lint warning
This commit is contained in:
@@ -1645,8 +1645,7 @@ class BaresipService: Service() {
|
|||||||
val messageUpdate = MutableLiveData<Long>()
|
val messageUpdate = MutableLiveData<Long>()
|
||||||
val contactUpdate = MutableLiveData<Long>()
|
val contactUpdate = MutableLiveData<Long>()
|
||||||
val registrationUpdate = MutableLiveData<Long>()
|
val registrationUpdate = MutableLiveData<Long>()
|
||||||
@SuppressLint("MutableCollectionMutableState")
|
val baresipContacts = mutableStateOf(emptyList<Contact.BaresipContact>())
|
||||||
val baresipContacts = mutableStateOf(mutableListOf<Contact.BaresipContact>())
|
|
||||||
val androidContacts = mutableStateOf(emptyList<Contact.AndroidContact>())
|
val androidContacts = mutableStateOf(emptyList<Contact.AndroidContact>())
|
||||||
val contactNames = mutableStateOf(emptyList<String>())
|
val contactNames = mutableStateOf(emptyList<String>())
|
||||||
var contactsMode = "baresip"
|
var contactsMode = "baresip"
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ sealed class Contact {
|
|||||||
Log.e(TAG, "Could not read avatar image from file $id.png: ${e.message}")
|
Log.e(TAG, "Could not read avatar image from file $id.png: ${e.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BaresipService.baresipContacts.value.add(contact)
|
BaresipService.baresipContacts.value += contact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@@ -267,22 +267,26 @@ sealed class Contact {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addBaresipContact(contact: BaresipContact) {
|
fun addBaresipContact(contact: BaresipContact) {
|
||||||
BaresipService.baresipContacts.value.add(contact)
|
BaresipService.baresipContacts.value += contact
|
||||||
saveBaresipContacts()
|
saveBaresipContacts()
|
||||||
contactsUpdate()
|
contactsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateBaresipContact(contact: BaresipContact) {
|
fun updateBaresipContact(contact: BaresipContact) {
|
||||||
val newContact = contact.copy() as BaresipContact
|
val updatedContacts = BaresipService.baresipContacts.value.toMutableList()
|
||||||
BaresipService.baresipContacts.value.removeIf { it.id == contact.id }
|
val updatedContact = contact.copy() as BaresipContact
|
||||||
newContact.id = System.currentTimeMillis()
|
updatedContact.id = System.currentTimeMillis()
|
||||||
BaresipService.baresipContacts.value.add(newContact)
|
updatedContacts.removeIf { it.id == contact.id }
|
||||||
|
updatedContacts.add(updatedContact)
|
||||||
|
BaresipService.baresipContacts.value = updatedContacts
|
||||||
saveBaresipContacts()
|
saveBaresipContacts()
|
||||||
contactsUpdate()
|
contactsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun removeBaresipContact(contact: BaresipContact) {
|
fun removeBaresipContact(contact: BaresipContact) {
|
||||||
BaresipService.baresipContacts.value.removeIf { it.id == contact.id }
|
val removed = BaresipService.baresipContacts.value.toMutableList()
|
||||||
|
removed.removeIf { it.id == contact.id }
|
||||||
|
BaresipService.baresipContacts.value = removed.toList()
|
||||||
saveBaresipContacts()
|
saveBaresipContacts()
|
||||||
contactsUpdate()
|
contactsUpdate()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -340,7 +340,6 @@ class ContactsActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Contact.removeBaresipContact(contact)
|
Contact.removeBaresipContact(contact)
|
||||||
//Contact.contactsUpdate()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogInterface.BUTTON_NEUTRAL -> {
|
DialogInterface.BUTTON_NEUTRAL -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user