properly sort multipart messages by date, then by id
This commit is contained in:
parent
647410f4aa
commit
64ee324d1a
|
@ -58,7 +58,7 @@ fun Context.getMessages(threadId: Int): ArrayList<Message> {
|
||||||
|
|
||||||
val selection = "${Sms.THREAD_ID} = ?"
|
val selection = "${Sms.THREAD_ID} = ?"
|
||||||
val selectionArgs = arrayOf(threadId.toString())
|
val selectionArgs = arrayOf(threadId.toString())
|
||||||
val sortOrder = "${Sms._ID} DESC LIMIT 100"
|
val sortOrder = "${Sms._ID} LIMIT 100"
|
||||||
|
|
||||||
var messages = ArrayList<Message>()
|
var messages = ArrayList<Message>()
|
||||||
queryCursor(uri, projection, selection, selectionArgs, sortOrder, showErrors = true) { cursor ->
|
queryCursor(uri, projection, selection, selectionArgs, sortOrder, showErrors = true) { cursor ->
|
||||||
|
@ -84,7 +84,7 @@ fun Context.getMessages(threadId: Int): ArrayList<Message> {
|
||||||
|
|
||||||
messages.addAll(getMMS(threadId, sortOrder))
|
messages.addAll(getMMS(threadId, sortOrder))
|
||||||
messages = messages.filter { it.participants.isNotEmpty() }
|
messages = messages.filter { it.participants.isNotEmpty() }
|
||||||
.sortedByDescending { it.date }.toMutableList() as ArrayList<Message>
|
.sortedWith(compareBy<Message> { it.date }.thenBy { it.id }).toMutableList() as ArrayList<Message>
|
||||||
|
|
||||||
return messages
|
return messages
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue