use of de.djuelg.neuronizer.domain.model.preview.NotePreview in project Neuronizer by djuelg.
the class PreviewFragment method permanentDeleteItem.
private void permanentDeleteItem(int position) {
if (mAdapter == null || mPresenter == null)
return;
PreviewViewModel adapterItem = mAdapter.getItem(position);
mAdapter.clearSelection();
if (adapterItem != null) {
if (adapterItem.getPreview() instanceof TodoListPreview) {
mPresenter.deleteTodoList(adapterItem.getUuid());
} else if (adapterItem.getPreview() instanceof NotePreview) {
mPresenter.deleteNote(adapterItem.getUuid());
}
mAdapter.removeItem(position);
}
}
use of de.djuelg.neuronizer.domain.model.preview.NotePreview in project Neuronizer by djuelg.
the class PreviewRepositoryImpl method getAll.
@Override
public Iterable<Preview> getAll(ItemsPerPreview itemsPerPreview) {
Realm realm = Realm.getInstance(configuration);
RealmResults<TodoListDAO> allTodoListDAO = realm.where(TodoListDAO.class).findAllSorted("position", Sort.DESCENDING);
RealmResults<NoteDAO> allNoteDAO = realm.where(NoteDAO.class).findAllSorted("position", Sort.DESCENDING);
List<Preview> previews = new ArrayList<>(allTodoListDAO.size() + allNoteDAO.size());
for (TodoListDAO todoListDAO : allTodoListDAO) {
previews.add(constructPreview(realm, todoListDAO, itemsPerPreview));
}
for (NoteDAO noteDAO : allNoteDAO) {
previews.add(new NotePreview(RealmConverter.convert(noteDAO)));
}
realm.close();
return previews;
}
Aggregations