Search in sources :

Example 1 with PositionComparator

use of de.djuelg.neuronizer.domain.comparator.PositionComparator in project Neuronizer by djuelg.

the class DisplayTodoListPresenterImpl method createSubItemList.

private List<TodoListItemViewModel> createSubItemList(TodoListHeaderViewModel headerVM, List<TodoListItem> items) {
    Collections.sort(items, new PositionComparator());
    List<TodoListItemViewModel> itemVMs = new ArrayList<>();
    for (TodoListItem item : items) {
        itemVMs.add(new TodoListItemViewModel(headerVM, item));
    }
    return itemVMs;
}
Also used : TodoListItemViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListItemViewModel) ArrayList(java.util.ArrayList) PositionComparator(de.djuelg.neuronizer.domain.comparator.PositionComparator) TodoListItem(de.djuelg.neuronizer.domain.model.todolist.TodoListItem)

Example 2 with PositionComparator

use of de.djuelg.neuronizer.domain.comparator.PositionComparator 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 3 with PositionComparator

use of de.djuelg.neuronizer.domain.comparator.PositionComparator 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 4 with PositionComparator

use of de.djuelg.neuronizer.domain.comparator.PositionComparator in project Neuronizer by djuelg.

the class ItemPresenterImpl method onHeadersRetrieved.

@Override
public void onHeadersRetrieved(List<TodoListHeader> headers) {
    Collections.sort(headers, new PositionComparator());
    mView.onHeadersLoaded(headers);
}
Also used : PositionComparator(de.djuelg.neuronizer.domain.comparator.PositionComparator)

Aggregations

PositionComparator (de.djuelg.neuronizer.domain.comparator.PositionComparator)4 TodoListItem (de.djuelg.neuronizer.domain.model.todolist.TodoListItem)2 TodoListSection (de.djuelg.neuronizer.domain.model.todolist.TodoListSection)2 ArrayList (java.util.ArrayList)2 TodoListHeaderViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel)1 TodoListItemViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListItemViewModel)1 AbstractFlexibleItem (eu.davidea.flexibleadapter.items.AbstractFlexibleItem)1