Exemplo n.º 1
0
 public List<Note> getEntryData() {
   List<Note> res = new ArrayList<>();
   for (SyndEntryImpl list1 : (List<SyndEntryImpl>) feedContent.getEntries()) {
     if (list1 == null || list1.equals(last)) break;
     Note addition = new Note();
     //            print(addition + " " + last);
     addition.setTitle(list1.getTitle());
     addition.setContent(list1.getLink());
     res.add(addition);
   }
   last = (SyndEntryImpl) feedContent.getEntries().get(0);
   return res;
 }
  public Note makeNote(
      EvernoteNoteStoreClient noteStore,
      String noteTitle,
      String noteBody,
      Bitmap... imageResources) {

    // Create a Note instance with title and body
    // Send Note object to user's account
    Note note = new Note();
    note.setTitle(noteTitle);

    // Build body of note
    StringBuilder body = new StringBuilder(EvernoteUtil.NOTE_PREFIX).append(noteBody);

    if (imageResources != null && imageResources.length > 0) {
      // Create Resource objects from image resources and add them to note body
      body.append("<br /><br />");
      List<Resource> resources = new ArrayList<>(imageResources.length);
      note.setResources(resources);
      for (Bitmap image : imageResources) {
        Resource r = makeResource(image);
        if (r == null) continue;
        resources.add(r);
        body.append("Attachment with hash ")
            .append(Arrays.toString(r.getData().getBodyHash()))
            .append(": <br /><en-media type=\"")
            .append(r.getMime())
            .append("\" hash=\"")
            .append(Arrays.toString(r.getData().getBodyHash()))
            .append("\" /><br />");
      }
      body.append(EvernoteUtil.NOTE_SUFFIX);

      note.setContent(body.toString());

      // Attempt to create note in Evernote account
      try {
        note = noteStore.createNote(note);
      } catch (Exception e) {
        // Something was wrong with the note data
        // See EDAMErrorCode enumeration for error code explanation
        // http://dev.evernote.com/documentation/reference/Errors.html#Enum_EDAMErrorCode
        Toast.makeText(this, R.string.save_note_error, Toast.LENGTH_LONG).show();
        note = null;
      }
    }

    // Return created note object
    return note;
  }