Prevent crash if exception is thrown during contacts fetching + fixed cast issue
This commit is contained in:
parent
6ef3dc288e
commit
197b45536c
2 changed files with 16 additions and 10 deletions
|
@ -24,7 +24,7 @@ import android.view.View
|
|||
import androidx.lifecycle.ViewModelProvider
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.assistant.AssistantActivity
|
||||
import org.linphone.activities.SnackBarActivity
|
||||
import org.linphone.activities.assistant.viewmodels.*
|
||||
import org.linphone.activities.navigateToEchoCancellerCalibration
|
||||
import org.linphone.activities.navigateToPhoneAccountValidation
|
||||
|
@ -99,7 +99,7 @@ class PhoneAccountLinkingFragment : AbstractPhoneFragment<AssistantPhoneAccountL
|
|||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
(requireActivity() as SnackBarActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,14 +109,20 @@ class AsyncContactsLoader(private val context: Context) :
|
|||
Log.i("[Contacts Loader] Only fetching contacts in default directory")
|
||||
selection = ContactsContract.Data.IN_DEFAULT_DIRECTORY + " == 1"
|
||||
}
|
||||
val cursor: Cursor? = context.contentResolver
|
||||
.query(
|
||||
ContactsContract.Data.CONTENT_URI,
|
||||
projection,
|
||||
selection,
|
||||
null,
|
||||
null
|
||||
)
|
||||
|
||||
val cursor: Cursor? = try {
|
||||
context.contentResolver
|
||||
.query(
|
||||
ContactsContract.Data.CONTENT_URI,
|
||||
projection,
|
||||
selection,
|
||||
null,
|
||||
null
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.e("[Contacts Loader] Failed to get contacts cursor: $e")
|
||||
null
|
||||
}
|
||||
|
||||
if (cursor != null) {
|
||||
Log.i("[Contacts Loader] Found ${cursor.count} entries in cursor")
|
||||
|
|
Loading…
Reference in a new issue