use of de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel in project Neuronizer by djuelg.
the class DisplayTodoListPresenterImpl method syncTodoList.
@Override
public void syncTodoList(FlexibleAdapter<AbstractFlexibleItem> adapter) {
List<IHeader> reversedHeaders = Lists.reverse(Optional.fromNullable(Lists.newArrayList(adapter.getHeaderItems())).or(new ArrayList<IHeader>(0)));
for (IHeader iHeader : reversedHeaders) {
TodoListHeaderViewModel vm = (TodoListHeaderViewModel) iHeader;
TodoListHeader header = vm.getHeader();
syncHeader(header, reversedHeaders.indexOf(vm), vm.isExpanded());
syncSubItems(Lists.newArrayList(adapter.getSectionItems(iHeader)));
}
}
use of de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel 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);
}
use of de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel in project Neuronizer by djuelg.
the class TodoListFragment method editSelectedHeader.
private void editSelectedHeader() {
int position = mAdapter.getSelectedPositions().get(0);
TodoListHeaderViewModel headerVH = (TodoListHeaderViewModel) mAdapter.getItem(position);
if (headerVH != null) {
TodoListHeader header = headerVH.getHeader();
showEditHeaderDialog(this, header.getUuid(), header.getTitle(), header.getPosition(), header.isExpanded());
}
mActionModeHelper.destroyActionModeIfCan();
}
use of de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel in project Neuronizer by djuelg.
the class TodoListFragment method onActionCanceled.
@Override
public void onActionCanceled(@UndoHelper.Action int action, List<Integer> positions) {
if (mAdapter == null || action != UndoHelper.Action.REMOVE)
return;
List<AbstractFlexibleItem> restoredItems = mAdapter.getDeletedItems();
mAdapter.restoreDeletedItems();
if (!restoredItems.isEmpty()) {
mAdapter.clearSelection();
AbstractFlexibleItem item = Iterables.getLast(restoredItems);
if (item instanceof TodoListHeaderViewModel && mActionModeHelper != null)
mActionModeHelper.onLongClick((AppCompatActivity) getActivity(), mAdapter.getGlobalPositionOf(item));
}
}
use of de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel in project Neuronizer by djuelg.
the class TodoListFragment method onDestroyActionMode.
@Override
public void onDestroyActionMode(ActionMode mode) {
changeAppbarColor(getActivity(), R.color.colorPrimary);
for (IHeader header : mAdapter.getHeaderItems()) {
TodoListHeaderViewModel vm = (TodoListHeaderViewModel) header;
boolean shouldExpand = vm.getHeader().isExpanded();
if (shouldExpand && !omitActionModeExpansion)
mAdapter.expand(vm);
}
}
Aggregations