Java Code Examples for com.eveningoutpost.dexdrip.UtilityModels.Notifications#start()

The following examples show how to use com.eveningoutpost.dexdrip.UtilityModels.Notifications#start() . 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: NewDataObserver.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static void newBgReading(BgReading bgReading, boolean is_follower) {

        sendToPebble();
        sendToWear();
        sendToAmazfit();
        sendToLeFun();
        sendToMiBand();
        sendToBlueJay();
        sendToRemoteBlueJay();
        Notifications.start();
        uploadToShare(bgReading, is_follower);
        textToSpeech(bgReading, null);
        LibreBlock.UpdateBgVal(bgReading.timestamp, bgReading.calculated_value);
        LockScreenWallPaper.setIfEnabled();
        TidepoolEntry.newData();

    }
 
Example 2
Source File: NewDataObserver.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static void newBgReading(BgReading bgReading, boolean is_follower) {

        sendToPebble();
        sendToWear();
        sendToAmazfit();
        sendToLeFun();
        sendToMiBand();
        sendToBlueJay();
        sendToRemoteBlueJay();
        Notifications.start();
        uploadToShare(bgReading, is_follower);
        textToSpeech(bgReading, null);
        LibreBlock.UpdateBgVal(bgReading.timestamp, bgReading.calculated_value);
        LockScreenWallPaper.setIfEnabled();
        TidepoolEntry.newData();

    }
 
Example 3
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static void create(EGVRecord egvRecord, long addativeOffset, Context context) {
    BgReading bgReading = BgReading.getForTimestamp(egvRecord.getSystemTime().getTime() + addativeOffset);
    Log.i(TAG, "create: Looking for BG reading to tag this thing to: " + egvRecord.getBGValue());
    if (bgReading != null) {
        bgReading.calculated_value = egvRecord.getBGValue();
        if (egvRecord.getBGValue() <= 13) {
            Calibration calibration = bgReading.calibration;
            double firstAdjSlope = calibration.first_slope + (calibration.first_decay * (Math.ceil(new Date().getTime() - calibration.timestamp) / (1000 * 60 * 10)));
            double calSlope = (calibration.first_scale / firstAdjSlope) * 1000;
            double calIntercept = ((calibration.first_scale * calibration.first_intercept) / firstAdjSlope) * -1;
            bgReading.raw_calculated = (((calSlope * bgReading.raw_data) + calIntercept) - 5);
        }
        Log.i(TAG, "create: NEW VALUE CALCULATED AT: " + bgReading.calculated_value);
        bgReading.calculated_value_slope = bgReading.slopefromName(egvRecord.getTrend().friendlyTrendName());
        bgReading.noise = egvRecord.noiseValue();
        String friendlyName = egvRecord.getTrend().friendlyTrendName();
        if (friendlyName.compareTo("NONE") == 0 ||
                friendlyName.compareTo("NOT_COMPUTABLE") == 0 ||
                friendlyName.compareTo("NOT COMPUTABLE") == 0 ||
                friendlyName.compareTo("OUT OF RANGE") == 0 ||
                friendlyName.compareTo("OUT_OF_RANGE") == 0) {
            bgReading.hide_slope = true;
        }
        bgReading.save();
        bgReading.find_new_curve();
        bgReading.find_new_raw_curve();
        //context.startService(new Intent(context, Notifications.class));
        Notifications.start(); // this may not be needed as it is duplicated in handleNewBgReading
        BgSendQueue.handleNewBgReading(bgReading, "create", context);
    }
}
 
Example 4
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static void notifyAndSync(final BgReading bgr) {
    final boolean recent = bgr.isCurrent();
    if (recent) {
        Notifications.start(); // may not be needed as this is duplicated in handleNewBgReading
        // probably not wanted for G5 internal values?
        //bgr.injectNoise(true); // Add noise parameter for nightscout
        //bgr.injectDisplayGlucose(BestGlucose.getDisplayGlucose()); // Add display glucose for nightscout
    }
    BgSendQueue.handleNewBgReading(bgr, "create", xdrip.getAppContext(), Home.get_follower(), !recent); // pebble and widget and follower
}
 
