mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-05-18 11:35:54 +02: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 isSearchOpen = false
|
||||||
private var searchMenuItem: MenuItem? = null
|
private var searchMenuItem: MenuItem? = null
|
||||||
private var werePermissionsHandled = false
|
private var werePermissionsHandled = false
|
||||||
|
private var isFirstResume = true
|
||||||
|
private var isGettingContacts = false
|
||||||
|
|
||||||
private var storedTextColor = 0
|
private var storedTextColor = 0
|
||||||
private var storedBackgroundColor = 0
|
private var storedBackgroundColor = 0
|
||||||
@ -116,16 +118,18 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
favorites_fragment?.startNameWithSurnameChanged(configStartNameWithSurname)
|
favorites_fragment?.startNameWithSurnameChanged(configStartNameWithSurname)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (werePermissionsHandled) {
|
if (werePermissionsHandled && !isFirstResume) {
|
||||||
if (viewpager.adapter == null) {
|
if (viewpager.adapter == null) {
|
||||||
initFragments()
|
initFragments()
|
||||||
|
} else {
|
||||||
|
refreshContacts(ALL_TABS_MASK)
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
it?.onActivityResume()
|
it?.onActivityResume()
|
||||||
}
|
}
|
||||||
refreshContacts(ALL_TABS_MASK)
|
|
||||||
}
|
}
|
||||||
|
isFirstResume = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
@ -396,11 +400,13 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun refreshContacts(refreshTabsMask: Int) {
|
override fun refreshContacts(refreshTabsMask: Int) {
|
||||||
if (isActivityDestroyed()) {
|
if (isActivityDestroyed() || isGettingContacts) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isGettingContacts = true
|
||||||
ContactsHelper(this).getContacts {
|
ContactsHelper(this).getContacts {
|
||||||
|
isGettingContacts = false
|
||||||
if (isActivityDestroyed()) {
|
if (isActivityDestroyed()) {
|
||||||
return@getContacts
|
return@getContacts
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user