コード例 #1
0
  public void testCompletedTasksAreCompletedWhenParsed() {
    XmlPullParser xmlParser = Xml.newPullParser();

    try {
      xmlParser.setInput(
          new StringReader(
              "<todo>"
                  + "<completed-at type=\"datetime\" nil=\"true\"/>"
                  + "<context-id type=\"integer\">3711</context-id>"
                  + "<created-at type=\"datetime\">2009-10-26T22:23:42+01:00</created-at>"
                  + "<description>Läs getting things done igen</description>"
                  + "<due type=\"datetime\" nil=\"true\"/>"
                  + "<id type=\"integer\">25076</id>"
                  + "<ip-address>90.232.35.15</ip-address>"
                  + "<notes>Primärt kring idéer och projekt</notes>"
                  + "<project-id type=\"integer\">4558</project-id>"
                  + "<recurring-todo-id type=\"integer\" nil=\"true\"/>"
                  + "<show-from type=\"datetime\" nil=\"true\"/>"
                  + "<state>completed</state>"
                  + "<updated-at type=\"datetime\">2010-02-03T10:37:19+01:00</updated-at>"
                  + "</todo>"));
    } catch (XmlPullParserException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    TaskParser parser = CreateSUT();
    Task task = parser.parseSingle(xmlParser).getResult();
    assertEquals("completed date isn't parsed correctly", true, task.isComplete());
  }
コード例 #2
0
  @Override
  protected void updateUIFromItem(Task task) {
    // If we hadn't previously retrieved the original task, do so
    // now.  This allows the user to revert their changes.
    if (mOriginalItem == null) {
      mOriginalItem = task;
    }

    final String details = task.getDetails();
    mDetailsWidget.setTextKeepState(details == null ? "" : details);

    mDescriptionWidget.setTextKeepState(task.getDescription());

    final Id contextId = task.getContextId();
    if (contextId.isInitialised()) {
      setSpinnerSelection(mContextSpinner, mContextIds, contextId.getId());
    }

    final Id projectId = task.getProjectId();
    if (projectId.isInitialised()) {
      setSpinnerSelection(mProjectSpinner, mProjectIds, projectId.getId());
    }

    boolean allDay = task.isAllDay();
    if (allDay) {
      String tz = mStartTime.timezone;
      mStartTime.timezone = Time.TIMEZONE_UTC;
      mStartTime.set(task.getStartDate());
      mStartTime.timezone = tz;

      // Calling normalize to calculate isDst
      mStartTime.normalize(true);
    } else {
      mStartTime.set(task.getStartDate());
    }

    if (allDay) {
      String tz = mStartTime.timezone;
      mDueTime.timezone = Time.TIMEZONE_UTC;
      mDueTime.set(task.getDueDate());
      mDueTime.timezone = tz;

      // Calling normalize to calculate isDst
      mDueTime.normalize(true);
    } else {
      mDueTime.set(task.getDueDate());
    }

    setWhenDefaults();
    populateWhen();

    // show scheduling section if either start or due date are set
    mSchedulingExpanded = mShowStart || mShowDue;
    setSchedulingVisibility(mSchedulingExpanded);

    mAllDayCheckBox.setChecked(allDay);
    updateTimeVisibility(!allDay);

    mCompletedCheckBox.setChecked(task.isComplete());

    mDeletedEntry.setVisibility(task.isDeleted() ? View.VISIBLE : View.GONE);
    mDeletedCheckBox.setChecked(task.isDeleted());

    updateCalendarPanel();

    // Load reminders (if there are any)
    if (task.hasAlarms()) {
      Uri uri = ReminderProvider.Reminders.CONTENT_URI;
      ContentResolver cr = getContentResolver();
      Cursor reminderCursor =
          cr.query(
              uri,
              ReminderProvider.Reminders.cFullProjection,
              REMINDERS_WHERE,
              new String[] {String.valueOf(task.getLocalId().getId())},
              null);
      try {
        // First pass: collect all the custom reminder minutes (e.g.,
        // a reminder of 8 minutes) into a global list.
        while (reminderCursor.moveToNext()) {
          int minutes = reminderCursor.getInt(ReminderProvider.Reminders.MINUTES_INDEX);
          addMinutesToList(this, mReminderValues, mReminderLabels, minutes);
        }

        // Second pass: create the reminder spinners
        reminderCursor.moveToPosition(-1);
        while (reminderCursor.moveToNext()) {
          int minutes = reminderCursor.getInt(ReminderProvider.Reminders.MINUTES_INDEX);
          mOriginalMinutes.add(minutes);
          addReminder(this, this, mReminderItems, mReminderValues, mReminderLabels, minutes);
        }
      } finally {
        reminderCursor.close();
      }
    }
    updateRemindersVisibility();
  }