From 89ee77575c31a7c3b76e96be68d5acae96f66dbb Mon Sep 17 00:00:00 2001 From: Andrii Chubko Date: Tue, 17 Aug 2021 16:57:43 +0300 Subject: [PATCH] Fix contacts not refreshing when search bar is open Before, if you opened search bar and went on to add a contact, the new contact wasn't shown. With this change, contacts will be refreshed and previous search query will be reapplied. --- .../contacts/pro/activities/MainActivity.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt index 5b5d2064..416ed2de 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt @@ -52,6 +52,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { private var isSearchOpen = false private var searchMenuItem: MenuItem? = null + private var searchQuery = "" private var werePermissionsHandled = false private var isFirstResume = true private var isGettingContacts = false @@ -229,6 +230,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { override fun onQueryTextChange(newText: String): Boolean { if (isSearchOpen) { + searchQuery = newText getCurrentFragment()?.onSearchQueryChanged(newText) } return true @@ -540,7 +542,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { } override fun refreshContacts(refreshTabsMask: Int) { - if (isDestroyed || isFinishing || isGettingContacts || isSearchOpen) { + if (isDestroyed || isFinishing || isGettingContacts) { return } @@ -572,6 +574,10 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { } groups_fragment?.refreshContacts(contacts) } + + if (isSearchOpen) { + getCurrentFragment()?.onSearchQueryChanged(searchQuery) + } } }