Beispiel #1
0
  public static final ApplyChangesInfo deleteNotes(Context context, Collection<RtmTaskNote> notes) {
    boolean ok = true;
    ContentProviderActionItemList actionItemList = new ContentProviderActionItemList();

    for (Iterator<RtmTaskNote> i = notes.iterator(); ok && i.hasNext(); ) {
      final String noteId = i.next().getId();
      final ModificationSet modifications = new ModificationSet();

      modifications.add(
          Modification.newNonPersistentModification(
              Queries.contentUriWithId(Notes.CONTENT_URI, noteId),
              Notes.NOTE_DELETED,
              System.currentTimeMillis()));
      modifications.add(Modification.newNoteModified(noteId));

      ok =
          actionItemList.add(
              ContentProviderAction.Type.DELETE,
              CreationsProviderPart.deleteCreation(
                  Queries.contentUriWithId(Notes.CONTENT_URI, noteId)));
      actionItemList.add(modifications);
    }

    if (!ok) actionItemList = null;

    return new ApplyChangesInfo(
        actionItemList,
        context.getString(R.string.toast_delete_note),
        context.getString(R.string.toast_delete_note_ok),
        context.getString(R.string.toast_delete_note_failed));
  }
Beispiel #2
0
  public static final ApplyChangesInfo setNoteTitleAndText(
      Context context, String noteId, String title, String text) {
    final ModificationSet modifications = new ModificationSet();

    modifications.add(
        Modification.newModification(
            Queries.contentUriWithId(Notes.CONTENT_URI, noteId), Notes.NOTE_TITLE, title));
    modifications.add(
        Modification.newModification(
            Queries.contentUriWithId(Notes.CONTENT_URI, noteId), Notes.NOTE_TEXT, text));
    modifications.add(Modification.newNoteModified(noteId));

    return new ApplyChangesInfo(
        modifications.toContentProviderActionItemList(),
        context.getString(R.string.toast_save_note),
        context.getString(R.string.toast_save_note_ok),
        context.getString(R.string.toast_save_note_failed));
  }