private Note findNote(long id) { for (Note n : notes()) { if (n.getId() == id) { return n; } } return null; }
@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)); } }
@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); }
@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(); } }