Search in sources :

Example 6 with TodoListItemViewModel

use of de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListItemViewModel in project Neuronizer by djuelg.

the class TodoListFragment method permanentDeleteItems.

public void permanentDeleteItems(List<Integer> positions) {
    if (mAdapter == null || mPresenter == null)
        return;
    for (int position : positions) {
        AbstractFlexibleItem adapterItem = mAdapter.getItem(position);
        if (adapterItem != null) {
            switch(adapterItem.getLayoutRes()) {
                case R.layout.todo_list_header:
                    if (mActionModeHelper != null)
                        mActionModeHelper.destroyActionModeIfCan();
                    mPresenter.deleteHeader(((TodoListHeaderViewModel) adapterItem).getHeader().getUuid());
                    break;
                case R.layout.todo_list_item:
                    mPresenter.deleteItem(((TodoListItemViewModel) adapterItem).getItem().getUuid());
                    break;
            }
        }
        mAdapter.removeItem(position);
    }
    mListener.onUpdateAllWidgets(50);
}
Also used : TodoListItemViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListItemViewModel) AbstractFlexibleItem(eu.davidea.flexibleadapter.items.AbstractFlexibleItem) TodoListHeaderViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel)

Aggregations

TodoListItemViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListItemViewModel)6 AbstractFlexibleItem (eu.davidea.flexibleadapter.items.AbstractFlexibleItem)4 TodoListItem (de.djuelg.neuronizer.domain.model.todolist.TodoListItem)3 TodoListHeaderViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel)3 ArrayList (java.util.ArrayList)2 PositionComparator (de.djuelg.neuronizer.domain.comparator.PositionComparator)1 EditItemInteractor (de.djuelg.neuronizer.domain.interactors.todolist.EditItemInteractor)1 EditItemInteractorImpl (de.djuelg.neuronizer.domain.interactors.todolist.impl.EditItemInteractorImpl)1 ISectionable (eu.davidea.flexibleadapter.items.ISectionable)1