Java Code Examples for com.eveningoutpost.dexdrip.Models.ActiveBgAlert#alertTypegetOnly()

The following examples show how to use com.eveningoutpost.dexdrip.Models.ActiveBgAlert#alertTypegetOnly() . 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: AlertPlayer.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public synchronized void Snooze(Context ctx, int repeatTime, boolean from_interactive) {
    Log.i(TAG, "Snooze called repeatTime = " + repeatTime);
    stopAlert(ctx, false, false);
    ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
    if (activeBgAlert == null) {
        Log.e(TAG, "Error, snooze was called but no alert is active.");
        //KS TODO if (from_interactive) GcmActivity.sendSnoozeToRemote();
        return;
    }
    if (repeatTime == -1) {
        // try to work out default
        AlertType alert = ActiveBgAlert.alertTypegetOnly();
        if (alert != null) {
            repeatTime = alert.default_snooze;
            Log.d(TAG, "Selecting default snooze time: " + repeatTime);
        } else {
            repeatTime = 30; // pick a number if we cannot even find the default
            Log.e(TAG, "Cannot even find default snooze time so going with: " + repeatTime);
        }
    }
    activeBgAlert.snooze(repeatTime);
    //KS if (from_interactive) GcmActivity.sendSnoozeToRemote();
}
 
Example 2
Source File: AlertPlayer.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public synchronized void Snooze(Context ctx, int repeatTime, boolean from_interactive) {
    Log.i(TAG, "Snooze called repeatTime = " + repeatTime);
    stopAlert(ctx, false, false);
    ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
    if (activeBgAlert == null) {
        Log.e(TAG, "Error, snooze was called but no alert is active.");
        if (from_interactive) GcmActivity.sendSnoozeToRemote();
        return;
    }
    if (repeatTime == -1) {
        // try to work out default
        AlertType alert = ActiveBgAlert.alertTypegetOnly();
        if (alert != null) {
            repeatTime = alert.default_snooze;
            Log.d(TAG, "Selecting default snooze time: " + repeatTime);
        } else {
            repeatTime = 30; // pick a number if we cannot even find the default
            Log.e(TAG, "Cannot even find default snooze time so going with: " + repeatTime);
        }
    }
    activeBgAlert.snooze(repeatTime);
    if (from_interactive) GcmActivity.sendSnoozeToRemote();
}
 
Example 3
Source File: AlertPlayer.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public synchronized void Snooze(Context ctx, int repeatTime, boolean from_interactive) {
    Log.i(TAG, "Snooze called repeatTime = " + repeatTime);
    stopAlert(ctx, false, false);
    ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
    if (activeBgAlert == null) {
        Log.e(TAG, "Error, snooze was called but no alert is active.");
        //KS TODO if (from_interactive) GcmActivity.sendSnoozeToRemote();
        return;
    }
    if (repeatTime == -1) {
        // try to work out default
        AlertType alert = ActiveBgAlert.alertTypegetOnly();
        if (alert != null) {
            repeatTime = alert.default_snooze;
            Log.d(TAG, "Selecting default snooze time: " + repeatTime);
        } else {
            repeatTime = 30; // pick a number if we cannot even find the default
            Log.e(TAG, "Cannot even find default snooze time so going with: " + repeatTime);
        }
    }
    activeBgAlert.snooze(repeatTime);
    //KS if (from_interactive) GcmActivity.sendSnoozeToRemote();
}
 
Example 4
Source File: AlertPlayer.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public synchronized void Snooze(Context ctx, int repeatTime, boolean from_interactive) {
    Log.i(TAG, "Snooze called repeatTime = " + repeatTime);
    stopAlert(ctx, false, false);
    ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
    if (activeBgAlert == null) {
        Log.e(TAG, "Error, snooze was called but no alert is active.");
        if (from_interactive) GcmActivity.sendSnoozeToRemote();
        return;
    }
    if (repeatTime == -1) {
        // try to work out default
        AlertType alert = ActiveBgAlert.alertTypegetOnly();
        if (alert != null) {
            repeatTime = alert.default_snooze;
            Log.d(TAG, "Selecting default snooze time: " + repeatTime);
        } else {
            repeatTime = 30; // pick a number if we cannot even find the default
            Log.e(TAG, "Cannot even find default snooze time so going with: " + repeatTime);
        }
    }
    activeBgAlert.snooze(repeatTime);
    if (from_interactive) GcmActivity.sendSnoozeToRemote();
}
 
