Beispiel #1
0
 /** Get a cursor to tag identifiers */
 public Cursor getTaskAlertsCursor(TaskIdentifier taskId) throws SQLException {
   Cursor cursor =
       alertDatabase.query(
           alertsTable,
           Alert.FIELD_LIST,
           Alert.TASK + " = ?",
           new String[] {taskId.idAsString()},
           null,
           null,
           null);
   return cursor;
 }
Beispiel #2
0
  /** Get a list of alerts for the given task */
  public List<Date> getTaskAlerts(TaskIdentifier taskId) throws SQLException {
    List<Date> list = new LinkedList<Date>();
    Cursor cursor =
        alertDatabase.query(
            alertsTable,
            Alert.FIELD_LIST,
            Alert.TASK + " = ?",
            new String[] {taskId.idAsString()},
            null,
            null,
            null);

    try {
      if (cursor.getCount() == 0) return list;
      do {
        cursor.moveToNext();
        list.add(new Alert(cursor).getDate());
      } while (!cursor.isLast());

      return list;
    } finally {
      cursor.close();
    }
  }
Beispiel #3
0
 /** Add the given tag to the task */
 public boolean addAlert(TaskIdentifier taskId, Date date) throws SQLException {
   ContentValues values = new ContentValues();
   values.put(Alert.DATE, date.getTime());
   values.put(Alert.TASK, taskId.getId());
   return alertDatabase.insert(alertsTable, Alert.TASK, values) >= 0;
 }
Beispiel #4
0
 /** Remove all alerts from the task */
 public boolean removeAlerts(TaskIdentifier taskId) throws SQLException {
   return alertDatabase.delete(
           alertsTable, String.format("%s = ?", Alert.TASK), new String[] {taskId.idAsString()})
       > 0;
 }