Example 5
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static void create(EGVRecord egvRecord, long addativeOffset, Context context) {
    BgReading bgReading = BgReading.getForTimestamp(egvRecord.getSystemTime().getTime() + addativeOffset);
    Log.i(TAG, "create: Looking for BG reading to tag this thing to: " + egvRecord.getBGValue());
    if (bgReading != null) {
        bgReading.calculated_value = egvRecord.getBGValue();
        if (egvRecord.getBGValue() <= 13) {
            Calibration calibration = bgReading.calibration;
            double firstAdjSlope = calibration.first_slope + (calibration.first_decay * (Math.ceil(new Date().getTime() - calibration.timestamp) / (1000 * 60 * 10)));
            double calSlope = (calibration.first_scale / firstAdjSlope) * 1000;
            double calIntercept = ((calibration.first_scale * calibration.first_intercept) / firstAdjSlope) * -1;
            bgReading.raw_calculated = (((calSlope * bgReading.raw_data) + calIntercept) - 5);
        }
        Log.i(TAG, "create: NEW VALUE CALCULATED AT: " + bgReading.calculated_value);
        bgReading.calculated_value_slope = bgReading.slopefromName(egvRecord.getTrend().friendlyTrendName());
        bgReading.noise = egvRecord.noiseValue();
        String friendlyName = egvRecord.getTrend().friendlyTrendName();
        if (friendlyName.compareTo("NONE") == 0 ||
                friendlyName.compareTo("NOT_COMPUTABLE") == 0 ||
                friendlyName.compareTo("NOT COMPUTABLE") == 0 ||
                friendlyName.compareTo("OUT OF RANGE") == 0 ||
                friendlyName.compareTo("OUT_OF_RANGE") == 0) {
            bgReading.hide_slope = true;
        }
        bgReading.save();
        bgReading.find_new_curve();
        bgReading.find_new_raw_curve();
        //context.startService(new Intent(context, Notifications.class));
        Notifications.start(); // this may not be needed as it is duplicated in handleNewBgReading
        BgSendQueue.handleNewBgReading(bgReading, "create", context);
    }
}
 
Example 6
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static void notifyAndSync(final BgReading bgr) {
    final boolean recent = bgr.isCurrent();
    if (recent) {
        Notifications.start(); // may not be needed as this is duplicated in handleNewBgReading
        // probably not wanted for G5 internal values?
        //bgr.injectNoise(true); // Add noise parameter for nightscout
        //bgr.injectDisplayGlucose(BestGlucose.getDisplayGlucose()); // Add display glucose for nightscout
    }
    BgSendQueue.handleNewBgReading(bgr, "create", xdrip.getAppContext(), Home.get_follower(), !recent); // pebble and widget and follower
}
 
Example 7
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static void create(EGVRecord egvRecord, long addativeOffset, Context context) {
    BgReading bgReading = BgReading.getForTimestamp(egvRecord.getSystemTime().getTime() + addativeOffset);
    Log.i(TAG, "create: Looking for BG reading to tag this thing to: " + egvRecord.getBGValue());
    if (bgReading != null) {
        bgReading.calculated_value = egvRecord.getBGValue();
        if (egvRecord.getBGValue() <= 13) {
            Calibration calibration = bgReading.calibration;
            double firstAdjSlope = calibration.first_slope + (calibration.first_decay * (Math.ceil(new Date().getTime() - calibration.timestamp) / (1000 * 60 * 10)));
            double calSlope = (calibration.first_scale / firstAdjSlope) * 1000;
            double calIntercept = ((calibration.first_scale * calibration.first_intercept) / firstAdjSlope) * -1;
            bgReading.raw_calculated = (((calSlope * bgReading.raw_data) + calIntercept) - 5);
        }
        Log.i(TAG, "create: NEW VALUE CALCULATED AT: " + bgReading.calculated_value);
        bgReading.calculated_value_slope = bgReading.slopefromName(egvRecord.getTrend().friendlyTrendName());
        bgReading.noise = egvRecord.noiseValue();
        String friendlyName = egvRecord.getTrend().friendlyTrendName();
        if (friendlyName.compareTo("NONE") == 0 ||
                friendlyName.compareTo("NOT_COMPUTABLE") == 0 ||
                friendlyName.compareTo("NOT COMPUTABLE") == 0 ||
                friendlyName.compareTo("OUT OF RANGE") == 0 ||
                friendlyName.compareTo("OUT_OF_RANGE") == 0) {
            bgReading.hide_slope = true;
        }
        bgReading.save();
        bgReading.find_new_curve();
        bgReading.find_new_raw_curve();
        //context.startService(new Intent(context, Notifications.class));
        Notifications.start(); // this may not be needed as it is duplicated in handleNewBgReading
        BgSendQueue.handleNewBgReading(bgReading, "create", context);
    }
}
 
Example 8
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static void notifyAndSync(final BgReading bgr) {
    final boolean recent = bgr.isCurrent();
    if (recent) {
        Notifications.start(); // may not be needed as this is duplicated in handleNewBgReading
        // probably not wanted for G5 internal values?
        //bgr.injectNoise(true); // Add noise parameter for nightscout
        //bgr.injectDisplayGlucose(BestGlucose.getDisplayGlucose()); // Add display glucose for nightscout
    }
    BgSendQueue.handleNewBgReading(bgr, "create", xdrip.getAppContext(), Home.get_follower(), !recent); // pebble and widget and follower
}
 
Example 9
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static void create(EGVRecord egvRecord, long addativeOffset, Context context) {
    BgReading bgReading = BgReading.getForTimestamp(egvRecord.getSystemTime().getTime() + addativeOffset);
    Log.i(TAG, "create: Looking for BG reading to tag this thing to: " + egvRecord.getBGValue());
    if (bgReading != null) {
        bgReading.calculated_value = egvRecord.getBGValue();
        if (egvRecord.getBGValue() <= 13) {
            Calibration calibration = bgReading.calibration;
            double firstAdjSlope = calibration.first_slope + (calibration.first_decay * (Math.ceil(new Date().getTime() - calibration.timestamp) / (1000 * 60 * 10)));
            double calSlope = (calibration.first_scale / firstAdjSlope) * 1000;
            double calIntercept = ((calibration.first_scale * calibration.first_intercept) / firstAdjSlope) * -1;
            bgReading.raw_calculated = (((calSlope * bgReading.raw_data) + calIntercept) - 5);
        }
        Log.i(TAG, "create: NEW VALUE CALCULATED AT: " + bgReading.calculated_value);
        bgReading.calculated_value_slope = bgReading.slopefromName(egvRecord.getTrend().friendlyTrendName());
        bgReading.noise = egvRecord.noiseValue();
        String friendlyName = egvRecord.getTrend().friendlyTrendName();
        if (friendlyName.compareTo("NONE") == 0 ||
                friendlyName.compareTo("NOT_COMPUTABLE") == 0 ||
                friendlyName.compareTo("NOT COMPUTABLE") == 0 ||
                friendlyName.compareTo("OUT OF RANGE") == 0 ||
                friendlyName.compareTo("OUT_OF_RANGE") == 0) {
            bgReading.hide_slope = true;
        }
        bgReading.save();
        bgReading.find_new_curve();
        bgReading.find_new_raw_curve();
        //context.startService(new Intent(context, Notifications.class));
        Notifications.start(); // this may not be needed as it is duplicated in handleNewBgReading
        BgSendQueue.handleNewBgReading(bgReading, "create", context);
    }
}
 
Example 10
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static void notifyAndSync(final BgReading bgr) {
    final boolean recent = bgr.isCurrent();
    if (recent) {
        Notifications.start(); // may not be needed as this is duplicated in handleNewBgReading
        // probably not wanted for G5 internal values?
        //bgr.injectNoise(true); // Add noise parameter for nightscout
        //bgr.injectDisplayGlucose(BestGlucose.getDisplayGlucose()); // Add display glucose for nightscout
    }
    BgSendQueue.handleNewBgReading(bgr, "create", xdrip.getAppContext(), Home.get_follower(), !recent); // pebble and widget and follower
}
 