Example 5
Source File: SnoozeOnNotificationDismissService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private void snoozeBgAlert() {
    AlertType activeBgAlert = ActiveBgAlert.alertTypegetOnly();

    int snooze = 30;
    if(activeBgAlert != null) {
        if(activeBgAlert.default_snooze != 0) {
            snooze = activeBgAlert.default_snooze;
        } else {
            snooze = SnoozeActivity.getDefaultSnooze(activeBgAlert.above);
        }
    }

    AlertPlayer.getPlayer().Snooze(getApplicationContext(), snooze);
}
 
Example 6
Source File: SnoozeOnNotificationDismissService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private void snoozeBgAlert() {
    AlertType activeBgAlert = ActiveBgAlert.alertTypegetOnly();

    int snooze = 30;
    if(activeBgAlert != null) {
        if(activeBgAlert.default_snooze != 0) {
            snooze = activeBgAlert.default_snooze;
        } else {
            snooze = SnoozeActivity.getDefaultSnooze(activeBgAlert.above);
        }
    }

    AlertPlayer.getPlayer().Snooze(getApplicationContext(), snooze);
}
 
Example 7
Source File: AlertTracker.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static void evaluate() {

        final ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();

        if (activeBgAlert != null) {
            if (!activeBgAlert.is_snoozed) {
                if (JoH.ratelimit("alert-tracker-eval", 10)) {
                    final AlertType type = ActiveBgAlert.alertTypegetOnly(activeBgAlert);
                    if (type != null) {
                        final long since = JoH.msSince(activeBgAlert.alert_started_at);
                        String summary = "";
                        try {
                            summary = "(glucose " + BestGlucose.getDisplayGlucose().humanSummary() + ")";
                        } catch (Exception e) {
                            //
                        }
                        if (!type.above) {
                            EmergencyAssist.checkAndActivate(EmergencyAssist.Reason.DID_NOT_ACKNOWLEDGE_LOW_ALERT,
                                    since, summary);
                        } else {
                            EmergencyAssist.checkAndActivate(EmergencyAssist.Reason.DID_NOT_ACKNOWLEDGE_HIGH_ALERT,
                                    since, summary);
                        }
                    }
                }
            }
        }
    }
 
Example 8
Source File: SnoozeOnNotificationDismissService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void snoozeBgAlert() {
    AlertType activeBgAlert = ActiveBgAlert.alertTypegetOnly();

    int snooze = 30;
    if(activeBgAlert != null) {
        if(activeBgAlert.default_snooze != 0) {
            snooze = activeBgAlert.default_snooze;
        } else {
            snooze = SnoozeActivity.getDefaultSnooze(activeBgAlert.above);
        }
    }

    AlertPlayer.getPlayer().Snooze(getApplicationContext(), snooze);
}
 
Example 9
Source File: SnoozeOnNotificationDismissService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void snoozeBgAlert() {
    AlertType activeBgAlert = ActiveBgAlert.alertTypegetOnly();

    int snooze = 30;
    if(activeBgAlert != null) {
        if(activeBgAlert.default_snooze != 0) {
            snooze = activeBgAlert.default_snooze;
        } else {
            snooze = SnoozeActivity.getDefaultSnooze(activeBgAlert.above);
        }
    }

    AlertPlayer.getPlayer().Snooze(getApplicationContext(), snooze);
}
 
Example 10
Source File: AlertTracker.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static void evaluate() {

        final ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();

        if (activeBgAlert != null) {
            if (!activeBgAlert.is_snoozed) {
                if (JoH.ratelimit("alert-tracker-eval", 10)) {
                    final AlertType type = ActiveBgAlert.alertTypegetOnly(activeBgAlert);
                    if (type != null) {
                        final long since = JoH.msSince(activeBgAlert.alert_started_at);
                        String summary = "";
                        try {
                            summary = "(glucose " + BestGlucose.getDisplayGlucose().humanSummary() + ")";
                        } catch (Exception e) {
                            //
                        }
                        if (!type.above) {
                            EmergencyAssist.checkAndActivate(EmergencyAssist.Reason.DID_NOT_ACKNOWLEDGE_LOW_ALERT,
                                    since, summary);
                        } else {
                            EmergencyAssist.checkAndActivate(EmergencyAssist.Reason.DID_NOT_ACKNOWLEDGE_HIGH_ALERT,
                                    since, summary);
                        }
                    }
                }
            }
        }
    }
 
Example 11
Source File: SnoozeOnNotificationDismissService.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
private void snoozeBgAlert() {
    AlertType activeBgAlert = ActiveBgAlert.alertTypegetOnly();

    int snooze = 30;
    if(activeBgAlert != null) {
        if(activeBgAlert.default_snooze != 0) {
            snooze = activeBgAlert.default_snooze;
        } else {
            snooze = SnoozeActivity.getDefaultSnooze(activeBgAlert.above);
        }
    }

    AlertPlayer.getPlayer().Snooze(getApplicationContext(), snooze);
}