@Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case android.R.id.home:
        {
          finish();
          break;
        }
      case R.id.action_save_alarm_details:
        {
          updateModelFromLayout();

          AlarmManagerHelper.cancelAlarms(this);

          if (alarmDetails.id < 0) {
            dbHelper.createAlarm(alarmDetails);
          } else {
            dbHelper.updateAlarm(alarmDetails);
          }

          AlarmManagerHelper.setAlarms(this);

          setResult(RESULT_OK);
          finish();
        }
    }

    return super.onOptionsItemSelected(item);
  }
Exemplo n.º 2
0
  public void setAlarmEnabled(long id, boolean isEnabled) {
    AlarmManagerHelper.cancelAlarms(this);

    AlarmModel model = dbHelper.getAlarm(id);
    model.isEnabled = isEnabled;
    dbHelper.updateAlarm(model);

    AlarmManagerHelper.setAlarms(this);
  }