do not show filter contact source dialog if theres no available sources

This commit is contained in:
tibbi 2018-01-02 23:30:29 +01:00
parent 98424ebd20
commit 22b4dd0a19
2 changed files with 5 additions and 1 deletions

View File

@ -15,6 +15,10 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, val callback: ()
init {
ContactsHelper(activity).getContactSources {
if (it.isEmpty()) {
return@getContactSources
}
val selectedSources = activity.config.displayContactSources
activity.runOnUiThread {
view.filter_contact_sources_list.adapter = FilterContactSourcesAdapter(activity, it, selectedSources)

View File

@ -231,7 +231,7 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
cursor = activity.contentResolver.query(uri, projection, null, null, null)
if (cursor?.moveToFirst() == true) {
do {
val name = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_NAME)
val name = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_NAME) ?: continue
accounts.add(name)
} while (cursor.moveToNext())
}