mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-02-17 04:00:35 +01:00
adding some crashfixes
This commit is contained in:
parent
953d521e47
commit
d1fe3531e1
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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})"
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user