io.realm.OrderedCollectionChangeSet Java Examples

The following examples show how to use io.realm.OrderedCollectionChangeSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From 600SeriesAndroidUploader with MIT License 6 votes vote down vote up
private void startDisplayCgm() {
    Log.d(TAG, "startDisplayCgm");

    displayCgmResults = historyRealm.where(PumpHistoryCGM.class)
            .notEqualTo("sgv", 0)
            .sort("eventDate", Sort.ASCENDING)
            .findAllAsync();

    displayCgmResults.addChangeListener(new OrderedRealmCollectionChangeListener<RealmResults<PumpHistoryCGM>>() {
        @Override
        public void onChange(@NonNull RealmResults realmResults, @NonNull OrderedCollectionChangeSet changeSet) {
            Log.d(TAG, "displayCgmResults triggered size=" + displayCgmResults.size());
            refreshDisplayCgm();
            refreshDisplayChart();
        }
    });
}
 
Example #2
Source File: MainActivity.java    From 600SeriesAndroidUploader with MIT License 6 votes vote down vote up
private void startDisplayChart() {
    Log.d(TAG, "startDisplayChart");
    if (historyRealm == null) return;

    // reset if last chart interaction was over 5 mins
    if (System.currentTimeMillis() - chartChangeTimestamp > 5 * 60000L)
        chartTimeOffset = 0;

    final long timestamp = timeLastSGV == 0 ? System.currentTimeMillis() : timeLastSGV - chartTimeOffset;

    displayChartResults = historyRealm.where(PumpHistoryCGM.class)
            .notEqualTo("sgv", 0)
            .greaterThan("eventDate", new Date(timestamp - 24 * 60 * 60000L))
            .lessThanOrEqualTo("eventDate", new Date(timestamp + 5 * 60000L))
            .sort("eventDate", Sort.ASCENDING)
            .findAllAsync();

    displayChartResults.addChangeListener(new OrderedRealmCollectionChangeListener<RealmResults<PumpHistoryCGM>>() {
        @Override
        public void onChange(@NonNull RealmResults<PumpHistoryCGM> realmResults, @NonNull OrderedCollectionChangeSet changeSet) {
            Log.d(TAG, "displayChartResults triggered size=" + displayChartResults.size());
            updateChart(realmResults, timestamp);
        }
    });
}
 
Example #3
Source File: ManagedLiveResults.java    From realm-monarchy with Apache License 2.0 5 votes vote down vote up
@Override
public void onChange(@Nonnull RealmResults<T> realmResults, @Nonnull OrderedCollectionChangeSet changeSet) {
    Monarchy.ManagedChangeSet<T> managedChangeSet = new Monarchy.ManagedChangeSet<>(realmResults, changeSet);
    if(!asAsync && changeSet.getState() == OrderedCollectionChangeSet.State.INITIAL) {
        setValue(managedChangeSet);
    } else {
        postValue(managedChangeSet);
    }
}
 
Example #4
Source File: MainActivity.java    From 600SeriesAndroidUploader with MIT License 5 votes vote down vote up
private void startDisplayPump() {
    Log.d(TAG, "startDisplayPump");

    displayPumpResults = mRealm.where(PumpStatusEvent.class)
            .sort("eventDate", Sort.ASCENDING)
            .findAllAsync();

    displayPumpResults.addChangeListener(new OrderedRealmCollectionChangeListener<RealmResults<PumpStatusEvent>>() {
        @Override
        public void onChange(@NonNull RealmResults realmResults, @NonNull OrderedCollectionChangeSet changeSet) {
            Log.d(TAG, "displayPumpResults triggered size=" + displayPumpResults.size());
            refreshDisplayPump();
        }
    });
}
 
Example #5
Source File: Monarchy.java    From realm-monarchy with Apache License 2.0 4 votes vote down vote up
ManagedChangeSet(RealmResults<T> realmResults, OrderedCollectionChangeSet orderedCollectionChangeSet) {
    this.realmResults = realmResults;
    this.orderedCollectionChangeSet = orderedCollectionChangeSet;
}
 
Example #6
Source File: Monarchy.java    From realm-monarchy with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the ordered collection change set.
 *
 * @return the change set
 */
@Nonnull
public OrderedCollectionChangeSet getOrderedCollectionChangeSet() {
    return orderedCollectionChangeSet;
}