Esempio n. 1
0
  @Override
  protected void onHandleIntent(Intent intent) {
    int serviceMode = intent.getIntExtra(SERVICE_MODE, MODE_ALL_REMINDS);
    switch (serviceMode) {
      case MODE_ALL_REMINDS:
        Log.i(TAG, "NotificationService called to update alarm");

        List<Remind> waitingReminds =
            RemindDatabase.getInstance().getStoredData(DatabaseHelper.FILTER_WAITING_REMINDS);
        for (Remind remind : waitingReminds) {
          if (remind.getNotificationMillis() >= System.currentTimeMillis()) {
            setAlarm(remind.getId(), remind.getNotificationMillis(), remind.getTitle());
          }
        }
        break;

      case MODE_ONE_REMIND:
        Log.i(TAG, "NotificationService called to set one alarm");

        int setAlarmId = intent.getIntExtra(DatabaseHelper.COLUMN_ID, 0);
        long alarmMillis = intent.getLongExtra(DatabaseHelper.COLUMN_MILLIS, 0);
        String alarmMessage = intent.getStringExtra(DatabaseHelper.COLUMN_TITLE);
        setAlarm(setAlarmId, alarmMillis, alarmMessage);
        break;

      case MODE_UPDATE_ALARM:
        Log.i(TAG, "NotificationService called to update alarm");

        int updateAlarmId = intent.getIntExtra(DatabaseHelper.COLUMN_ID, 0);
        updateAlarm(updateAlarmId);
        break;
    }
  }
Esempio n. 2
0
  public void remove(Remind item) {
    try {
      remindDao.delete(item);

      Log.i(TAG, String.format("%s: %d", "remove at base, id", item.getId()));
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
Esempio n. 3
0
  public void add(Remind remind) {
    try {
      remindDao.create(remind);

      Log.i(TAG, String.format("%s: %d", "add to base, id", remind.getId()));
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }