/* Build a HashMap of task fields and associated values.
  */
 public HashMap<String, String> getTaskAttributes() {
   taskAttributesMap.put(AbstractController.KEY_ROWID, getTaskIdentifier().idAsString());
   taskAttributesMap.put(NAME, getName());
   taskAttributesMap.put(IMPORTANCE, getImportance().toString());
   taskAttributesMap.put(ELAPSED_SECONDS, getElapsedSeconds().toString());
   taskAttributesMap.put(ESTIMATED_SECONDS, getEstimatedSeconds().toString());
   safePutDate(TIMER_START, getTimerStart());
   safePutDate(DEFINITE_DUE_DATE, getDefiniteDueDate());
   safePutDate(PREFERRED_DUE_DATE, getPreferredDueDate());
   taskAttributesMap.put(NOTIFICATIONS, getNotificationIntervalSeconds().toString());
   taskAttributesMap.put(PROGRESS_PERCENTAGE, Integer.toString(getProgressPercentage()));
   safePutDate(COMPLETION_DATE, getCompletionDate());
   safePutDate(CREATION_DATE, getCreationDate());
   safePutDate(HIDDEN_UNTIL, getHiddenUntil());
   taskAttributesMap.put(NOTES, getNotes());
   RepeatInfo repeat = getRepeat();
   if (repeat != null) {
     taskAttributesMap.put(REPEAT_VALUE, Integer.toString(repeat.getValue()));
     taskAttributesMap.put(REPEAT_INTERVAL, repeat.getInterval().toString());
   }
   taskAttributesMap.put(FLAGS, Integer.toString(getFlags()));
   taskAttributesMap.put(POSTPONE_COUNT, getPostponeCount().toString());
   taskAttributesMap.put(BLOCKING_ON, Long.toString(getBlockingOn().getId()));
   safePutDate(LAST_NOTIFIED, getLastNotificationDate());
   taskAttributesMap.put(NOTIFICATION_FLAGS, Integer.toString(getNotificationFlags()));
   String calendarUri = getCalendarUri();
   if (calendarUri != null) {
     taskAttributesMap.put(CALENDAR_URI, calendarUri);
   }
   return taskAttributesMap;
 }
示例#2
0
  /**
   * This method updates the task to reflect a new repeat iteration. It moves back the due dates and
   * updates other task properties accordingly.
   *
   * @param context
   * @param taskController
   * @param repeatInfo
   */
  public void repeatTaskBy(Context context, TaskController taskController, RepeatInfo repeatInfo) {

    // move dates back
    if (getDefiniteDueDate() != null)
      setDefiniteDueDate(repeatInfo.shiftDate(getDefiniteDueDate()));
    if (getHiddenUntil() != null) setHiddenUntil(repeatInfo.shiftDate(getHiddenUntil()));
    if (getPreferredDueDate() != null)
      setPreferredDueDate(repeatInfo.shiftDate(getPreferredDueDate()));
    setProgressPercentage(0);

    // set elapsed time to 0... yes, we're losing data
    setElapsedSeconds(0);

    // if no deadlines set, create one (so users don't get confused)
    if (getDefiniteDueDate() == null && getPreferredDueDate() == null)
      setPreferredDueDate(repeatInfo.shiftDate(new Date()));

    // shift fixed alerts
    AlertController alertController = new AlertController(context);
    alertController.open();
    List<Date> alerts = alertController.getTaskAlerts(getTaskIdentifier());
    alertController.removeAlerts(getTaskIdentifier());
    for (int i = 0; i < alerts.size(); i++) {
      Date newAlert = repeatInfo.shiftDate(alerts.get(i));
      alertController.addAlert(getTaskIdentifier(), newAlert);
      alerts.set(i, newAlert);
    }

    // reset periodic alerts
    setLastNotificationTime(null);
    alertController.close();
  }
示例#3
0
 @Override
 public void write(JsonWriter out, RepeatInfo value) throws IOException {
   out.beginObject();
   out.name(TYPE).value(value.getType().name());
   if (value.getType().isUseTime()) {
     out.name(DAYS).value(value.getDays());
     out.name(HOURS).value(value.getHours());
   }
   out.endObject();
 }