io.realm.OrderedRealmCollectionChangeListener Java Examples

The following examples show how to use io.realm.OrderedRealmCollectionChangeListener. 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: 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();
        }
    });
}