Make delay before showing contacts operation in progress spinner configurable
This commit is contained in:
parent
2c846f6727
commit
cc632d89f3
2 changed files with 6 additions and 1 deletions
|
@ -27,6 +27,7 @@ import androidx.lifecycle.viewModelScope
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
|
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||||
import org.linphone.contact.Contact
|
import org.linphone.contact.Contact
|
||||||
import org.linphone.contact.ContactsUpdatedListenerStub
|
import org.linphone.contact.ContactsUpdatedListenerStub
|
||||||
import org.linphone.contact.NativeContact
|
import org.linphone.contact.NativeContact
|
||||||
|
@ -106,9 +107,10 @@ class ContactsListViewModel : ViewModel() {
|
||||||
fastFetchJob?.cancel()
|
fastFetchJob?.cancel()
|
||||||
coreContext.contactsManager.magicSearch.getContactsAsync(filterValue, domain, filter)
|
coreContext.contactsManager.magicSearch.getContactsAsync(filterValue, domain, filter)
|
||||||
|
|
||||||
|
val spinnerDelay = corePreferences.delayBeforeShowingContactsSearchSpinner.toLong()
|
||||||
fastFetchJob = viewModelScope.launch {
|
fastFetchJob = viewModelScope.launch {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
delay(200)
|
delay(spinnerDelay)
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
if (searchResultsPending) {
|
if (searchResultsPending) {
|
||||||
fetchInProgress.value = true
|
fetchInProgress.value = true
|
||||||
|
|
|
@ -431,6 +431,9 @@ class CorePreferences constructor(private val context: Context) {
|
||||||
val fetchContactsFromDefaultDirectory: Boolean
|
val fetchContactsFromDefaultDirectory: Boolean
|
||||||
get() = config.getBool("app", "fetch_contacts_from_default_directory", true)
|
get() = config.getBool("app", "fetch_contacts_from_default_directory", true)
|
||||||
|
|
||||||
|
val delayBeforeShowingContactsSearchSpinner: Int
|
||||||
|
get() = config.getInt("app", "delay_before_showing_contacts_search_spinner", 200)
|
||||||
|
|
||||||
// From Android Contact APIs we can also retrieve the internationalized phone number
|
// From Android Contact APIs we can also retrieve the internationalized phone number
|
||||||
// By default we display the same value as the native address book app
|
// By default we display the same value as the native address book app
|
||||||
val preferNormalizedPhoneNumbersFromAddressBook: Boolean
|
val preferNormalizedPhoneNumbersFromAddressBook: Boolean
|
||||||
|
|
Loading…
Reference in a new issue