use of it.niedermann.owncloud.notes.model.DBNote in project nextcloud-notes by stefan-niedermann.
the class LoadNotesListTask method fillListByCategory.
@NonNull
@WorkerThread
private List<Item> fillListByCategory(@NonNull List<DBNote> noteList) {
List<Item> itemList = new ArrayList<>();
String currentCategory = category.category;
for (DBNote note : noteList) {
if (currentCategory != null && !currentCategory.equals(note.getCategory())) {
itemList.add(new SectionItem(NoteUtil.extendCategory(note.getCategory())));
}
itemList.add(note);
currentCategory = note.getCategory();
}
return itemList;
}
use of it.niedermann.owncloud.notes.model.DBNote in project nextcloud-notes by stefan-niedermann.
the class NoteSQLiteOpenHelper method addNote.
/**
* Inserts a note directly into the Database.
* No Synchronisation will be triggered! Use addNoteAndSync()!
*
* @param note Note to be added. Remotely created Notes must be of type CloudNote and locally created Notes must be of Type DBNote (with DBStatus.LOCAL_EDITED)!
*/
long addNote(CloudNote note) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
if (note instanceof DBNote) {
DBNote dbNote = (DBNote) note;
if (dbNote.getId() > 0) {
values.put(key_id, dbNote.getId());
}
values.put(key_status, dbNote.getStatus().getTitle());
} else {
values.put(key_status, DBStatus.VOID.getTitle());
}
if (note.getRemoteId() > 0) {
values.put(key_remote_id, note.getRemoteId());
}
values.put(key_title, note.getTitle());
values.put(key_modified, note.getModified(NoteSQLiteOpenHelper.DATE_FORMAT));
values.put(key_content, note.getContent());
values.put(key_favorite, note.isFavorite());
values.put(key_category, note.getCategory());
values.put(key_etag, note.getEtag());
return db.insert(table_notes, null, values);
}
use of it.niedermann.owncloud.notes.model.DBNote in project nextcloud-notes by stefan-niedermann.
the class NoteSQLiteOpenHelper method addNoteAndSync.
/**
* Creates a new Note in the Database and adds a Synchronization Flag.
*
* @param note Note
*/
@SuppressWarnings("UnusedReturnValue")
public long addNoteAndSync(CloudNote note) {
DBNote dbNote = new DBNote(0, 0, note.getModified(), note.getTitle(), note.getContent(), note.isFavorite(), note.getCategory(), note.getEtag(), DBStatus.LOCAL_EDITED);
long id = addNote(dbNote);
notifyNotesChanged();
getNoteServerSyncHelper().scheduleSync(true);
return id;
}
Aggregations