fix #25, ensure that the top conversations are at the top
This commit is contained in:
parent
d223266f1b
commit
910aa365ac
1 changed files with 4 additions and 1 deletions
|
|
@ -185,8 +185,9 @@ fun Context.getConversations(): ArrayList<Conversation> {
|
||||||
|
|
||||||
val selection = "${Threads.MESSAGE_COUNT} > ?"
|
val selection = "${Threads.MESSAGE_COUNT} > ?"
|
||||||
val selectionArgs = arrayOf("0")
|
val selectionArgs = arrayOf("0")
|
||||||
|
val sortOrder = "${Threads.DATE} DESC"
|
||||||
val conversations = ArrayList<Conversation>()
|
val conversations = ArrayList<Conversation>()
|
||||||
queryCursor(uri, projection, selection, selectionArgs, showErrors = true) { cursor ->
|
queryCursor(uri, projection, selection, selectionArgs, sortOrder, true) { cursor ->
|
||||||
val id = cursor.getIntValue(Threads._ID)
|
val id = cursor.getIntValue(Threads._ID)
|
||||||
var snippet = cursor.getStringValue(Threads.SNIPPET) ?: ""
|
var snippet = cursor.getStringValue(Threads.SNIPPET) ?: ""
|
||||||
if (snippet.isEmpty()) {
|
if (snippet.isEmpty()) {
|
||||||
|
|
@ -211,9 +212,11 @@ fun Context.getConversations(): ArrayList<Conversation> {
|
||||||
val photoUri = if (phoneNumbers.size == 1) SimpleContactsHelper(this).getPhotoUriFromPhoneNumber(phoneNumbers.first()) else ""
|
val photoUri = if (phoneNumbers.size == 1) SimpleContactsHelper(this).getPhotoUriFromPhoneNumber(phoneNumbers.first()) else ""
|
||||||
val isGroupConversation = phoneNumbers.size > 1
|
val isGroupConversation = phoneNumbers.size > 1
|
||||||
val conversation = Conversation(id, snippet, date.toInt(), read, title, photoUri, isGroupConversation, phoneNumbers.first())
|
val conversation = Conversation(id, snippet, date.toInt(), read, title, photoUri, isGroupConversation, phoneNumbers.first())
|
||||||
|
|
||||||
conversations.add(conversation)
|
conversations.add(conversation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
conversations.sortByDescending { it.date }
|
||||||
return conversations
|
return conversations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue