use of com.eveningoutpost.dexdrip.Models.UserNotification in project xDrip-plus by jamorham.
the class Notifications method calcuatleArmTimeUnclearalert.
// This is the absolute time, not time from now.
private long calcuatleArmTimeUnclearalert(Context ctx, long now, boolean unclearAlert) {
if (!unclearAlert) {
return Long.MAX_VALUE;
}
Long wakeTimeUnclear = Long.MAX_VALUE;
UserNotification userNotification = UserNotification.GetNotificationByType("bg_unclear_readings_alert");
if (userNotification == null) {
// This is the case, that we are in unclear sensor reading, but for small time, so there is no call
Log.i(TAG, "No active alert exists. returning Long.MAX_VALUE");
return Long.MAX_VALUE;
} else {
// This alert is snoozed
// reminder - userNotification.timestamp is the time that the alert should be played again
wakeTimeUnclear = (long) userNotification.timestamp;
}
if (wakeTimeUnclear < now) {
// we should alert now,
wakeTimeUnclear = now;
}
if (wakeTimeUnclear == Long.MAX_VALUE) {
// Should not happen
Log.e(TAG, "calcuatleArmTimeUnclearalert wakeTimeUnclear bad value setting it to one minute from now " + new Date(wakeTimeUnclear) + " in " + ((wakeTimeUnclear - now) / 60000d) + " minutes");
return now + 60 * 1000;
}
Log.w(TAG, "calcuatleArmTimeUnclearalert returning " + new Date(wakeTimeUnclear) + " in " + ((wakeTimeUnclear - now) / 60000d) + " minutes");
return wakeTimeUnclear;
}
use of com.eveningoutpost.dexdrip.Models.UserNotification in project xDrip-plus by jamorham.
the class Notifications method doubleCalibrationRequest.
private void doubleCalibrationRequest() {
UserNotification userNotification = UserNotification.lastDoubleCalibrationAlert();
if ((userNotification == null) || (userNotification.timestamp <= ((new Date().getTime()) - (60000 * calibration_snooze)))) {
if (userNotification != null) {
userNotification.delete();
}
UserNotification.create("Double Calibration", "double_calibration_alert", new Date().getTime());
String title = "Sensor is ready";
// KS String content = getString(R.string.sensor_is_ready_please_enter_double_calibration) + " (@" + JoH.hourMinuteString() + ")";
// KS Intent intent = new Intent(mContext, DoubleCalibrationActivity.class);
// KS calibrationNotificationCreate(title, content, intent, calibrationNotificationId);
}
}
use of com.eveningoutpost.dexdrip.Models.UserNotification in project xDrip-plus by jamorham.
the class Notifications method extraCalibrationRequest.
private void extraCalibrationRequest() {
UserNotification userNotification = UserNotification.lastExtraCalibrationAlert();
if ((userNotification == null) || (userNotification.timestamp <= ((new Date().getTime()) - (60000 * calibration_snooze)))) {
if (userNotification != null) {
userNotification.delete();
}
UserNotification.create("Extra Calibration Requested", "extra_calibration_alert", new Date().getTime());
String title = "Calibration Requested";
String content = "Increase performance by calibrating now" + " (@" + JoH.hourMinuteString() + ")";
// KS Intent intent = new Intent(mContext, AddCalibration.class);
// KS calibrationNotificationCreate(title, content, intent, extraCalibrationNotificationId);
}
}
Aggregations