Search in sources :

Example 16 with TodoListHeader

use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.

the class TodoListRepositoryImplTest method testDeleteHeaderNotExisting.

@Test
public void testDeleteHeaderNotExisting() {
    TodoListHeader header = createHeader();
    repository.delete(header);
    Optional<TodoListHeader> fromDb = repository.getHeaderById(header.getUuid());
    assertFalse(fromDb.isPresent());
}
Also used : TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 17 with TodoListHeader

use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.

the class AddHeaderInteractorImpl method run.

@Override
public void run() {
    final Optional<TodoList> todoList = repository.todoList().getTodoListById(parentTodoListUuid);
    final int position = repository.todoList().getHeaderCountOfTodoList(parentTodoListUuid);
    if (!todoList.isPresent()) {
        callback.onParentNotFound();
        return;
    }
    // try to insert with new UUID on failure
    TodoListHeader header = new TodoListHeader(title, position, parentTodoListUuid);
    while (!repository.todoList().insert(header)) {
        header = new TodoListHeader(title, position, parentTodoListUuid);
    }
    repository.todoList().update(todoList.get().updateLastChange());
    // notify on the main thread that we have inserted this item
    mMainThread.post(new Runnable() {

        @Override
        public void run() {
            callback.onHeaderAdded();
        }
    });
}
Also used : TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) TodoList(de.djuelg.neuronizer.domain.model.preview.TodoList)

Example 18 with TodoListHeader

use of de.djuelg.neuronizer.domain.model.todolist.TodoListHeader in project Neuronizer by djuelg.

the class AddItemInteractorImpl method run.

@Override
public void run() {
    final Optional<TodoList> todoList = repository.todoList().getTodoListById(parentTodoListUuid);
    final Optional<TodoListHeader> header = repository.todoList().getHeaderById(parentHeaderUuid);
    final int position = repository.todoList().getSubItemCountOfHeader(parentHeaderUuid);
    if (!todoList.isPresent() || !header.isPresent()) {
        callback.onParentNotFound();
        return;
    }
    // try to insert with new UUID on failure
    TodoListItem item = new TodoListItem(title, position, important, details, parentTodoListUuid, parentHeaderUuid);
    while (!repository.todoList().insert(item)) {
        item = new TodoListItem(title, position, important, details, parentTodoListUuid, parentHeaderUuid);
    }
    repository.todoList().update(todoList.get().updateLastChange());
    // notify on the main thread that we have inserted this item
    mMainThread.post(new Runnable() {

        @Override
        public void run() {
            callback.onItemAdded();
        }
    });
}
Also used : TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) TodoListItem(de.djuelg.neuronizer.domain.model.todolist.TodoListItem) TodoList(de.djuelg.neuronizer.domain.model.preview.TodoList)

Aggregations

TodoListHeader (de.djuelg.neuronizer.domain.model.todolist.TodoListHeader)18 MediumTest (android.support.test.filters.MediumTest)6 Test (org.junit.Test)6 TodoList (de.djuelg.neuronizer.domain.model.preview.TodoList)5 TodoListHeaderDAO (de.djuelg.neuronizer.storage.model.TodoListHeaderDAO)5 TodoListItem (de.djuelg.neuronizer.domain.model.todolist.TodoListItem)4 ArrayList (java.util.ArrayList)3 TodoListHeaderViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel)2 TodoListHeaderDAOConverter (de.djuelg.neuronizer.storage.converter.TodoListHeaderDAOConverter)2 Realm (io.realm.Realm)2 InputMismatchException (java.util.InputMismatchException)2 ArrayAdapter (android.widget.ArrayAdapter)1 TodoListPreview (de.djuelg.neuronizer.domain.model.preview.TodoListPreview)1 TodoListSection (de.djuelg.neuronizer.domain.model.todolist.TodoListSection)1 TodoListItemDAO (de.djuelg.neuronizer.storage.model.TodoListItemDAO)1 IHeader (eu.davidea.flexibleadapter.items.IHeader)1