mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-17 12:00:39 +01:00
avoid fetching contacts multiple times at once
This commit is contained in:
parent
9089edf04c
commit
f25e953cd4
@ -39,6 +39,8 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||
private var isSearchOpen = false
|
||||
private var searchMenuItem: MenuItem? = null
|
||||
private var werePermissionsHandled = false
|
||||
private var isFirstResume = true
|
||||
private var isGettingContacts = false
|
||||
|
||||
private var storedTextColor = 0
|
||||
private var storedBackgroundColor = 0
|
||||
@ -116,16 +118,18 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||
favorites_fragment?.startNameWithSurnameChanged(configStartNameWithSurname)
|
||||
}
|
||||
|
||||
if (werePermissionsHandled) {
|
||||
if (werePermissionsHandled && !isFirstResume) {
|
||||
if (viewpager.adapter == null) {
|
||||
initFragments()
|
||||
} else {
|
||||
refreshContacts(ALL_TABS_MASK)
|
||||
}
|
||||
|
||||
getAllFragments().forEach {
|
||||
it?.onActivityResume()
|
||||
}
|
||||
refreshContacts(ALL_TABS_MASK)
|
||||
}
|
||||
isFirstResume = false
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@ -396,11 +400,13 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||
}
|
||||
|
||||
override fun refreshContacts(refreshTabsMask: Int) {
|
||||
if (isActivityDestroyed()) {
|
||||
if (isActivityDestroyed() || isGettingContacts) {
|
||||
return
|
||||
}
|
||||
|
||||
isGettingContacts = true
|
||||
ContactsHelper(this).getContacts {
|
||||
isGettingContacts = false
|
||||
if (isActivityDestroyed()) {
|
||||
return@getContacts
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user