Java Code Examples for com.eveningoutpost.dexdrip.Models.BgReading#latestForGraphAsc()

The following examples show how to use com.eveningoutpost.dexdrip.Models.BgReading#latestForGraphAsc() . 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: ListenerService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private synchronized DataMap getWearBgReadingData(int count, long last_send_time, int min_count) {
    forceGoogleApiConnect();

    Log.d(TAG, "getWearBgReadingData last_send_time:" + JoH.dateTimeText(last_send_time));

    BgReading last_bg = BgReading.last();
    if (last_bg != null) {
        Log.d(TAG, "getWearBgReadingData last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp));
    }

    if (last_bg != null && last_send_time <= last_bg.timestamp) {//startTime
        long last_send_success = last_send_time;
        Log.d(TAG, "getWearBgData last_send_time < last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp));
        final List<BgReading> graph_bgs = BgReading.latestForGraphAsc(count, last_send_time);
        if (!graph_bgs.isEmpty() && graph_bgs.size() > min_count) {
            //Log.d(TAG, "getWearBgData count = " + graph_bgs.size());
            final DataMap entries = dataMap(last_bg);
            final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
            for (BgReading bg : graph_bgs) {
                dataMaps.add(dataMap(bg));
                last_send_success = bg.timestamp;
                //Log.d(TAG, "getWearBgData bg getId:" + bg.getId() + " raw_data:" + bg.raw_data + " filtered_data:" + bg.filtered_data + " timestamp:" + bg.timestamp + " uuid:" + bg.uuid);
            }
            entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
            entries.putDataMapArrayList("entries", dataMaps);
            Log.i(TAG, "getWearBgReadingData SYNCED BGs up to " + JoH.dateTimeText(last_send_success) + " count = " + graph_bgs.size());
            return entries;
        } else
            Log.i(TAG, "getWearBgReading SYNCED BGs up to " + JoH.dateTimeText(last_send_success) + " count = 0");
    }
    return null;
}
 
Example 2
Source File: UploadChunk.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
static long getOldestRecordTimeStamp() {
    // TODO we could make sure we include records older than the first bg record for completeness

    final long start = 0;
    final long end = JoH.tsl();

    final List<BgReading> bgReadingList = BgReading.latestForGraphAsc(1, start, end);
    if (bgReadingList != null && bgReadingList.size() > 0) {
        return bgReadingList.get(0).timestamp;
    }
    return -1;
}
 
Example 3
Source File: ListenerService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private synchronized DataMap getWearBgReadingData(int count, long last_send_time, int min_count) {
    forceGoogleApiConnect();

    Log.d(TAG, "getWearBgReadingData last_send_time:" + JoH.dateTimeText(last_send_time));

    BgReading last_bg = BgReading.last();
    if (last_bg != null) {
        Log.d(TAG, "getWearBgReadingData last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp));
    }

    if (last_bg != null && last_send_time <= last_bg.timestamp) {//startTime
        long last_send_success = last_send_time;
        Log.d(TAG, "getWearBgData last_send_time < last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp));
        final List<BgReading> graph_bgs = BgReading.latestForGraphAsc(count, last_send_time);
        if (!graph_bgs.isEmpty() && graph_bgs.size() > min_count) {
            //Log.d(TAG, "getWearBgData count = " + graph_bgs.size());
            final DataMap entries = dataMap(last_bg);
            final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
            for (BgReading bg : graph_bgs) {
                dataMaps.add(dataMap(bg));
                last_send_success = bg.timestamp;
                //Log.d(TAG, "getWearBgData bg getId:" + bg.getId() + " raw_data:" + bg.raw_data + " filtered_data:" + bg.filtered_data + " timestamp:" + bg.timestamp + " uuid:" + bg.uuid);
            }
            entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
            entries.putDataMapArrayList("entries", dataMaps);
            Log.i(TAG, "getWearBgReadingData SYNCED BGs up to " + JoH.dateTimeText(last_send_success) + " count = " + graph_bgs.size());
            return entries;
        } else
            Log.i(TAG, "getWearBgReading SYNCED BGs up to " + JoH.dateTimeText(last_send_success) + " count = 0");
    }
    return null;
}
 
Example 4
Source File: UploadChunk.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
static long getOldestRecordTimeStamp() {
    // TODO we could make sure we include records older than the first bg record for completeness

    final long start = 0;
    final long end = JoH.tsl();

    final List<BgReading> bgReadingList = BgReading.latestForGraphAsc(1, start, end);
    if (bgReadingList != null && bgReadingList.size() > 0) {
        return bgReadingList.get(0).timestamp;
    }
    return -1;
}