do not spend time fetching data for hidden fragments

This commit is contained in:
tibbi 2018-08-02 15:16:24 +02:00
parent d8a26a87a6
commit 7b577aa082

View File

@ -86,6 +86,12 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
}
fun refreshContacts(contacts: ArrayList<Contact>) {
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 ?: ""