Example 11
Source File: Calibration.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static void create(CalRecord[] calRecords, Context context, boolean override, long addativeOffset) {
        //TODO: Change calibration.last and other queries to order calibrations by timestamp rather than ID
        Log.i("CALIBRATION-CHECK-IN: ", "Creating Calibration Record");
        Sensor sensor = Sensor.currentSensor();
        CalRecord firstCalRecord = calRecords[0];
        CalRecord secondCalRecord = calRecords[0];
//        CalRecord secondCalRecord = calRecords[calRecords.length - 1];
        //TODO: Figgure out how the ratio between the two is determined
        double calSlope = ((secondCalRecord.getScale() / secondCalRecord.getSlope()) + (3 * firstCalRecord.getScale() / firstCalRecord.getSlope())) * 250;

        double calIntercept = (((secondCalRecord.getScale() * secondCalRecord.getIntercept()) / secondCalRecord.getSlope()) + ((3 * firstCalRecord.getScale() * firstCalRecord.getIntercept()) / firstCalRecord.getSlope())) / -4;
        if (sensor != null) {
            for (int i = 0; i < firstCalRecord.getCalSubrecords().length - 1; i++) {
                if (((firstCalRecord.getCalSubrecords()[i] != null && Calibration.is_new(firstCalRecord.getCalSubrecords()[i], addativeOffset))) || (i == 0 && override)) {
                    CalSubrecord calSubrecord = firstCalRecord.getCalSubrecords()[i];

                    Calibration calibration = new Calibration();
                    calibration.bg = calSubrecord.getCalBGL();
                    calibration.timestamp = calSubrecord.getDateEntered().getTime() + addativeOffset;
                    calibration.raw_timestamp = calibration.timestamp;
                    if (calibration.timestamp > new Date().getTime()) {
                        Log.d(TAG, "ERROR - Calibration timestamp is from the future, wont save!");
                        return;
                    }
                    calibration.raw_value = calSubrecord.getCalRaw() / 1000;
                    calibration.slope = calSlope;
                    calibration.intercept = calIntercept;

                    calibration.sensor_confidence = ((-0.0018 * calibration.bg * calibration.bg) + (0.6657 * calibration.bg) + 36.7505) / 100;
                    if (calibration.sensor_confidence <= 0) {
                        calibration.sensor_confidence = 0;
                    }
                    calibration.slope_confidence = 0.8; //TODO: query backwards to find this value near the timestamp
                    calibration.estimate_raw_at_time_of_calibration = calSubrecord.getCalRaw() / 1000;
                    calibration.sensor = sensor;
                    calibration.sensor_age_at_time_of_estimation = calibration.timestamp - sensor.started_at;
                    calibration.uuid = UUID.randomUUID().toString();
                    calibration.sensor_uuid = sensor.uuid;
                    calibration.check_in = true;

                    calibration.first_decay = firstCalRecord.getDecay();
                    calibration.second_decay = secondCalRecord.getDecay();
                    calibration.first_slope = firstCalRecord.getSlope();
                    calibration.second_slope = secondCalRecord.getSlope();
                    calibration.first_scale = firstCalRecord.getScale();
                    calibration.second_scale = secondCalRecord.getScale();
                    calibration.first_intercept = firstCalRecord.getIntercept();
                    calibration.second_intercept = secondCalRecord.getIntercept();

                    calibration.save();
                    CalibrationSendQueue.addToQueue(calibration, context);
                    Calibration.requestCalibrationIfRangeTooNarrow();
                    newFingerStickData();
                }
            }
            if (firstCalRecord.getCalSubrecords()[0] != null && firstCalRecord.getCalSubrecords()[2] == null) {
                if (Calibration.latest(2).size() == 1) {
                    Calibration.create(calRecords, context, true, 0);
                }
            }
            Notifications.start();
        }
    }
 
Example 12
Source File: SnoozeActivity.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public void recheckAlerts() {
    Notifications.start();
    JoH.startService(MissedReadingService.class); // TODO this should be rate limited or similar as it is polled in various locations leading to excessive cpu
}
 
