select the appropriate messages at the individual ThreadActivity
This commit is contained in:
parent
a446a56afb
commit
70c1e7d6b7
|
@ -2,6 +2,7 @@ package com.simplemobiletools.smsmessenger.activities
|
|||
|
||||
import android.os.Bundle
|
||||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.extensions.getMessages
|
||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_ID
|
||||
|
||||
class ThreadActivity : SimpleActivity() {
|
||||
|
@ -10,5 +11,6 @@ class ThreadActivity : SimpleActivity() {
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_thread)
|
||||
val threadID = intent.getIntExtra(THREAD_ID, 0)
|
||||
val messages = getMessages(threadID)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import com.simplemobiletools.smsmessenger.models.Message
|
|||
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||
|
||||
fun Context.getMessages(): ArrayList<Message> {
|
||||
fun Context.getMessages(threadID: Int? = null): ArrayList<Message> {
|
||||
val messages = ArrayList<Message>()
|
||||
val hasContactsPermission = hasPermission(PERMISSION_READ_CONTACTS)
|
||||
val uri = Telephony.Sms.CONTENT_URI
|
||||
|
@ -29,8 +29,17 @@ fun Context.getMessages(): ArrayList<Message> {
|
|||
Telephony.Sms.THREAD_ID
|
||||
)
|
||||
|
||||
val selection = "1 == 1) GROUP BY (${Telephony.Sms.THREAD_ID}"
|
||||
val selectionArgs = null
|
||||
val selection = if (threadID == null) {
|
||||
"1 == 1) GROUP BY (${Telephony.Sms.THREAD_ID}"
|
||||
} else {
|
||||
"${Telephony.Sms.THREAD_ID} = ?"
|
||||
}
|
||||
|
||||
val selectionArgs = if (threadID == null) {
|
||||
null
|
||||
} else {
|
||||
arrayOf(threadID.toString())
|
||||
}
|
||||
|
||||
var cursor: Cursor? = null
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue