adding some crashfixes

This commit is contained in:
tibbi 2021-03-15 23:30:56 +01:00
parent 6c9d25d16f
commit 0e07117b3a
3 changed files with 15 additions and 6 deletions

View File

@ -56,7 +56,7 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:5.34.21'
implementation 'com.simplemobiletools:commons:5.34.22'
implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'com.klinkerapps:android-smsmms:5.2.6'
implementation 'com.github.tibbi:IndicatorFastScroll:c3de1d040a'

View File

@ -156,7 +156,12 @@ class ThreadActivity : SimpleActivity() {
private fun setupCachedMessages(callback: () -> Unit) {
ensureBackgroundThread {
messages = messagesDB.getThreadMessages(threadId).toMutableList() as ArrayList<Message>
messages = try {
messagesDB.getThreadMessages(threadId).toMutableList() as ArrayList<Message>
} catch (e: Exception) {
ArrayList()
}
setupParticipants()
setupAdapter()
@ -176,9 +181,9 @@ class ThreadActivity : SimpleActivity() {
private fun setupThread() {
val privateCursor = getMyContactsCursor()?.loadInBackground()
ensureBackgroundThread {
val cachedMessagesCode = messages.hashCode()
val cachedMessagesCode = messages.clone().hashCode()
messages = getMessages(threadId)
if (messages.hashCode() == cachedMessagesCode && participants.isNotEmpty()) {
if (participants.isNotEmpty() && messages.hashCode() == cachedMessagesCode) {
return@ensureBackgroundThread
}

View File

@ -507,8 +507,12 @@ fun Context.insertNewSMS(address: String, subject: String, body: String, date: L
put(Sms.SUBSCRIPTION_ID, subscriptionId)
}
return try {
val newUri = contentResolver.insert(uri, contentValues)
return newUri?.lastPathSegment?.toLong() ?: 0L
newUri?.lastPathSegment?.toLong() ?: 0L
} catch (e: Exception) {
0L
}
}
fun Context.deleteConversation(threadId: Long) {