mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
properly sort all fetched messages
This commit is contained in:
@ -200,7 +200,7 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
|
|
||||||
private fun getThreadItems(threadID: Int): ArrayList<ThreadItem> {
|
private fun getThreadItems(threadID: Int): ArrayList<ThreadItem> {
|
||||||
val messages = getMessages(threadID)
|
val messages = getMessages(threadID)
|
||||||
messages.sortBy { it.id }
|
messages.sortBy { it.date }
|
||||||
|
|
||||||
val items = ArrayList<ThreadItem>()
|
val items = ArrayList<ThreadItem>()
|
||||||
var prevDateTime = 0
|
var prevDateTime = 0
|
||||||
|
@ -56,7 +56,7 @@ fun Context.getMessages(threadID: Int? = null): ArrayList<Message> {
|
|||||||
arrayOf(threadID.toString())
|
arrayOf(threadID.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
val messages = ArrayList<Message>()
|
var messages = ArrayList<Message>()
|
||||||
queryCursor(uri, projection, selection, selectionArgs, showErrors = true) { cursor ->
|
queryCursor(uri, projection, selection, selectionArgs, showErrors = true) { cursor ->
|
||||||
val id = cursor.getIntValue(Sms._ID)
|
val id = cursor.getIntValue(Sms._ID)
|
||||||
val subject = cursor.getStringValue(Sms.SUBJECT) ?: ""
|
val subject = cursor.getStringValue(Sms.SUBJECT) ?: ""
|
||||||
@ -85,6 +85,11 @@ fun Context.getMessages(threadID: Int? = null): ArrayList<Message> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
messages.addAll(getMMS())
|
messages.addAll(getMMS())
|
||||||
|
messages = messages.sortedByDescending { it.date }.toMutableList() as ArrayList<Message>
|
||||||
|
if (threadID == null) {
|
||||||
|
messages = messages.distinctBy { it.thread }.toMutableList() as ArrayList<Message>
|
||||||
|
}
|
||||||
|
|
||||||
return messages
|
return messages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user