use of com.evernote.edam.notestore.NoteMetadata in project Notes by lguipeng.
the class EverNoteUtils method pullNotes.
public void pullNotes() throws Exception {
NotesLog.d("");
NoteFilter noteFilter = new NoteFilter();
noteFilter.setOrder(NoteSortOrder.UPDATED.getValue());
String guid = mPreferenceUtils.getStringParam(PreferenceUtils.EVERNOTE_NOTEBOOK_GUID_KEY);
noteFilter.setNotebookGuid(guid);
NotesMetadataResultSpec spec = new NotesMetadataResultSpec();
spec.setIncludeUpdated(true);
spec.setIncludeCreated(true);
NoteCollectionCounts counts = mEvernoteSession.getEvernoteClientFactory().getNoteStoreClient().findNoteCounts(noteFilter, false);
List<SNote> sNoteList = mFinalDb.findAllByWhere(SNote.class, "type != " + SNote.NoteType.TRASH.getValue());
List<String> guids = new ArrayList<>();
for (SNote note : sNoteList) {
guids.add(note.getGuid());
}
if (counts == null || counts.getNotebookCounts() == null) {
for (String deleteGuid : guids) {
deleteLocalNote(deleteGuid);
}
return;
}
int maxCount = counts.getNotebookCounts().get(guid);
NotesMetadataList list = mEvernoteSession.getEvernoteClientFactory().getNoteStoreClient().findNotesMetadata(noteFilter, 0, maxCount, spec);
for (NoteMetadata data : list.getNotes()) {
guids.remove(data.getGuid());
List<SNote> sNotes = mFinalDb.findAllByWhere(SNote.class, "guid = '" + data.getGuid() + "'");
if (sNotes != null && sNotes.size() > 0) {
//update
SNote sNote = sNotes.get(0);
if (data.getUpdated() > sNote.getLastOprTime())
pullUpdateNote(sNote);
} else {
//pull
loadEverNote(data.getGuid());
}
}
if (guids.size() > 0) {
for (String deleteGuid : guids) {
deleteLocalNote(deleteGuid);
}
}
NotesLog.d("");
}
Aggregations