setup some thread info sooner, before getting real messages
This commit is contained in:
parent
f97e3b048c
commit
189e60ac32
|
@ -81,7 +81,10 @@ class ThreadActivity : SimpleActivity() {
|
|||
bus!!.register(this)
|
||||
handlePermission(PERMISSION_READ_PHONE_STATE) {
|
||||
if (it) {
|
||||
setupThread()
|
||||
setupButtons()
|
||||
setupCachedMessages {
|
||||
setupThread()
|
||||
}
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
|
@ -102,11 +105,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
val privateCursor = getMyContactsCursor()?.loadInBackground()
|
||||
ensureBackgroundThread {
|
||||
messages = getMessages(threadId)
|
||||
participants = if (messages.isEmpty()) {
|
||||
getThreadParticipants(threadId, null)
|
||||
} else {
|
||||
messages.first().participants
|
||||
}
|
||||
setupParticipants()
|
||||
|
||||
// check if no participant came from a privately stored contact in Simple Contacts
|
||||
privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
||||
|
@ -143,20 +142,9 @@ class ThreadActivity : SimpleActivity() {
|
|||
setupAttachmentSizes()
|
||||
setupAdapter()
|
||||
runOnUiThread {
|
||||
val threadTitle = participants.getThreadTitle()
|
||||
if (threadTitle.isNotEmpty()) {
|
||||
supportActionBar?.title = participants.getThreadTitle()
|
||||
}
|
||||
|
||||
if (messages.isEmpty()) {
|
||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
thread_type_message.requestFocus()
|
||||
}
|
||||
|
||||
setupSIMSelector()
|
||||
setupThreadTitle()
|
||||
}
|
||||
}
|
||||
setupButtons()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@ -197,6 +185,25 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupCachedMessages(callback: () -> Unit) {
|
||||
ensureBackgroundThread {
|
||||
messages = messagesDB.getThreadMessages(threadId).toMutableList() as ArrayList<Message>
|
||||
setupParticipants()
|
||||
setupAdapter()
|
||||
|
||||
runOnUiThread {
|
||||
if (messages.isEmpty()) {
|
||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
thread_type_message.requestFocus()
|
||||
}
|
||||
|
||||
setupThreadTitle()
|
||||
setupSIMSelector()
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupAdapter() {
|
||||
threadItems = getThreadItems()
|
||||
invalidateOptionsMenu()
|
||||
|
@ -318,6 +325,23 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupParticipants() {
|
||||
if (participants.isEmpty()) {
|
||||
participants = if (messages.isEmpty()) {
|
||||
getThreadParticipants(threadId, null)
|
||||
} else {
|
||||
messages.first().participants
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupThreadTitle() {
|
||||
val threadTitle = participants.getThreadTitle()
|
||||
if (threadTitle.isNotEmpty()) {
|
||||
supportActionBar?.title = participants.getThreadTitle()
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private fun setupSIMSelector() {
|
||||
val availableSIMs = SubscriptionManager.from(this).activeSubscriptionInfoList ?: return
|
||||
|
|
Loading…
Reference in New Issue