Closed NightDeveloper-wq closed 3 years ago
Hrmm, well in the change set, I'm just providing what Realm is giving me. Is your RealmResults sorted? To stabilize change indexes, it's best to use some form of sort()
.
My list is already sorted but I guess the error is here. The setValue
or postValue
function or directly onChange
function in ManagedLiveResults
is not always triggered because of these checks. Can you check it out?
private OrderedRealmCollectionChangeListener<RealmResults<T>> realmChangeListener = new OrderedRealmCollectionChangeListener<RealmResults<T>>() {
@Override
public void onChange(@Nonnull RealmResults<T> realmResults, @Nonnull OrderedCollectionChangeSet changeSet) {
Logger.i("xx changeListener changeSet:" + changeSet + "realmResults: " + realmResults.asJSON());
RealmManager.ManagedChangeSet<T> managedChangeSet = new RealmManager.ManagedChangeSet<>(realmResults, changeSet);
if (changeSet.getState() == OrderedCollectionChangeSet.State.INITIAL) {
setValue(managedChangeSet);
} else {
postValue(managedChangeSet);
}
}
};
Hmm. :/ this could be a bug in my sample then, but you can try just using setValue
in both cases
I thought so but I couldn't be sure. Very thanks
I have an activity which has fragment. When the fragment is first opened, I set the observer and the adapter, then I make my realm query with
fillQuery
and pull all the data. When it is updated, I call adapter'supdateData
function through the observer in fragment. It also calls the dispatchUpdatesTo function, but this function is not triggered with every change.getInsertionRanges
andgetChangeRanges
values are not triggered on every change and addition insideMonarchyDiffResult
.I have a list from 80th to 92nd index. As seen in my log in this list, index updates 85,87,89 do not come to the getChangeRanges function in any way. This causes those indexes not to be updated.
I wondered if there was an error in my code. Can you please help?
My log:
My fragment code:
Adapter code: