mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
Merge pull request #506 from shenzhigang/master
Fix Mms duplication on scroll to top
This commit is contained in:
@ -122,7 +122,7 @@ fun Context.getMessages(
|
|||||||
messages.add(message)
|
messages.add(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
messages.addAll(getMMS(threadId, getImageResolutions, sortOrder))
|
messages.addAll(getMMS(threadId, getImageResolutions, sortOrder, dateFrom))
|
||||||
|
|
||||||
if (includeScheduledMessages) {
|
if (includeScheduledMessages) {
|
||||||
try {
|
try {
|
||||||
@ -143,7 +143,7 @@ fun Context.getMessages(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// as soon as a message contains multiple recipients it counts as an MMS instead of SMS
|
// as soon as a message contains multiple recipients it counts as an MMS instead of SMS
|
||||||
fun Context.getMMS(threadId: Long? = null, getImageResolutions: Boolean = false, sortOrder: String? = null): ArrayList<Message> {
|
fun Context.getMMS(threadId: Long? = null, getImageResolutions: Boolean = false, sortOrder: String? = null, dateFrom: Int = -1): ArrayList<Message> {
|
||||||
val uri = Mms.CONTENT_URI
|
val uri = Mms.CONTENT_URI
|
||||||
val projection = arrayOf(
|
val projection = arrayOf(
|
||||||
Mms._ID,
|
Mms._ID,
|
||||||
@ -155,16 +155,17 @@ fun Context.getMMS(threadId: Long? = null, getImageResolutions: Boolean = false,
|
|||||||
Mms.STATUS
|
Mms.STATUS
|
||||||
)
|
)
|
||||||
|
|
||||||
val selection = if (threadId == null) {
|
var selection: String? = null
|
||||||
null
|
var selectionArgs: Array<String>? = null
|
||||||
} else {
|
|
||||||
"${Mms.THREAD_ID} = ?"
|
|
||||||
}
|
|
||||||
|
|
||||||
val selectionArgs = if (threadId == null) {
|
if (threadId == null && dateFrom != -1) {
|
||||||
null
|
selection = "${Sms.DATE} < ${dateFrom.toLong()}" //Should not multiply 1000 here, because date in mms's database is different from sms's.
|
||||||
} else {
|
} else if (threadId != null && dateFrom == -1) {
|
||||||
arrayOf(threadId.toString())
|
selection = "${Sms.THREAD_ID} = ?"
|
||||||
|
selectionArgs = arrayOf(threadId.toString())
|
||||||
|
} else if (threadId != null && dateFrom != -1) {
|
||||||
|
selection = "${Sms.THREAD_ID} = ? AND ${Sms.DATE} < ${dateFrom.toLong()}"
|
||||||
|
selectionArgs = arrayOf(threadId.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
val messages = ArrayList<Message>()
|
val messages = ArrayList<Message>()
|
||||||
|
Reference in New Issue
Block a user