diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/MyViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/MyViewPagerFragment.kt index d5a30aef..d8d41319 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/MyViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/MyViewPagerFragment.kt @@ -128,19 +128,16 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) private fun setupContacts(contacts: ArrayList) { if (this is GroupsFragment) { - setupGroupsAdapter(contacts) + setupGroupsAdapter(contacts) { + groupsIgnoringSearch = (fragment_list?.adapter as? GroupsAdapter)?.groups ?: ArrayList() + } } else { setupContactsFavoritesAdapter(contacts) - } - - if (this is ContactsFragment || this is FavoritesFragment) { contactsIgnoringSearch = (fragment_list?.adapter as? ContactsAdapter)?.contactItems ?: ArrayList() - } else if (this is GroupsFragment) { - groupsIgnoringSearch = (fragment_list?.adapter as? GroupsAdapter)?.groups ?: ArrayList() } } - private fun setupGroupsAdapter(contacts: ArrayList) { + private fun setupGroupsAdapter(contacts: ArrayList, callback: () -> Unit) { ContactsHelper(activity!!).getStoredGroups { var storedGroups = it contacts.forEach { @@ -180,6 +177,8 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) updateItems(storedGroups) } } + + callback() } }