Java Code Examples for com.eveningoutpost.dexdrip.Models.AlertType#toTime()

The following examples show how to use com.eveningoutpost.dexdrip.Models.AlertType#toTime() . 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: EditAlertActivity.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public void testAlert() {
    // Check that values are ok.
    double threshold = parseDouble(alertThreshold.getText().toString());
    if(Double.isNaN(threshold))
        return;

    threshold = unitsConvertFromDisp(threshold);

    int timeStart = AlertType.toTime(startHour, startMinute);
    int timeEnd = AlertType.toTime(endHour, endMinute);

    boolean allDay = checkboxAllDay.isChecked();
    // if 23:59 was set, we increase it to 24:00
    if(timeStart == AlertType.toTime(23, 59)) {
        timeStart++;
    }
    if(timeEnd == AlertType.toTime(23, 59)) {
        timeEnd++;
    }
    if(timeStart == AlertType.toTime(0, 0) &&
            timeEnd == AlertType.toTime(24, 0)) {
        allDay = true;
    }
    if (timeStart == timeEnd && (allDay==false)) {
        Toast.makeText(getApplicationContext(), "start time and end time of alert can not be equal",Toast.LENGTH_LONG).show();
        return;
    }
    if(!verifyThreshold(threshold, allDay, timeStart, timeEnd)) {
        return;
    }
    boolean vibrate = checkboxVibrate.isChecked();
    boolean overrideSilentMode = checkboxAlertOverride.isChecked();
    String mp3_file = audioPath;
    int defaultSnooze = parseInt(editSnooze.getText().toString());
    AlertType.testAlert(alertText.getText().toString(), above, threshold, allDay, 1, mp3_file, timeStart, timeEnd, overrideSilentMode, defaultSnooze, vibrate, mContext);

}
 
Example 2
Source File: EditAlertActivity.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public void testAlert() {
    // Check that values are ok.
    double threshold = parseDouble(alertThreshold.getText().toString());
    if(Double.isNaN(threshold)) {
      JoH.static_toast_long("Threshold number is not valid");
        return;
    }

    threshold = unitsConvertFromDisp(threshold);

    int timeStart = AlertType.toTime(startHour, startMinute);
    int timeEnd = AlertType.toTime(endHour, endMinute);

    boolean allDay = checkboxAllDay.isChecked();
    // if 23:59 was set, we increase it to 24:00
    if(timeStart == AlertType.toTime(23, 59)) {
        timeStart++;
    }
    if(timeEnd == AlertType.toTime(23, 59)) {
        timeEnd++;
    }
    if(timeStart == AlertType.toTime(0, 0) &&
            timeEnd == AlertType.toTime(24, 0)) {
        allDay = true;
    }
    if (timeStart == timeEnd && (!allDay)) {
        Toast.makeText(getApplicationContext(), "start time and end time of alert can not be equal",Toast.LENGTH_LONG).show();
        return;
    }
    if(!verifyThreshold(threshold, allDay, timeStart, timeEnd)) {
        return;
    }
    boolean vibrate = checkboxVibrate.isChecked();
    boolean overrideSilentMode = checkboxOverrideSilent.isChecked();
    boolean forceSpeaker = checkboxForceSpeaker.isChecked();
    String mp3_file = audioPath;
    try {
        int defaultSnooze = safeGetDefaultSnooze();

        if (Pref.getBooleanDefaultFalse("start_snoozed"))  {
            JoH.static_toast_long("Start Snoozed setting means alert would normally start silent");
        } else if (Pref.getStringDefaultBlank("bg_alert_profile").equals("ascending")) {
            JoH.static_toast_long("Ascending Volume Profile means it will start silent");
        } else if (Pref.getStringDefaultBlank("bg_alert_profile").equals("Silent")) {
            JoH.static_toast_long("Volume Profile is set to silent!");
        }

        AlertType.testAlert(alertText.getText().toString(), above, threshold, allDay, 1, mp3_file, timeStart, timeEnd, overrideSilentMode, forceSpeaker, defaultSnooze, vibrate, mContext);
    } catch (NullPointerException e) {
        JoH.static_toast_long("Snooze value is not a number - cannot test");
    }
}
 
Example 3
Source File: EditAlertActivity.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public void testAlert() {
    // Check that values are ok.
    double threshold = parseDouble(alertThreshold.getText().toString());
    if(Double.isNaN(threshold)) {
      JoH.static_toast_long("Threshold number is not valid");
        return;
    }

    threshold = unitsConvertFromDisp(threshold);

    int timeStart = AlertType.toTime(startHour, startMinute);
    int timeEnd = AlertType.toTime(endHour, endMinute);

    boolean allDay = checkboxAllDay.isChecked();
    // if 23:59 was set, we increase it to 24:00
    if(timeStart == AlertType.toTime(23, 59)) {
        timeStart++;
    }
    if(timeEnd == AlertType.toTime(23, 59)) {
        timeEnd++;
    }
    if(timeStart == AlertType.toTime(0, 0) &&
            timeEnd == AlertType.toTime(24, 0)) {
        allDay = true;
    }
    if (timeStart == timeEnd && (!allDay)) {
        Toast.makeText(getApplicationContext(), "start time and end time of alert can not be equal",Toast.LENGTH_LONG).show();
        return;
    }
    if(!verifyThreshold(threshold, allDay, timeStart, timeEnd)) {
        return;
    }
    boolean vibrate = checkboxVibrate.isChecked();
    boolean overrideSilentMode = checkboxOverrideSilent.isChecked();
    boolean forceSpeaker = checkboxForceSpeaker.isChecked();
    String mp3_file = audioPath;
    try {
        int defaultSnooze = safeGetDefaultSnooze();

        if (Pref.getBooleanDefaultFalse("start_snoozed"))  {
            JoH.static_toast_long("Start Snoozed setting means alert would normally start silent");
        } else if (Pref.getStringDefaultBlank("bg_alert_profile").equals("ascending")) {
            JoH.static_toast_long("Ascending Volume Profile means it will start silent");
        } else if (Pref.getStringDefaultBlank("bg_alert_profile").equals("Silent")) {
            JoH.static_toast_long("Volume Profile is set to silent!");
        }

        AlertType.testAlert(alertText.getText().toString(), above, threshold, allDay, 1, mp3_file, timeStart, timeEnd, overrideSilentMode, forceSpeaker, defaultSnooze, vibrate, mContext);
    } catch (NullPointerException e) {
        JoH.static_toast_long("Snooze value is not a number - cannot test");
    }
}