Search in sources :

Example 6 with TodoListHeaderViewModel

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();
}
Also used : TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) TodoListHeaderViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel)

Example 7 with TodoListHeaderViewModel

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);
    }
}
Also used : IHeader(eu.davidea.flexibleadapter.items.IHeader) TodoListHeaderViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel)

Example 8 with TodoListHeaderViewModel

use of de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel 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

TodoListHeaderViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel)8 AbstractFlexibleItem (eu.davidea.flexibleadapter.items.AbstractFlexibleItem)5 TodoListItemViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListItemViewModel)3 TodoListHeader (de.djuelg.neuronizer.domain.model.todolist.TodoListHeader)2 IHeader (eu.davidea.flexibleadapter.items.IHeader)2 ArrayList (java.util.ArrayList)2 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 PositionComparator (de.djuelg.neuronizer.domain.comparator.PositionComparator)1 TodoListSection (de.djuelg.neuronizer.domain.model.todolist.TodoListSection)1