mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
adding some crashfixes
This commit is contained in:
@@ -138,7 +138,10 @@ class MainActivity : SimpleActivity() {
|
|||||||
handlePermission(PERMISSION_READ_CONTACTS) {
|
handlePermission(PERMISSION_READ_CONTACTS) {
|
||||||
initMessenger()
|
initMessenger()
|
||||||
bus = EventBus.getDefault()
|
bus = EventBus.getDefault()
|
||||||
|
try {
|
||||||
bus!!.register(this)
|
bus!!.register(this)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
finish()
|
finish()
|
||||||
@@ -165,7 +168,12 @@ class MainActivity : SimpleActivity() {
|
|||||||
|
|
||||||
private fun getCachedConversations() {
|
private fun getCachedConversations() {
|
||||||
ensureBackgroundThread {
|
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)
|
updateUnreadCountBadge(conversations)
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
setupConversations(conversations)
|
setupConversations(conversations)
|
||||||
|
@@ -161,6 +161,8 @@ class NewConversationActivity : SimpleActivity() {
|
|||||||
layoutInflater.inflate(R.layout.item_suggested_contact, null).apply {
|
layoutInflater.inflate(R.layout.item_suggested_contact, null).apply {
|
||||||
suggested_contact_name.text = contact.name
|
suggested_contact_name.text = contact.name
|
||||||
suggested_contact_name.setTextColor(baseConfig.textColor)
|
suggested_contact_name.setTextColor(baseConfig.textColor)
|
||||||
|
|
||||||
|
if (!isDestroyed) {
|
||||||
SimpleContactsHelper(this@NewConversationActivity).loadContactImage(contact.photoUri, suggested_contact_image, contact.name)
|
SimpleContactsHelper(this@NewConversationActivity).loadContactImage(contact.photoUri, suggested_contact_image, contact.name)
|
||||||
suggestions_holder.addView(this)
|
suggestions_holder.addView(this)
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
@@ -169,6 +171,7 @@ class NewConversationActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -314,7 +314,7 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
val availableSIMs = SubscriptionManager.from(this).activeSubscriptionInfoList ?: return
|
val availableSIMs = SubscriptionManager.from(this).activeSubscriptionInfoList ?: return
|
||||||
if (availableSIMs.size > 1) {
|
if (availableSIMs.size > 1) {
|
||||||
availableSIMs.forEachIndexed { index, subscriptionInfo ->
|
availableSIMs.forEachIndexed { index, subscriptionInfo ->
|
||||||
var label = subscriptionInfo.displayName.toString()
|
var label = subscriptionInfo.displayName?.toString() ?: ""
|
||||||
if (subscriptionInfo.number?.isNotEmpty() == true) {
|
if (subscriptionInfo.number?.isNotEmpty() == true) {
|
||||||
label += " (${subscriptionInfo.number})"
|
label += " (${subscriptionInfo.number})"
|
||||||
}
|
}
|
||||||
|
@@ -135,7 +135,11 @@ class ConversationsAdapter(activity: SimpleActivity, var conversations: ArrayLis
|
|||||||
activity.deleteConversation(it.thread_id)
|
activity.deleteConversation(it.thread_id)
|
||||||
activity.notificationManager.cancel(it.thread_id)
|
activity.notificationManager.cancel(it.thread_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
conversations.removeAll(conversationsToRemove)
|
conversations.removeAll(conversationsToRemove)
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
}
|
||||||
|
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
if (conversationsToRemove.isEmpty()) {
|
if (conversationsToRemove.isEmpty()) {
|
||||||
|
@@ -475,7 +475,11 @@ fun Context.deleteConversation(threadId: Int) {
|
|||||||
var uri = Sms.CONTENT_URI
|
var uri = Sms.CONTENT_URI
|
||||||
val selection = "${Sms.THREAD_ID} = ?"
|
val selection = "${Sms.THREAD_ID} = ?"
|
||||||
val selectionArgs = arrayOf(threadId.toString())
|
val selectionArgs = arrayOf(threadId.toString())
|
||||||
|
try {
|
||||||
contentResolver.delete(uri, selection, selectionArgs)
|
contentResolver.delete(uri, selection, selectionArgs)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
showErrorToast(e)
|
||||||
|
}
|
||||||
|
|
||||||
uri = Mms.CONTENT_URI
|
uri = Mms.CONTENT_URI
|
||||||
contentResolver.delete(uri, selection, selectionArgs)
|
contentResolver.delete(uri, selection, selectionArgs)
|
||||||
|
Reference in New Issue
Block a user