Java Code Examples for com.eveningoutpost.dexdrip.UtilityModels.Notifications#persistentHighAlert()
The following examples show how to use
com.eveningoutpost.dexdrip.UtilityModels.Notifications#persistentHighAlert() .
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: BgReading.java From xDrip with GNU General Public License v3.0 | 4 votes |
public static boolean checkForPersistentHigh() { // skip if not enabled if (!Pref.getBooleanDefaultFalse("persistent_high_alert_enabled")) return false; List<BgReading> last = BgReading.latest(1); if ((last != null) && (last.size()>0)) { final long now = JoH.tsl(); final long since = now - last.get(0).timestamp; // only process if last reading <10 mins if (since < 600000) { // check if exceeding high if (last.get(0).calculated_value > Home.convertToMgDlIfMmol( JoH.tolerantParseDouble(Pref.getString("highValue", "170")))) { final double this_slope = last.get(0).calculated_value_slope * 60000; //Log.d(TAG, "CheckForPersistentHigh: Slope: " + JoH.qs(this_slope)); // if not falling if (this_slope > 0) { final long high_since = Pref.getLong(PERSISTENT_HIGH_SINCE, 0); if (high_since == 0) { // no previous persistent high so set start as now Pref.setLong(PERSISTENT_HIGH_SINCE, now); Log.d(TAG, "Registering start of persistent high at time now"); } else { final long high_for_mins = (now - high_since) / (1000 * 60); long threshold_mins; try { threshold_mins = Long.parseLong(Pref.getString("persistent_high_threshold_mins", "60")); } catch (NumberFormatException e) { threshold_mins = 60; Home.toaststaticnext("Invalid persistent high for longer than minutes setting: using 60 mins instead"); } if (high_for_mins > threshold_mins) { // we have been high for longer than the threshold - raise alert // except if alerts are disabled if (Pref.getLong("alerts_disabled_until", 0) > new Date().getTime()) { Log.i(TAG, "checkforPersistentHigh: Notifications are currently disabled cannot alert!!"); return false; } Log.i(TAG, "Persistent high for: " + high_for_mins + " mins -> alerting"); Notifications.persistentHighAlert(xdrip.getAppContext(), true, xdrip.getAppContext().getString(R.string.persistent_high_for_greater_than) + (int) high_for_mins + xdrip.getAppContext().getString(R.string.space_mins)); } else { Log.d(TAG, "Persistent high below time threshold at: " + high_for_mins); } } } } else { // not high - cancel any existing if (Pref.getLong(PERSISTENT_HIGH_SINCE,0)!=0) { Log.i(TAG,"Cancelling previous persistent high as we are no longer high"); Pref.setLong(PERSISTENT_HIGH_SINCE, 0); // clear it Notifications.persistentHighAlert(xdrip.getAppContext(), false, ""); // cancel it } } } } return false; // actually we should probably return void as we do everything inside this method }
Example 2
Source File: PersistentHigh.java From xDrip with GNU General Public License v3.0 | 4 votes |
public static boolean checkForPersistentHigh() { // skip if not enabled if (!Pref.getBooleanDefaultFalse("persistent_high_alert_enabled")) return false; final List<BgReading> last = BgReading.latest(1); if ((last != null) && (last.size() > 0)) { final double highMarkMgDl = Home.convertToMgDlIfMmol( JoH.tolerantParseDouble(Pref.getString("highValue", "170"), 170d)); final long now = JoH.tsl(); final long since = now - last.get(0).timestamp; // only process if last reading <10 mins if (since < MINUTE_IN_MS * 10) { // check if exceeding high if (last.get(0).getDg_mgdl() > highMarkMgDl) { final double this_slope = last.get(0).getDg_slope() * MINUTE_IN_MS; Log.d(TAG, "CheckForPersistentHigh: Slope: " + JoH.qs(this_slope)+ " "+JoH.dateTimeText(last.get(0).timestamp)); // if not falling if (this_slope > 0 && !last.get(0).hide_slope) { final long high_since = Pref.getLong(PERSISTENT_HIGH_SINCE, 0); if (high_since == 0) { // no previous persistent high so set start as now Pref.setLong(PERSISTENT_HIGH_SINCE, now); Log.d(TAG, "Registering start of persistent high at time now"); } else { final long high_for_mins = (now - high_since) / MINUTE_IN_MS; long threshold_mins; try { threshold_mins = Long.parseLong(Pref.getString("persistent_high_threshold_mins", "60")); } catch (NumberFormatException e) { threshold_mins = 60; Home.toaststaticnext("Invalid persistent high for longer than minutes setting: using 60 mins instead"); } if (high_for_mins > threshold_mins) { // we have been high for longer than the threshold - raise alert // except if alerts are disabled if (Pref.getLong("alerts_disabled_until", 0) > new Date().getTime()) { Log.i(TAG, "checkforPersistentHigh: Notifications are currently disabled cannot alert!!"); return false; } if (!dataQualityCheck(high_since, highMarkMgDl)) { Log.d(TAG, "Insufficient data quality to raise persistent high alert"); return false; } Log.i(TAG, "Persistent high for: " + high_for_mins + " mins -> alerting"); Notifications.persistentHighAlert(xdrip.getAppContext(), true, xdrip.getAppContext().getString(R.string.persistent_high_for_greater_than) + (int) high_for_mins + xdrip.getAppContext().getString(R.string.space_mins)); return true; } else { Log.d(TAG, "Persistent high below time threshold at: " + high_for_mins); } } } } else { // not high - cancel any existing if (Pref.getLong(PERSISTENT_HIGH_SINCE, 0) != 0) { Log.i(TAG, "Cancelling previous persistent high as we are no longer high"); Pref.setLong(PERSISTENT_HIGH_SINCE, 0); // clear it Notifications.persistentHighAlert(xdrip.getAppContext(), false, ""); // cancel it } } } } return false; // actually we should probably return void as we do everything inside this method }
Example 3
Source File: BgReading.java From xDrip with GNU General Public License v3.0 | 4 votes |
public static boolean checkForPersistentHigh() { // skip if not enabled if (!Pref.getBooleanDefaultFalse("persistent_high_alert_enabled")) return false; List<BgReading> last = BgReading.latest(1); if ((last != null) && (last.size()>0)) { final long now = JoH.tsl(); final long since = now - last.get(0).timestamp; // only process if last reading <10 mins if (since < 600000) { // check if exceeding high if (last.get(0).calculated_value > Home.convertToMgDlIfMmol( JoH.tolerantParseDouble(Pref.getString("highValue", "170")))) { final double this_slope = last.get(0).calculated_value_slope * 60000; //Log.d(TAG, "CheckForPersistentHigh: Slope: " + JoH.qs(this_slope)); // if not falling if (this_slope > 0) { final long high_since = Pref.getLong(PERSISTENT_HIGH_SINCE, 0); if (high_since == 0) { // no previous persistent high so set start as now Pref.setLong(PERSISTENT_HIGH_SINCE, now); Log.d(TAG, "Registering start of persistent high at time now"); } else { final long high_for_mins = (now - high_since) / (1000 * 60); long threshold_mins; try { threshold_mins = Long.parseLong(Pref.getString("persistent_high_threshold_mins", "60")); } catch (NumberFormatException e) { threshold_mins = 60; Home.toaststaticnext("Invalid persistent high for longer than minutes setting: using 60 mins instead"); } if (high_for_mins > threshold_mins) { // we have been high for longer than the threshold - raise alert // except if alerts are disabled if (Pref.getLong("alerts_disabled_until", 0) > new Date().getTime()) { Log.i(TAG, "checkforPersistentHigh: Notifications are currently disabled cannot alert!!"); return false; } Log.i(TAG, "Persistent high for: " + high_for_mins + " mins -> alerting"); Notifications.persistentHighAlert(xdrip.getAppContext(), true, xdrip.getAppContext().getString(R.string.persistent_high_for_greater_than) + (int) high_for_mins + xdrip.getAppContext().getString(R.string.space_mins)); } else { Log.d(TAG, "Persistent high below time threshold at: " + high_for_mins); } } } } else { // not high - cancel any existing if (Pref.getLong(PERSISTENT_HIGH_SINCE,0)!=0) { Log.i(TAG,"Cancelling previous persistent high as we are no longer high"); Pref.setLong(PERSISTENT_HIGH_SINCE, 0); // clear it Notifications.persistentHighAlert(xdrip.getAppContext(), false, ""); // cancel it } } } } return false; // actually we should probably return void as we do everything inside this method }
Example 4
Source File: PersistentHigh.java From xDrip with GNU General Public License v3.0 | 4 votes |
public static boolean checkForPersistentHigh() { // skip if not enabled if (!Pref.getBooleanDefaultFalse("persistent_high_alert_enabled")) return false; final List<BgReading> last = BgReading.latest(1); if ((last != null) && (last.size() > 0)) { final double highMarkMgDl = Home.convertToMgDlIfMmol( JoH.tolerantParseDouble(Pref.getString("highValue", "170"), 170d)); final long now = JoH.tsl(); final long since = now - last.get(0).timestamp; // only process if last reading <10 mins if (since < MINUTE_IN_MS * 10) { // check if exceeding high if (last.get(0).getDg_mgdl() > highMarkMgDl) { final double this_slope = last.get(0).getDg_slope() * MINUTE_IN_MS; Log.d(TAG, "CheckForPersistentHigh: Slope: " + JoH.qs(this_slope)+ " "+JoH.dateTimeText(last.get(0).timestamp)); // if not falling if (this_slope > 0 && !last.get(0).hide_slope) { final long high_since = Pref.getLong(PERSISTENT_HIGH_SINCE, 0); if (high_since == 0) { // no previous persistent high so set start as now Pref.setLong(PERSISTENT_HIGH_SINCE, now); Log.d(TAG, "Registering start of persistent high at time now"); } else { final long high_for_mins = (now - high_since) / MINUTE_IN_MS; long threshold_mins; try { threshold_mins = Long.parseLong(Pref.getString("persistent_high_threshold_mins", "60")); } catch (NumberFormatException e) { threshold_mins = 60; Home.toaststaticnext("Invalid persistent high for longer than minutes setting: using 60 mins instead"); } if (high_for_mins > threshold_mins) { // we have been high for longer than the threshold - raise alert // except if alerts are disabled if (Pref.getLong("alerts_disabled_until", 0) > new Date().getTime()) { Log.i(TAG, "checkforPersistentHigh: Notifications are currently disabled cannot alert!!"); return false; } if (!dataQualityCheck(high_since, highMarkMgDl)) { Log.d(TAG, "Insufficient data quality to raise persistent high alert"); return false; } Log.i(TAG, "Persistent high for: " + high_for_mins + " mins -> alerting"); Notifications.persistentHighAlert(xdrip.getAppContext(), true, xdrip.getAppContext().getString(R.string.persistent_high_for_greater_than) + (int) high_for_mins + xdrip.getAppContext().getString(R.string.space_mins)); return true; } else { Log.d(TAG, "Persistent high below time threshold at: " + high_for_mins); } } } } else { // not high - cancel any existing if (Pref.getLong(PERSISTENT_HIGH_SINCE, 0) != 0) { Log.i(TAG, "Cancelling previous persistent high as we are no longer high"); Pref.setLong(PERSISTENT_HIGH_SINCE, 0); // clear it Notifications.persistentHighAlert(xdrip.getAppContext(), false, ""); // cancel it } } } } return false; // actually we should probably return void as we do everything inside this method }
Example 5
Source File: BgReading.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public static boolean checkForPersistentHigh() { // skip if not enabled if (!Pref.getBooleanDefaultFalse("persistent_high_alert_enabled")) return false; List<BgReading> last = BgReading.latest(1); if ((last != null) && (last.size()>0)) { final long now = JoH.tsl(); final long since = now - last.get(0).timestamp; // only process if last reading <10 mins if (since < 600000) { // check if exceeding high if (last.get(0).calculated_value > Home.convertToMgDlIfMmol( JoH.tolerantParseDouble(Pref.getString("highValue", "170")))) { final double this_slope = last.get(0).calculated_value_slope * 60000; //Log.d(TAG, "CheckForPersistentHigh: Slope: " + JoH.qs(this_slope)); // if not falling if (this_slope > 0) { final long high_since = Pref.getLong(PERSISTENT_HIGH_SINCE, 0); if (high_since == 0) { // no previous persistent high so set start as now Pref.setLong(PERSISTENT_HIGH_SINCE, now); Log.d(TAG, "Registering start of persistent high at time now"); } else { final long high_for_mins = (now - high_since) / (1000 * 60); long threshold_mins; try { threshold_mins = Long.parseLong(Pref.getString("persistent_high_threshold_mins", "60")); } catch (NumberFormatException e) { threshold_mins = 60; Home.toaststaticnext("Invalid persistent high for longer than minutes setting: using 60 mins instead"); } if (high_for_mins > threshold_mins) { // we have been high for longer than the threshold - raise alert // except if alerts are disabled if (Pref.getLong("alerts_disabled_until", 0) > new Date().getTime()) { Log.i(TAG, "checkforPersistentHigh: Notifications are currently disabled cannot alert!!"); return false; } Log.i(TAG, "Persistent high for: " + high_for_mins + " mins -> alerting"); Notifications.persistentHighAlert(xdrip.getAppContext(), true, xdrip.getAppContext().getString(R.string.persistent_high_for_greater_than) + (int) high_for_mins + xdrip.getAppContext().getString(R.string.space_mins)); } else { Log.d(TAG, "Persistent high below time threshold at: " + high_for_mins); } } } } else { // not high - cancel any existing if (Pref.getLong(PERSISTENT_HIGH_SINCE,0)!=0) { Log.i(TAG,"Cancelling previous persistent high as we are no longer high"); Pref.setLong(PERSISTENT_HIGH_SINCE, 0); // clear it Notifications.persistentHighAlert(xdrip.getAppContext(), false, ""); // cancel it } } } } return false; // actually we should probably return void as we do everything inside this method }
Example 6
Source File: PersistentHigh.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public static boolean checkForPersistentHigh() { // skip if not enabled if (!Pref.getBooleanDefaultFalse("persistent_high_alert_enabled")) return false; final List<BgReading> last = BgReading.latest(1); if ((last != null) && (last.size() > 0)) { final double highMarkMgDl = Home.convertToMgDlIfMmol( JoH.tolerantParseDouble(Pref.getString("highValue", "170"), 170d)); final long now = JoH.tsl(); final long since = now - last.get(0).timestamp; // only process if last reading <10 mins if (since < MINUTE_IN_MS * 10) { // check if exceeding high if (last.get(0).getDg_mgdl() > highMarkMgDl) { final double this_slope = last.get(0).getDg_slope() * MINUTE_IN_MS; Log.d(TAG, "CheckForPersistentHigh: Slope: " + JoH.qs(this_slope)+ " "+JoH.dateTimeText(last.get(0).timestamp)); // if not falling if (this_slope > 0 && !last.get(0).hide_slope) { final long high_since = Pref.getLong(PERSISTENT_HIGH_SINCE, 0); if (high_since == 0) { // no previous persistent high so set start as now Pref.setLong(PERSISTENT_HIGH_SINCE, now); Log.d(TAG, "Registering start of persistent high at time now"); } else { final long high_for_mins = (now - high_since) / MINUTE_IN_MS; long threshold_mins; try { threshold_mins = Long.parseLong(Pref.getString("persistent_high_threshold_mins", "60")); } catch (NumberFormatException e) { threshold_mins = 60; Home.toaststaticnext("Invalid persistent high for longer than minutes setting: using 60 mins instead"); } if (high_for_mins > threshold_mins) { // we have been high for longer than the threshold - raise alert // except if alerts are disabled if (Pref.getLong("alerts_disabled_until", 0) > new Date().getTime()) { Log.i(TAG, "checkforPersistentHigh: Notifications are currently disabled cannot alert!!"); return false; } if (!dataQualityCheck(high_since, highMarkMgDl)) { Log.d(TAG, "Insufficient data quality to raise persistent high alert"); return false; } Log.i(TAG, "Persistent high for: " + high_for_mins + " mins -> alerting"); Notifications.persistentHighAlert(xdrip.getAppContext(), true, xdrip.getAppContext().getString(R.string.persistent_high_for_greater_than) + (int) high_for_mins + xdrip.getAppContext().getString(R.string.space_mins)); return true; } else { Log.d(TAG, "Persistent high below time threshold at: " + high_for_mins); } } } } else { // not high - cancel any existing if (Pref.getLong(PERSISTENT_HIGH_SINCE, 0) != 0) { Log.i(TAG, "Cancelling previous persistent high as we are no longer high"); Pref.setLong(PERSISTENT_HIGH_SINCE, 0); // clear it Notifications.persistentHighAlert(xdrip.getAppContext(), false, ""); // cancel it } } } } return false; // actually we should probably return void as we do everything inside this method }
Example 7
Source File: BgReading.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public static boolean checkForPersistentHigh() { // skip if not enabled if (!Pref.getBooleanDefaultFalse("persistent_high_alert_enabled")) return false; List<BgReading> last = BgReading.latest(1); if ((last != null) && (last.size()>0)) { final long now = JoH.tsl(); final long since = now - last.get(0).timestamp; // only process if last reading <10 mins if (since < 600000) { // check if exceeding high if (last.get(0).calculated_value > Home.convertToMgDlIfMmol( JoH.tolerantParseDouble(Pref.getString("highValue", "170")))) { final double this_slope = last.get(0).calculated_value_slope * 60000; //Log.d(TAG, "CheckForPersistentHigh: Slope: " + JoH.qs(this_slope)); // if not falling if (this_slope > 0) { final long high_since = Pref.getLong(PERSISTENT_HIGH_SINCE, 0); if (high_since == 0) { // no previous persistent high so set start as now Pref.setLong(PERSISTENT_HIGH_SINCE, now); Log.d(TAG, "Registering start of persistent high at time now"); } else { final long high_for_mins = (now - high_since) / (1000 * 60); long threshold_mins; try { threshold_mins = Long.parseLong(Pref.getString("persistent_high_threshold_mins", "60")); } catch (NumberFormatException e) { threshold_mins = 60; Home.toaststaticnext("Invalid persistent high for longer than minutes setting: using 60 mins instead"); } if (high_for_mins > threshold_mins) { // we have been high for longer than the threshold - raise alert // except if alerts are disabled if (Pref.getLong("alerts_disabled_until", 0) > new Date().getTime()) { Log.i(TAG, "checkforPersistentHigh: Notifications are currently disabled cannot alert!!"); return false; } Log.i(TAG, "Persistent high for: " + high_for_mins + " mins -> alerting"); Notifications.persistentHighAlert(xdrip.getAppContext(), true, xdrip.getAppContext().getString(R.string.persistent_high_for_greater_than) + (int) high_for_mins + xdrip.getAppContext().getString(R.string.space_mins)); } else { Log.d(TAG, "Persistent high below time threshold at: " + high_for_mins); } } } } else { // not high - cancel any existing if (Pref.getLong(PERSISTENT_HIGH_SINCE,0)!=0) { Log.i(TAG,"Cancelling previous persistent high as we are no longer high"); Pref.setLong(PERSISTENT_HIGH_SINCE, 0); // clear it Notifications.persistentHighAlert(xdrip.getAppContext(), false, ""); // cancel it } } } } return false; // actually we should probably return void as we do everything inside this method }
Example 8
Source File: PersistentHigh.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public static boolean checkForPersistentHigh() { // skip if not enabled if (!Pref.getBooleanDefaultFalse("persistent_high_alert_enabled")) return false; final List<BgReading> last = BgReading.latest(1); if ((last != null) && (last.size() > 0)) { final double highMarkMgDl = Home.convertToMgDlIfMmol( JoH.tolerantParseDouble(Pref.getString("highValue", "170"), 170d)); final long now = JoH.tsl(); final long since = now - last.get(0).timestamp; // only process if last reading <10 mins if (since < MINUTE_IN_MS * 10) { // check if exceeding high if (last.get(0).getDg_mgdl() > highMarkMgDl) { final double this_slope = last.get(0).getDg_slope() * MINUTE_IN_MS; Log.d(TAG, "CheckForPersistentHigh: Slope: " + JoH.qs(this_slope)+ " "+JoH.dateTimeText(last.get(0).timestamp)); // if not falling if (this_slope > 0 && !last.get(0).hide_slope) { final long high_since = Pref.getLong(PERSISTENT_HIGH_SINCE, 0); if (high_since == 0) { // no previous persistent high so set start as now Pref.setLong(PERSISTENT_HIGH_SINCE, now); Log.d(TAG, "Registering start of persistent high at time now"); } else { final long high_for_mins = (now - high_since) / MINUTE_IN_MS; long threshold_mins; try { threshold_mins = Long.parseLong(Pref.getString("persistent_high_threshold_mins", "60")); } catch (NumberFormatException e) { threshold_mins = 60; Home.toaststaticnext("Invalid persistent high for longer than minutes setting: using 60 mins instead"); } if (high_for_mins > threshold_mins) { // we have been high for longer than the threshold - raise alert // except if alerts are disabled if (Pref.getLong("alerts_disabled_until", 0) > new Date().getTime()) { Log.i(TAG, "checkforPersistentHigh: Notifications are currently disabled cannot alert!!"); return false; } if (!dataQualityCheck(high_since, highMarkMgDl)) { Log.d(TAG, "Insufficient data quality to raise persistent high alert"); return false; } Log.i(TAG, "Persistent high for: " + high_for_mins + " mins -> alerting"); Notifications.persistentHighAlert(xdrip.getAppContext(), true, xdrip.getAppContext().getString(R.string.persistent_high_for_greater_than) + (int) high_for_mins + xdrip.getAppContext().getString(R.string.space_mins)); return true; } else { Log.d(TAG, "Persistent high below time threshold at: " + high_for_mins); } } } } else { // not high - cancel any existing if (Pref.getLong(PERSISTENT_HIGH_SINCE, 0) != 0) { Log.i(TAG, "Cancelling previous persistent high as we are no longer high"); Pref.setLong(PERSISTENT_HIGH_SINCE, 0); // clear it Notifications.persistentHighAlert(xdrip.getAppContext(), false, ""); // cancel it } } } } return false; // actually we should probably return void as we do everything inside this method }