mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-02-22 22:47:49 +01:00
changing the conversation fetcher code style a bit
This commit is contained in:
parent
94086547a5
commit
7d1e28203e
@ -188,6 +188,7 @@ fun Context.getConversations(): ArrayList<Conversation> {
|
||||
val sortOrder = "${Threads.DATE} DESC"
|
||||
|
||||
val conversations = ArrayList<Conversation>()
|
||||
val simpleContactHelper = SimpleContactsHelper(this)
|
||||
queryCursor(uri, projection, selection, selectionArgs, sortOrder, true) { cursor ->
|
||||
val id = cursor.getIntValue(Threads._ID)
|
||||
var snippet = cursor.getStringValue(Threads.SNIPPET) ?: ""
|
||||
@ -200,7 +201,6 @@ fun Context.getConversations(): ArrayList<Conversation> {
|
||||
date /= 1000
|
||||
}
|
||||
|
||||
val read = cursor.getIntValue(Threads.READ) == 1
|
||||
val rawIds = cursor.getStringValue(Threads.RECIPIENT_IDS)
|
||||
val recipientIds = rawIds.split(" ").filter { it.areDigitsOnly() }.map { it.toInt() }.toMutableList()
|
||||
val phoneNumbers = getThreadPhoneNumbers(recipientIds)
|
||||
@ -210,8 +210,9 @@ fun Context.getConversations(): ArrayList<Conversation> {
|
||||
|
||||
val names = getThreadContactNames(phoneNumbers)
|
||||
val title = TextUtils.join(", ", names.toTypedArray())
|
||||
val photoUri = if (phoneNumbers.size == 1) SimpleContactsHelper(this).getPhotoUriFromPhoneNumber(phoneNumbers.first()) else ""
|
||||
val photoUri = if (phoneNumbers.size == 1) simpleContactHelper.getPhotoUriFromPhoneNumber(phoneNumbers.first()) else ""
|
||||
val isGroupConversation = phoneNumbers.size > 1
|
||||
val read = cursor.getIntValue(Threads.READ) == 1
|
||||
val conversation = Conversation(id, snippet, date.toInt(), read, title, photoUri, isGroupConversation, phoneNumbers.first())
|
||||
|
||||
conversations.add(conversation)
|
||||
|
Loading…
x
Reference in New Issue
Block a user