Store lastMessage instead of it's fields in conversation

This commit is contained in:
moezbhatti
2019-11-09 03:43:15 -05:00
parent e720ee9560
commit 335c5757c4
11 changed files with 74 additions and 71 deletions
@@ -36,33 +36,21 @@ class CursorToConversationImpl @Inject constructor(
val URI: Uri = Uri.parse("content://mms-sms/conversations?simple=true")
val PROJECTION = arrayOf(
Threads._ID,
Threads.DATE,
Threads.RECIPIENT_IDS,
Threads.MESSAGE_COUNT,
Threads.READ,
Threads.SNIPPET
Threads.RECIPIENT_IDS
)
const val ID = 0
const val DATE = 1
const val RECIPIENT_IDS = 2
const val MESSAGE_COUNT = 3
const val READ = 4
const val SNIPPET = 5
const val RECIPIENT_IDS = 1
}
override fun map(from: Cursor): Conversation {
return Conversation().apply {
id = from.getLong(ID)
date = from.getLong(DATE)
recipients.addAll(from.getString(RECIPIENT_IDS)
.split(" ")
.filter { it.isNotBlank() }
.map { recipientId -> recipientId.toLong() }
.map { recipientId -> Recipient().apply { id = recipientId } })
count = from.getInt(MESSAGE_COUNT)
read = from.getInt(READ) == 1
snippet = from.getString(SNIPPET) ?: ""
}
}