adding some crashfixes

This commit is contained in:
tibbi 2020-11-03 19:39:59 +01:00
parent 953d521e47
commit d1fe3531e1
5 changed files with 28 additions and 9 deletions

View File

@ -138,7 +138,10 @@ class MainActivity : SimpleActivity() {
handlePermission(PERMISSION_READ_CONTACTS) {
initMessenger()
bus = EventBus.getDefault()
bus!!.register(this)
try {
bus!!.register(this)
} catch (e: Exception) {
}
}
} else {
finish()
@ -165,7 +168,12 @@ class MainActivity : SimpleActivity() {
private fun getCachedConversations() {
ensureBackgroundThread {
val conversations = conversationsDB.getAll().sortedByDescending { it.date }.toMutableList() as ArrayList<Conversation>
val conversations = try {
conversationsDB.getAll().sortedByDescending { it.date }.toMutableList() as ArrayList<Conversation>
} catch (e: Exception) {
ArrayList()
}
updateUnreadCountBadge(conversations)
runOnUiThread {
setupConversations(conversations)

View File

@ -161,10 +161,13 @@ class NewConversationActivity : SimpleActivity() {
layoutInflater.inflate(R.layout.item_suggested_contact, null).apply {
suggested_contact_name.text = contact.name
suggested_contact_name.setTextColor(baseConfig.textColor)
SimpleContactsHelper(this@NewConversationActivity).loadContactImage(contact.photoUri, suggested_contact_image, contact.name)
suggestions_holder.addView(this)
setOnClickListener {
launchThreadActivity(contact.phoneNumbers.first(), contact.name)
if (!isDestroyed) {
SimpleContactsHelper(this@NewConversationActivity).loadContactImage(contact.photoUri, suggested_contact_image, contact.name)
suggestions_holder.addView(this)
setOnClickListener {
launchThreadActivity(contact.phoneNumbers.first(), contact.name)
}
}
}
}

View File

@ -314,7 +314,7 @@ class ThreadActivity : SimpleActivity() {
val availableSIMs = SubscriptionManager.from(this).activeSubscriptionInfoList ?: return
if (availableSIMs.size > 1) {
availableSIMs.forEachIndexed { index, subscriptionInfo ->
var label = subscriptionInfo.displayName.toString()
var label = subscriptionInfo.displayName?.toString() ?: ""
if (subscriptionInfo.number?.isNotEmpty() == true) {
label += " (${subscriptionInfo.number})"
}

View File

@ -135,7 +135,11 @@ class ConversationsAdapter(activity: SimpleActivity, var conversations: ArrayLis
activity.deleteConversation(it.thread_id)
activity.notificationManager.cancel(it.thread_id)
}
conversations.removeAll(conversationsToRemove)
try {
conversations.removeAll(conversationsToRemove)
} catch (ignored: Exception) {
}
activity.runOnUiThread {
if (conversationsToRemove.isEmpty()) {

View File

@ -475,7 +475,11 @@ fun Context.deleteConversation(threadId: Int) {
var uri = Sms.CONTENT_URI
val selection = "${Sms.THREAD_ID} = ?"
val selectionArgs = arrayOf(threadId.toString())
contentResolver.delete(uri, selection, selectionArgs)
try {
contentResolver.delete(uri, selection, selectionArgs)
} catch (e: Exception) {
showErrorToast(e)
}
uri = Mms.CONTENT_URI
contentResolver.delete(uri, selection, selectionArgs)