From ca9b1cc6c42c40a9e86ba1492c70178b538ec4de Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 26 Dec 2017 23:49:31 +0100 Subject: [PATCH] set the most frequent contact source as the default one --- .../simplemobiletools/contacts/activities/MainActivity.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/MainActivity.kt index d539b0fa..b9ea346a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/MainActivity.kt @@ -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()