Пример #1
0
  /**
   * Delete the given item
   *
   * @param database
   * @param id
   * @return true if delete was successful
   */
  @Override
  public boolean delete(long id) {
    boolean result = super.delete(id);
    if (!result) return false;

    // delete all metadata
    metadataDao.deleteWhere(MetadataCriteria.byTask(id));

    TaskApiDao.afterTaskListChanged();

    return true;
  }
Пример #2
0
 @Override
 public boolean saveExisting(Task item) {
   ContentValues values = item.getSetValues();
   if (values == null || values.size() == 0) return false;
   if (!TaskApiDao.insignificantChange(values)) {
     item.setValue(Task.DETAILS, null);
     if (!values.containsKey(Task.MODIFICATION_DATE.name))
       item.setValue(Task.MODIFICATION_DATE, DateUtilities.now());
   }
   boolean result = super.saveExisting(item);
   if (result) afterSave(item, values);
   return result;
 }
Пример #3
0
  /**
   * Called after the task is saved. This differs from the call in TaskApiDao in that it runs hooks
   * that need to be run from within Astrid. Order matters here!
   */
  public static void afterSave(Task task, ContentValues values) {
    if (values == null) return;

    task.markSaved();
    if (values.containsKey(Task.COMPLETION_DATE.name) && task.isCompleted())
      afterComplete(task, values);
    else {
      if (values.containsKey(Task.DUE_DATE.name)
          || values.containsKey(Task.REMINDER_FLAGS.name)
          || values.containsKey(Task.REMINDER_PERIOD.name)
          || values.containsKey(Task.REMINDER_LAST.name)
          || values.containsKey(Task.REMINDER_SNOOZE.name))
        ReminderService.getInstance().scheduleAlarm(task);
    }

    // run api save hooks
    TaskApiDao.afterSave(task, values);
  }