use of de.djuelg.neuronizer.domain.model.todolist.TodoListItem in project Neuronizer by djuelg.
the class PreviewRepositoryImpl method getItemPreviewOfHeader.
private List<TodoListItem> getItemPreviewOfHeader(Realm realm, TodoListHeader header, ItemsPerPreview itemsPerPreview) {
if (header == null || itemsPerPreview.areZero())
return new ArrayList<>(0);
RealmResults<TodoListItemDAO> itemDAOs = realm.where(TodoListItemDAO.class).equalTo("parentTodoListUuid", header.getParentTodoListUuid()).equalTo("parentHeaderUuid", header.getUuid()).findAllSorted("position", Sort.DESCENDING);
int size = Math.min(itemDAOs.size(), itemsPerPreview.getCount());
List<TodoListItem> items = new ArrayList<>(size);
if (size > 0) {
for (TodoListItemDAO itemDAO : itemDAOs.subList(0, size)) {
items.add(RealmConverter.convert(itemDAO));
}
}
return items;
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListItem 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);
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListItem in project Neuronizer by djuelg.
the class TodoListRepositoryImpl method getItemById.
@Override
public Optional<TodoListItem> getItemById(String uuid) {
Realm realm = Realm.getInstance(configuration);
Optional<TodoListItemDAO> itemDAO = Optional.fromNullable(realm.where(TodoListItemDAO.class).equalTo("uuid", uuid).findFirst());
Optional<TodoListItem> item = itemDAO.transform(new TodoListItemDAOConverter());
realm.close();
return item;
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListItem in project Neuronizer by djuelg.
the class TodoListFragment method onItemClick.
@Override
public boolean onItemClick(View view, int position) {
AbstractFlexibleItem vm = mAdapter.getItem(position);
if (vm instanceof TodoListItemViewModel) {
TodoListItem item = ((TodoListItemViewModel) vm).getItem().toggleDoneState();
// update view now, update database later via sync
mAdapter.updateItem(position, new TodoListItemViewModel(((TodoListItemViewModel) vm).getHeader(), item), Payload.CHANGE);
}
// return true if you want to activate action mode
return false;
}
use of de.djuelg.neuronizer.domain.model.todolist.TodoListItem 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;
}
Aggregations