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)); }
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)); }
public static final ApplyChangesInfo insertNote(Context context, RtmTaskNote note) { ContentProviderActionItemList actionItemList = new ContentProviderActionItemList(); boolean ok = actionItemList.add( ContentProviderAction.Type.INSERT, RtmNotesProviderPart.insertLocalCreatedNote(note)); ok = ok && actionItemList.add( ContentProviderAction.Type.INSERT, CreationsProviderPart.newCreation( Queries.contentUriWithId(Notes.CONTENT_URI, note.getId()), note.getCreatedDate().getTime())); if (!ok) actionItemList = null; return new ApplyChangesInfo( actionItemList, context.getString(R.string.toast_insert_note), context.getString(R.string.toast_insert_note_ok), context.getString(R.string.toast_insert_note_fail)); }