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 androidx.lifecycle.ViewModelProvider
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
import org.linphone.R
|
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.assistant.viewmodels.*
|
||||||
import org.linphone.activities.navigateToEchoCancellerCalibration
|
import org.linphone.activities.navigateToEchoCancellerCalibration
|
||||||
import org.linphone.activities.navigateToPhoneAccountValidation
|
import org.linphone.activities.navigateToPhoneAccountValidation
|
||||||
|
@ -99,7 +99,7 @@ class PhoneAccountLinkingFragment : AbstractPhoneFragment<AssistantPhoneAccountL
|
||||||
viewLifecycleOwner
|
viewLifecycleOwner
|
||||||
) {
|
) {
|
||||||
it.consume { message ->
|
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")
|
Log.i("[Contacts Loader] Only fetching contacts in default directory")
|
||||||
selection = ContactsContract.Data.IN_DEFAULT_DIRECTORY + " == 1"
|
selection = ContactsContract.Data.IN_DEFAULT_DIRECTORY + " == 1"
|
||||||
}
|
}
|
||||||
val cursor: Cursor? = context.contentResolver
|
|
||||||
.query(
|
val cursor: Cursor? = try {
|
||||||
ContactsContract.Data.CONTENT_URI,
|
context.contentResolver
|
||||||
projection,
|
.query(
|
||||||
selection,
|
ContactsContract.Data.CONTENT_URI,
|
||||||
null,
|
projection,
|
||||||
null
|
selection,
|
||||||
)
|
null,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("[Contacts Loader] Failed to get contacts cursor: $e")
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
Log.i("[Contacts Loader] Found ${cursor.count} entries in cursor")
|
Log.i("[Contacts Loader] Found ${cursor.count} entries in cursor")
|
||||||
|
|
Loading…
Reference in a new issue