set the most frequent contact source as the default one

This commit is contained in:
tibbi 2017-12-26 23:49:31 +01:00
parent 44bd03b98a
commit ca9b1cc6c4
1 changed files with 6 additions and 0 deletions

View File

@ -89,6 +89,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
contacts_placeholder_2.setOnClickListener {
showFilterDialog()
}
if (!isFirstResume) {
initContacts()
}
@ -144,6 +145,11 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private fun initContacts() {
ContactsHelper(this).getContacts {
if (config.lastUsedContactSource.isEmpty()) {
val grouped = it.groupBy { it.source }.maxWith(compareBy { it.value.size })
config.lastUsedContactSource = grouped?.key ?: ""
}
Contact.sorting = config.sorting
it.sort()