Search in sources :

Example 1 with TodoListSection

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

the class DisplayTodoListPresenterImpl method onTodoListRetrieved.

@Override
public void onTodoListRetrieved(List<TodoListSection> sections) {
    Collections.sort(sections, new PositionComparator());
    List<AbstractFlexibleItem> headerVMs = new ArrayList<>(sections.size());
    for (TodoListSection section : sections) {
        TodoListHeaderViewModel headerVM = new TodoListHeaderViewModel(section.getHeader());
        headerVM.setSubItems(createSubItemList(headerVM, Lists.newArrayList(section.getItems())));
        headerVMs.add(headerVM);
    }
    mView.onTodoListLoaded(headerVMs);
}
Also used : TodoListSection(de.djuelg.neuronizer.domain.model.todolist.TodoListSection) AbstractFlexibleItem(eu.davidea.flexibleadapter.items.AbstractFlexibleItem) ArrayList(java.util.ArrayList) PositionComparator(de.djuelg.neuronizer.domain.comparator.PositionComparator) TodoListHeaderViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel)

Example 2 with TodoListSection

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

the class WidgetListFactory method onDataSetChanged.

@Override
public void onDataSetChanged() {
    itemList.clear();
    List<TodoListSection> sections = Lists.newArrayList(repository.getSectionsOfTodoListId(uuid));
    Collections.sort(sections, new PositionComparator());
    for (TodoListSection section : sections) {
        itemList.add(section.getHeader());
        List<TodoListItem> items = Lists.newArrayList(section.getItems());
        Collections.sort(items, new PositionComparator());
        itemList.addAll(items);
    }
}
Also used : TodoListSection(de.djuelg.neuronizer.domain.model.todolist.TodoListSection) PositionComparator(de.djuelg.neuronizer.domain.comparator.PositionComparator) TodoListItem(de.djuelg.neuronizer.domain.model.todolist.TodoListItem)

Example 3 with TodoListSection

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

the class TodoListRepositoryImpl method getSectionsOfTodoListId.

@Override
public List<TodoListSection> getSectionsOfTodoListId(String uuid) {
    Realm realm = Realm.getInstance(configuration);
    RealmResults<TodoListHeaderDAO> headerDAOs = realm.where(TodoListHeaderDAO.class).equalTo("parentTodoListUuid", uuid).findAll();
    List<TodoListSection> sections = new ArrayList<>(headerDAOs.size());
    for (TodoListHeaderDAO dao : headerDAOs) {
        sections.add(constructSection(realm, dao));
    }
    realm.close();
    return sections;
}
Also used : TodoListSection(de.djuelg.neuronizer.domain.model.todolist.TodoListSection) ArrayList(java.util.ArrayList) TodoListHeaderDAO(de.djuelg.neuronizer.storage.model.TodoListHeaderDAO) Realm(io.realm.Realm)

Example 4 with TodoListSection

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

the class TodoListRepositoryImpl method constructSection.

private TodoListSection constructSection(Realm realm, TodoListHeaderDAO headerDAO) {
    RealmResults<TodoListItemDAO> itemDAOs = realm.where(TodoListItemDAO.class).equalTo("parentTodoListUuid", headerDAO.getParentTodoListUuid()).equalTo("parentHeaderUuid", headerDAO.getUuid()).findAll();
    List<TodoListItem> items = new ArrayList<>(itemDAOs.size());
    TodoListHeader header = RealmConverter.convert(headerDAO);
    for (TodoListItemDAO dao : itemDAOs) {
        items.add(RealmConverter.convert(dao));
    }
    return new TodoListSection(header, items);
}
Also used : TodoListSection(de.djuelg.neuronizer.domain.model.todolist.TodoListSection) TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) ArrayList(java.util.ArrayList) TodoListItem(de.djuelg.neuronizer.domain.model.todolist.TodoListItem) TodoListItemDAO(de.djuelg.neuronizer.storage.model.TodoListItemDAO)

Example 5 with TodoListSection

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

the class TodoListRepositoryMock method getSectionsOfTodoListId.

@Override
public // - are presenters tested? if yes then test DisplayTodoListPresenter
List<TodoListSection> getSectionsOfTodoListId(String uuid) {
    List<TodoListSection> sections = new ArrayList<>(1);
    List<TodoListItem> items = new ArrayList<TodoListItem>(1);
    items.add(alwaysSameItem);
    sections.add(new TodoListSection(alwaysSameHeader, items));
    return sections;
}
Also used : TodoListSection(de.djuelg.neuronizer.domain.model.todolist.TodoListSection) ArrayList(java.util.ArrayList) TodoListItem(de.djuelg.neuronizer.domain.model.todolist.TodoListItem)

Aggregations

TodoListSection (de.djuelg.neuronizer.domain.model.todolist.TodoListSection)5 ArrayList (java.util.ArrayList)4 TodoListItem (de.djuelg.neuronizer.domain.model.todolist.TodoListItem)3 PositionComparator (de.djuelg.neuronizer.domain.comparator.PositionComparator)2 TodoListHeader (de.djuelg.neuronizer.domain.model.todolist.TodoListHeader)1 TodoListHeaderViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel)1 TodoListHeaderDAO (de.djuelg.neuronizer.storage.model.TodoListHeaderDAO)1 TodoListItemDAO (de.djuelg.neuronizer.storage.model.TodoListItemDAO)1 AbstractFlexibleItem (eu.davidea.flexibleadapter.items.AbstractFlexibleItem)1 Realm (io.realm.Realm)1