adding a helper function for opening a specific thread
This commit is contained in:
parent
5b6b5db17b
commit
8379a753b2
|
@ -18,7 +18,7 @@ import com.simplemobiletools.smsmessenger.R
|
|||
import com.simplemobiletools.smsmessenger.adapters.MessagesAdapter
|
||||
import com.simplemobiletools.smsmessenger.extensions.config
|
||||
import com.simplemobiletools.smsmessenger.extensions.getMessages
|
||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_ID
|
||||
import com.simplemobiletools.smsmessenger.extensions.launchThreadActivity
|
||||
import com.simplemobiletools.smsmessenger.models.Events
|
||||
import com.simplemobiletools.smsmessenger.models.Message
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
|
@ -136,10 +136,7 @@ class MainActivity : SimpleActivity() {
|
|||
val messages = getMessages()
|
||||
runOnUiThread {
|
||||
MessagesAdapter(this, messages, messages_list, messages_fastscroller) {
|
||||
Intent(this, ThreadActivity::class.java).apply {
|
||||
putExtra(THREAD_ID, (it as Message).thread)
|
||||
startActivity(this)
|
||||
}
|
||||
launchThreadActivity((it as Message).thread)
|
||||
}.apply {
|
||||
messages_list.adapter = this
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simplemobiletools.smsmessenger.extensions
|
|||
import android.annotation.SuppressLint
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.database.Cursor
|
||||
import android.provider.ContactsContract
|
||||
import android.provider.ContactsContract.CommonDataKinds
|
||||
|
@ -11,12 +12,21 @@ import android.text.TextUtils
|
|||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
|
||||
import com.simplemobiletools.commons.helpers.isMarshmallowPlus
|
||||
import com.simplemobiletools.smsmessenger.activities.ThreadActivity
|
||||
import com.simplemobiletools.smsmessenger.helpers.Config
|
||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_ID
|
||||
import com.simplemobiletools.smsmessenger.models.Message
|
||||
import com.simplemobiletools.smsmessenger.models.MessagingThread
|
||||
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||
|
||||
fun Context.launchThreadActivity(id: Int) {
|
||||
Intent(this, ThreadActivity::class.java).apply {
|
||||
putExtra(THREAD_ID, id)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.getMessages(threadID: Int? = null): ArrayList<Message> {
|
||||
val messages = ArrayList<Message>()
|
||||
val hasContactsPermission = hasPermission(PERMISSION_READ_CONTACTS)
|
||||
|
|
Loading…
Reference in New Issue