load contact from realm if possible

This commit is contained in:
Moez Bhatti
2017-08-28 16:18:04 -07:00
parent 837f474e97
commit 15c6cc159d
4 changed files with 37 additions and 8 deletions
@@ -5,14 +5,14 @@ import io.realm.annotations.PrimaryKey
open class Contact() : RealmObject() {
@PrimaryKey var id: Long = 0
@PrimaryKey var recipientId: Long = 0
var address: String = ""
/**
* For inflating the contact using the cursor
*/
constructor(id: Long, address: String) : this() {
this.id = id
this.recipientId = id
this.address = address
}
@@ -30,8 +30,8 @@ open class Conversation() : RealmObject() {
Flowable.fromIterable(cursor.getString(ConversationColumns.RECIPIENT_IDS).split(" "))
.map { id -> id.toLong() }
.map { id -> contacts.getContactBlocking(id) }
.filter { contact -> contact.id != 0L }
.map { id -> contacts.getContact(id) }
.filter { contact -> contact.recipientId != 0L }
.blockingSubscribe { contact -> this.contacts.add(contact) }
snippet = cursor.getString(ConversationColumns.SNIPPET) ?: ""