Search in sources :

Example 1 with TodoListPreview

use of de.djuelg.neuronizer.domain.model.preview.TodoListPreview 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);
    }
}
Also used : PreviewViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.PreviewViewModel) NotePreview(de.djuelg.neuronizer.domain.model.preview.NotePreview) TodoListPreview(de.djuelg.neuronizer.domain.model.preview.TodoListPreview)

Example 2 with TodoListPreview

use of de.djuelg.neuronizer.domain.model.preview.TodoListPreview in project Neuronizer by djuelg.

the class PreviewRepositoryImpl method constructPreview.

private TodoListPreview constructPreview(Realm realm, TodoListDAO todoListDAO, ItemsPerPreview itemsPerPreview) {
    TodoList todoList = RealmConverter.convert(todoListDAO);
    Optional<TodoListHeaderDAO> headerDAO = Optional.fromNullable(realm.where(TodoListHeaderDAO.class).equalTo("parentTodoListUuid", todoListDAO.getUuid()).sort("position", Sort.DESCENDING).findFirst());
    TodoListHeader header = headerDAO.transform(new TodoListHeaderDAOConverter()).orNull();
    List<TodoListItem> items = getItemPreviewOfHeader(realm, header, itemsPerPreview);
    return new TodoListPreview(todoList, header, items);
}
Also used : TodoListHeaderDAOConverter(de.djuelg.neuronizer.storage.converter.TodoListHeaderDAOConverter) TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) TodoListHeaderDAO(de.djuelg.neuronizer.storage.model.TodoListHeaderDAO) TodoListItem(de.djuelg.neuronizer.domain.model.todolist.TodoListItem) TodoListPreview(de.djuelg.neuronizer.domain.model.preview.TodoListPreview) TodoList(de.djuelg.neuronizer.domain.model.preview.TodoList)

Aggregations

TodoListPreview (de.djuelg.neuronizer.domain.model.preview.TodoListPreview)2 NotePreview (de.djuelg.neuronizer.domain.model.preview.NotePreview)1 TodoList (de.djuelg.neuronizer.domain.model.preview.TodoList)1 TodoListHeader (de.djuelg.neuronizer.domain.model.todolist.TodoListHeader)1 TodoListItem (de.djuelg.neuronizer.domain.model.todolist.TodoListItem)1 PreviewViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.PreviewViewModel)1 TodoListHeaderDAOConverter (de.djuelg.neuronizer.storage.converter.TodoListHeaderDAOConverter)1 TodoListHeaderDAO (de.djuelg.neuronizer.storage.model.TodoListHeaderDAO)1