From 7b577aa082132df9480b461fb1b96d0a0f0be638 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 2 Aug 2018 15:16:24 +0200 Subject: [PATCH] do not spend time fetching data for hidden fragments --- .../contacts/fragments/MyViewPagerFragment.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/MyViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/MyViewPagerFragment.kt index 805eb5ee..defca5ad 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/MyViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/fragments/MyViewPagerFragment.kt @@ -86,6 +86,12 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) } fun refreshContacts(contacts: ArrayList) { + if ((config.showTabs and CONTACTS_TAB_MASK == 0 && this is ContactsFragment) || + (config.showTabs and FAVORITES_TAB_MASK == 0 && this is FavoritesFragment) || + (config.showTabs and GROUPS_TAB_MASK == 0 && this is GroupsFragment)) { + return + } + if (config.lastUsedContactSource.isEmpty()) { val grouped = contacts.groupBy { it.source }.maxWith(compareBy { it.value.size }) config.lastUsedContactSource = grouped?.key ?: ""