public static void rescheduleTask(Task task, long newDueDate) {
    long hideUntil = task.getValue(Task.HIDE_UNTIL);
    if (hideUntil > 0 && task.getValue(Task.DUE_DATE) > 0) {
      hideUntil += newDueDate - task.getValue(Task.DUE_DATE);
    }

    task.setValue(Task.COMPLETION_DATE, 0L);
    task.setValue(Task.DUE_DATE, newDueDate);
    task.setValue(Task.HIDE_UNTIL, hideUntil);
    task.putTransitory(TaskService.TRANS_REPEAT_COMPLETE, true);

    ContentResolver cr = ContextManager.getContext().getContentResolver();
    GCalHelper.rescheduleRepeatingTask(task, cr);
    PluginServices.getTaskService().save(task);
  }
  public static void rescheduleTask(
      Context context, GCalHelper gcalHelper, TaskService taskService, Task task, long newDueDate) {
    long hideUntil = task.getHideUntil();
    if (hideUntil > 0 && task.getDueDate() > 0) {
      hideUntil += newDueDate - task.getDueDate();
    }

    task.setReminderSnooze(0L);
    task.setCompletionDate(0L);
    task.setDueDate(newDueDate);
    task.setHideUntil(hideUntil);
    task.putTransitory(TaskService.TRANS_REPEAT_COMPLETE, true);

    ContentResolver cr = context.getContentResolver();
    gcalHelper.rescheduleRepeatingTask(task, cr);
    taskService.save(task);
  }
Exemple #3
0
  public void delete(Task item) {
    if (!item.isSaved()) {
      return;
    }

    if (item.containsValue(Task.TITLE) && item.getTitle().length() == 0) {
      taskDao.delete(item.getId());
      item.setId(Task.NO_ID);
    } else {
      long id = item.getId();
      item.clear();
      item.setId(id);
      gcalHelper.deleteTaskEvent(item);
      item.setDeletionDate(DateUtilities.now());
      taskService.save(item);
    }
  }