コード例 #1
0
 private Note findNote(long id) {
   for (Note n : notes()) {
     if (n.getId() == id) {
       return n;
     }
   }
   return null;
 }
コード例 #2
0
 @Override
 public void updateViewingNote(Object sender, String title, String content) {
   Note note = getModel().getViewingNote();
   if (note != null) {
     note.setTitle(title);
     note.setContent(content);
     note.setUpdateTime(System.currentTimeMillis());
     persistNotes();
     postC2VEvent(new EventC2V.OnNoteUpdated(sender));
   }
 }
コード例 #3
0
  @Override
  public void addNote(String title, String content) {
    if (title != null && !title.isEmpty()) {
      Note note = new Note();
      notes().add(note);
      note.setId(System.currentTimeMillis());
      note.setTitle(title);
      note.setContent(content);
      note.setUpdateTime(System.currentTimeMillis());

      persistNotes();
      postC2VEvent(new EventC2V.OnNoteCreated(this));
    }
    navigationController.navigateBack(this);
  }
コード例 #4
0
  @Override
  public void removeNote(Object sender) {
    if (inSelectionMode()) {
      Iterator<Note> iterator = notes().iterator();
      while (iterator.hasNext()) {
        Note note = iterator.next();
        if (getModel().getSelectedNoteIds().contains(note.getId())) {
          iterator.remove();
        }
      }

      persistNotes();

      postC2VEvent(
          new EventC2V.OnNoteRemoved(sender, new ArrayList<>(getModel().getSelectedNoteIds())));
      getModel().getSelectedNoteIds().clear();
    }
  }