Minor code optimizations

This commit is contained in:
Juha Heinanen
2022-02-18 10:02:14 +02:00
parent 4f7278e3d7
commit 9ff543fd6d
@@ -90,21 +90,19 @@ class ContactActivity : AppCompatActivity() {
binding.AndroidTitle.visibility = View.GONE binding.AndroidTitle.visibility = View.GONE
androidCheck.visibility = View.GONE androidCheck.visibility = View.GONE
index = intent.getIntExtra("index", 0) index = intent.getIntExtra("index", 0)
val contact = Contact.contacts()[index] val contact = Contact.contacts()[index] as Contact.BaresipContact
if (contact is Contact.BaresipContact) { val name = contact.name
val name = contact.name color = contact.color
color = contact.color id = contact.id
id = contact.id val avatarImage = contact.avatarImage
val avatarImage = contact.avatarImage if (avatarImage != null)
if (avatarImage != null) showImageAvatar(avatarImage)
showImageAvatar(avatarImage) else
else showTextAvatar(name, color)
showTextAvatar(name, color) title = name
title = name nameView.setText(name)
nameView.setText(name) uriView.setText(contact.uri)
uriView.setText(contact.uri) uOrI = index.toString()
uOrI = index.toString()
}
} }
val avatarRequest = val avatarRequest =
@@ -272,9 +270,8 @@ class ContactActivity : AppCompatActivity() {
} else { } else {
if (newContact) if (newContact)
Contact.contacts().add(contact) Contact.contacts().add(contact)
Contact.sortContacts()
Contact.generateContactNames()
Contact.saveBaresipContacts() Contact.saveBaresipContacts()
Contact.contactsUpdate()
} }
BaresipService.activities.remove("contact,$newContact,$uOrI") BaresipService.activities.remove("contact,$newContact,$uOrI")