Search in sources :

Example 1 with NoteFilter

use of com.evernote.edam.notestore.NoteFilter in project Notes by lguipeng.

the class EvernoteSearchHelper method findNotesInBusinessNotebook.

protected List<NotesMetadataList> findNotesInBusinessNotebook(Search search, LinkedNotebook linkedNotebook) throws Exception {
    EvernoteBusinessNotebookHelper businessNotebookHelper = mClientFactory.getBusinessNotebookHelper();
    EvernoteLinkedNotebookHelper linkedNotebookHelper = mClientFactory.getLinkedNotebookHelper(linkedNotebook);
    Notebook correspondingNotebook = linkedNotebookHelper.getCorrespondingNotebook();
    // create a deep copy so that we don't touch the initial search request values
    NoteFilter noteFilter = new NoteFilter(search.getNoteFilter());
    noteFilter.setNotebookGuid(correspondingNotebook.getGuid());
    return findAllNotes(search, businessNotebookHelper.getClient(), noteFilter);
}
Also used : NoteFilter(com.evernote.edam.notestore.NoteFilter) Notebook(com.evernote.edam.type.Notebook) LinkedNotebook(com.evernote.edam.type.LinkedNotebook)

Example 2 with NoteFilter

use of com.evernote.edam.notestore.NoteFilter in project Notes by lguipeng.

the class EvernoteSearchHelper method findNotesInLinkedNotebook.

protected List<NotesMetadataList> findNotesInLinkedNotebook(Search search, LinkedNotebook linkedNotebook) throws Exception {
    EvernoteLinkedNotebookHelper linkedNotebookHelper = mClientFactory.getLinkedNotebookHelper(linkedNotebook);
    Notebook correspondingNotebook = linkedNotebookHelper.getCorrespondingNotebook();
    // create a deep copy so that we don't touch the initial search request values
    NoteFilter noteFilter = new NoteFilter(search.getNoteFilter());
    noteFilter.setNotebookGuid(correspondingNotebook.getGuid());
    return findAllNotes(search, linkedNotebookHelper.getClient(), noteFilter);
}
Also used : NoteFilter(com.evernote.edam.notestore.NoteFilter) Notebook(com.evernote.edam.type.Notebook) LinkedNotebook(com.evernote.edam.type.LinkedNotebook)

Example 3 with NoteFilter

use of com.evernote.edam.notestore.NoteFilter 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("");
}
Also used : NoteFilter(com.evernote.edam.notestore.NoteFilter) SNote(com.lguipeng.notes.model.SNote) ArrayList(java.util.ArrayList) NotesMetadataList(com.evernote.edam.notestore.NotesMetadataList) NoteMetadata(com.evernote.edam.notestore.NoteMetadata) NoteCollectionCounts(com.evernote.edam.notestore.NoteCollectionCounts) NotesMetadataResultSpec(com.evernote.edam.notestore.NotesMetadataResultSpec)

Aggregations

NoteFilter (com.evernote.edam.notestore.NoteFilter)3 LinkedNotebook (com.evernote.edam.type.LinkedNotebook)2 Notebook (com.evernote.edam.type.Notebook)2 NoteCollectionCounts (com.evernote.edam.notestore.NoteCollectionCounts)1 NoteMetadata (com.evernote.edam.notestore.NoteMetadata)1 NotesMetadataList (com.evernote.edam.notestore.NotesMetadataList)1 NotesMetadataResultSpec (com.evernote.edam.notestore.NotesMetadataResultSpec)1 SNote (com.lguipeng.notes.model.SNote)1 ArrayList (java.util.ArrayList)1