Properly check if user is a contact.
This commit is contained in:
parent
244fd32762
commit
d3c2b5ee26
2 changed files with 3 additions and 3 deletions
|
@ -120,7 +120,7 @@ class ConnectionsActivity extends EnsichatActivity with OnItemClickListener {
|
||||||
|
|
||||||
val user = service.get.getUser(parsedAddress)
|
val user = service.get.getUser(parsedAddress)
|
||||||
|
|
||||||
if (database.getContacts.contains(user)) {
|
if (database.getContacts.map(_.address).contains(user.address)) {
|
||||||
val text = getString(R.string.contact_already_added, user.name)
|
val text = getString(R.string.contact_already_added, user.name)
|
||||||
Toast.makeText(this, text, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, text, Toast.LENGTH_SHORT).show()
|
||||||
return
|
return
|
||||||
|
|
|
@ -128,7 +128,7 @@ class Database(context: Context) extends DatabaseInterface {
|
||||||
|
|
||||||
def addContact(contact: User): Unit = {
|
def addContact(contact: User): Unit = {
|
||||||
val cv = new ContentValues()
|
val cv = new ContentValues()
|
||||||
cv.put("address", contact.address.toString)
|
cv.put("address", contact.address.toString())
|
||||||
cv.put("name", contact.name)
|
cv.put("name", contact.name)
|
||||||
cv.put("status", contact.status)
|
cv.put("status", contact.status)
|
||||||
helper.getWritableDatabase.insert("contacts", null, cv)
|
helper.getWritableDatabase.insert("contacts", null, cv)
|
||||||
|
@ -139,7 +139,7 @@ class Database(context: Context) extends DatabaseInterface {
|
||||||
val cv = new ContentValues()
|
val cv = new ContentValues()
|
||||||
cv.put("name", contact.name)
|
cv.put("name", contact.name)
|
||||||
cv.put("status", contact.status)
|
cv.put("status", contact.status)
|
||||||
helper.getWritableDatabase.update("contacts", cv, "address = ?", Array(contact.address.toString))
|
helper.getWritableDatabase.update("contacts", cv, "address = ?", Array(contact.address.toString()))
|
||||||
contactsUpdated()
|
contactsUpdated()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue