mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
fixing some crashes and ANRs
This commit is contained in:
@ -189,7 +189,9 @@ class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleCo
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!activity.isDestroyed) {
|
||||||
SimpleContactsHelper(context).loadContactImage(contact.photoUri, findViewById(R.id.item_contact_image), contact.name)
|
SimpleContactsHelper(context).loadContactImage(contact.photoUri, findViewById(R.id.item_contact_image), contact.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -124,10 +124,14 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
ensureBackgroundThread {
|
||||||
val lookupKey = SimpleContactsHelper(activity!!).getContactLookupKey((contact).rawId.toString())
|
val lookupKey = SimpleContactsHelper(activity!!).getContactLookupKey((contact).rawId.toString())
|
||||||
val publicUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey)
|
val publicUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey)
|
||||||
|
activity?.runOnUiThread {
|
||||||
activity!!.launchViewContactIntent(publicUri)
|
activity!!.launchViewContactIntent(publicUri)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}.apply {
|
}.apply {
|
||||||
fragment_list.adapter = this
|
fragment_list.adapter = this
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ package com.simplemobiletools.dialer.helpers
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.telecom.Call
|
import android.telecom.Call
|
||||||
import android.telecom.InCallService
|
import android.telecom.InCallService
|
||||||
import android.telecom.VideoProfile
|
import android.telecom.VideoProfile
|
||||||
@ -55,10 +57,11 @@ class CallManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getCallContact(context: Context, callback: (CallContact?) -> Unit) {
|
fun getCallContact(context: Context, callback: (CallContact?) -> Unit) {
|
||||||
|
ensureBackgroundThread {
|
||||||
val callContact = CallContact("", "", "")
|
val callContact = CallContact("", "", "")
|
||||||
if (call == null || call!!.details == null || call!!.details!!.handle == null) {
|
if (call == null || call!!.details == null || call!!.details!!.handle == null) {
|
||||||
callback(callContact)
|
callback(callContact)
|
||||||
return
|
return@ensureBackgroundThread
|
||||||
}
|
}
|
||||||
|
|
||||||
val uri = Uri.decode(call!!.details.handle.toString())
|
val uri = Uri.decode(call!!.details.handle.toString())
|
||||||
@ -71,6 +74,7 @@ class CallManager {
|
|||||||
if (callContact.name != callContact.number) {
|
if (callContact.name != callContact.number) {
|
||||||
callback(callContact)
|
callback(callContact)
|
||||||
} else {
|
} else {
|
||||||
|
Handler(Looper.getMainLooper()).post {
|
||||||
val privateCursor = context.getMyContactsCursor().loadInBackground()
|
val privateCursor = context.getMyContactsCursor().loadInBackground()
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val privateContacts = MyContactsContentProvider.getSimpleContacts(context, privateCursor)
|
val privateContacts = MyContactsContentProvider.getSimpleContacts(context, privateCursor)
|
||||||
@ -85,3 +89,5 @@ class CallManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user