Example 13
Source File: Calibration.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static void create(CalRecord[] calRecords, Context context, boolean override, long addativeOffset) {
        //TODO: Change calibration.last and other queries to order calibrations by timestamp rather than ID
        Log.i("CALIBRATION-CHECK-IN: ", "Creating Calibration Record");
        Sensor sensor = Sensor.currentSensor();
        CalRecord firstCalRecord = calRecords[0];
        CalRecord secondCalRecord = calRecords[0];
//        CalRecord secondCalRecord = calRecords[calRecords.length - 1];
        //TODO: Figgure out how the ratio between the two is determined
        double calSlope = ((secondCalRecord.getScale() / secondCalRecord.getSlope()) + (3 * firstCalRecord.getScale() / firstCalRecord.getSlope())) * 250;

        double calIntercept = (((secondCalRecord.getScale() * secondCalRecord.getIntercept()) / secondCalRecord.getSlope()) + ((3 * firstCalRecord.getScale() * firstCalRecord.getIntercept()) / firstCalRecord.getSlope())) / -4;
        if (sensor != null) {
            for (int i = 0; i < firstCalRecord.getCalSubrecords().length - 1; i++) {
                if (((firstCalRecord.getCalSubrecords()[i] != null && Calibration.is_new(firstCalRecord.getCalSubrecords()[i], addativeOffset))) || (i == 0 && override)) {
                    CalSubrecord calSubrecord = firstCalRecord.getCalSubrecords()[i];

                    Calibration calibration = new Calibration();
                    calibration.bg = calSubrecord.getCalBGL();
                    calibration.timestamp = calSubrecord.getDateEntered().getTime() + addativeOffset;
                    calibration.raw_timestamp = calibration.timestamp;
                    if (calibration.timestamp > new Date().getTime()) {
                        Log.d(TAG, "ERROR - Calibration timestamp is from the future, wont save!");
                        return;
                    }
                    calibration.raw_value = calSubrecord.getCalRaw() / 1000;
                    calibration.slope = calSlope;
                    calibration.intercept = calIntercept;

                    calibration.sensor_confidence = ((-0.0018 * calibration.bg * calibration.bg) + (0.6657 * calibration.bg) + 36.7505) / 100;
                    if (calibration.sensor_confidence <= 0) {
                        calibration.sensor_confidence = 0;
                    }
                    calibration.slope_confidence = 0.8; //TODO: query backwards to find this value near the timestamp
                    calibration.estimate_raw_at_time_of_calibration = calSubrecord.getCalRaw() / 1000;
                    calibration.sensor = sensor;
                    calibration.sensor_age_at_time_of_estimation = calibration.timestamp - sensor.started_at;
                    calibration.uuid = UUID.randomUUID().toString();
                    calibration.sensor_uuid = sensor.uuid;
                    calibration.check_in = true;

                    calibration.first_decay = firstCalRecord.getDecay();
                    calibration.second_decay = secondCalRecord.getDecay();
                    calibration.first_slope = firstCalRecord.getSlope();
                    calibration.second_slope = secondCalRecord.getSlope();
                    calibration.first_scale = firstCalRecord.getScale();
                    calibration.second_scale = secondCalRecord.getScale();
                    calibration.first_intercept = firstCalRecord.getIntercept();
                    calibration.second_intercept = secondCalRecord.getIntercept();

                    calibration.save();
                    CalibrationSendQueue.addToQueue(calibration, context);
                    Calibration.requestCalibrationIfRangeTooNarrow();
                    newFingerStickData();
                }
            }
            if (firstCalRecord.getCalSubrecords()[0] != null && firstCalRecord.getCalSubrecords()[2] == null) {
                if (Calibration.latest(2).size() == 1) {
                    Calibration.create(calRecords, context, true, 0);
                }
            }
            Notifications.start();
        }
    }
 
Example 14
Source File: SnoozeActivity.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public void recheckAlerts() {
    Notifications.start();
    JoH.startService(MissedReadingService.class); // TODO this should be rate limited or similar as it is polled in various locations leading to excessive cpu
}