diff --git a/app/src/main/java/org/linphone/contacts/ContactLoader.kt b/app/src/main/java/org/linphone/contacts/ContactLoader.kt index 48fb2d744..75682a8a9 100644 --- a/app/src/main/java/org/linphone/contacts/ContactLoader.kt +++ b/app/src/main/java/org/linphone/contacts/ContactLoader.kt @@ -99,8 +99,10 @@ class ContactLoader : LoaderManager.LoaderCallbacks { ContactsContract.Data.CONTACT_ID + " ASC" ) - // Update at most once every X (see variable value for actual duration) - loader.setUpdateThrottle(MIN_INTERVAL_TO_WAIT_BEFORE_REFRESH) + // WARNING: this doesn't prevent to be called again in onLoadFinished, + // it will only have for effect that the notified cursor will be the same as before + // instead of a new one with updated content! + // loader.setUpdateThrottle(MIN_INTERVAL_TO_WAIT_BEFORE_REFRESH) return loader } @@ -110,8 +112,16 @@ class ContactLoader : LoaderManager.LoaderCallbacks { if (cursor == null) { Log.e("$TAG Cursor is null!") return + } else if (cursor.isClosed) { + Log.e("$TAG Cursor is closed!") + return } + Log.i("$TAG Load finished, found ${cursor.count} entries in cursor") + if (cursor.isAfterLast) { + Log.w("$TAG Cursor position is after last, it was probably already used, nothing to do") + return + } coreContext.postOnCoreThread { val core = coreContext.core diff --git a/app/src/main/java/org/linphone/ui/main/contacts/viewmodel/ContactViewModel.kt b/app/src/main/java/org/linphone/ui/main/contacts/viewmodel/ContactViewModel.kt index 96f8b9954..31a06fe13 100644 --- a/app/src/main/java/org/linphone/ui/main/contacts/viewmodel/ContactViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/contacts/viewmodel/ContactViewModel.kt @@ -181,7 +181,7 @@ class ContactViewModel if (!::friend.isInitialized) return val found = coreContext.contactsManager.findContactById(refKey) - if (found != null && found != friend) { + if (found != null) { Log.i( "$TAG Found contact [${found.name}] matching ref key [$refKey] after contacts have been loaded/updated" )