Search in sources :

Example 1 with IHeader

use of eu.davidea.flexibleadapter.items.IHeader 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)));
    }
}
Also used : IHeader(eu.davidea.flexibleadapter.items.IHeader) TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) ArrayList(java.util.ArrayList) TodoListHeaderViewModel(de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel)

Example 2 with IHeader

use of eu.davidea.flexibleadapter.items.IHeader 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 3 with IHeader

use of eu.davidea.flexibleadapter.items.IHeader in project FlexibleAdapter by davideas.

the class DatabaseService method updateNewItems.

/**
 * This demonstrates that new content of existing items are really rebound and
 * notified with CHANGE Payload in the Adapter list when refreshed.
 */
public void updateNewItems() {
    IHeader header = null;
    for (IFlexible iFlexible : mItems) {
        if (iFlexible instanceof AbstractItem) {
            AbstractItem item = (AbstractItem) iFlexible;
            item.increaseUpdates();
        }
        if (iFlexible instanceof ISectionable) {
            IHeader newHeader = ((ISectionable) iFlexible).getHeader();
            if (newHeader instanceof HeaderItem && !newHeader.equals(header)) {
                header = newHeader;
                HeaderItem headerItem = (HeaderItem) header;
                headerItem.increaseUpdates();
            }
        }
    }
}
Also used : IHeader(eu.davidea.flexibleadapter.items.IHeader) IFlexible(eu.davidea.flexibleadapter.items.IFlexible) AbstractItem(eu.davidea.samples.flexibleadapter.items.AbstractItem) InstagramHeaderItem(eu.davidea.samples.flexibleadapter.items.InstagramHeaderItem) StaggeredHeaderItem(eu.davidea.samples.flexibleadapter.items.StaggeredHeaderItem) ExpandableHeaderItem(eu.davidea.samples.flexibleadapter.items.ExpandableHeaderItem) HeaderItem(eu.davidea.samples.flexibleadapter.items.HeaderItem) ISectionable(eu.davidea.flexibleadapter.items.ISectionable)

Example 4 with IHeader

use of eu.davidea.flexibleadapter.items.IHeader in project FlexibleAdapter by davideas.

the class UpdateDataSetTest method changeDatabaseContent.

private void changeDatabaseContent() {
    // Remove item pos=2
    AbstractFlexibleItem itemToDelete = mAdapter.getItem(2);
    DatabaseService.getInstance().removeItem(itemToDelete);
    // Modify items content
    DatabaseService.getInstance().updateNewItems();
    // Add item pos=last
    IHeader header = mAdapter.getSectionHeader(30);
    AbstractFlexibleItem itemToAdd = DatabaseService.newSimpleItem(31, header);
    DatabaseService.getInstance().addItem(itemToAdd);
}
Also used : AbstractFlexibleItem(eu.davidea.flexibleadapter.items.AbstractFlexibleItem) IHeader(eu.davidea.flexibleadapter.items.IHeader)

Example 5 with IHeader

use of eu.davidea.flexibleadapter.items.IHeader in project FlexibleAdapter by davideas.

the class HeadersSectionsTest method testHasSameHeader.

@Test
public void testHasSameHeader() throws Exception {
    mAdapter = new FlexibleAdapter<>(mItems);
    mAdapter.setDisplayHeadersAtStartUp(true);
    AbstractFlexibleItem item1 = mAdapter.getItem(1);
    IHeader header = mAdapter.getHeaderOf(item1);
    assertNotNull(header);
    AbstractFlexibleItem item2 = mAdapter.getItem(3);
    assertNotNull(item2);
    assertTrue(mAdapter.hasSameHeader(item2, header));
}
Also used : AbstractFlexibleItem(eu.davidea.flexibleadapter.items.AbstractFlexibleItem) IHeader(eu.davidea.flexibleadapter.items.IHeader) Test(org.junit.Test)

Aggregations

IHeader (eu.davidea.flexibleadapter.items.IHeader)21 SuppressLint (android.annotation.SuppressLint)8 ISectionable (eu.davidea.flexibleadapter.items.ISectionable)8 Test (org.junit.Test)4 AbstractFlexibleItem (eu.davidea.flexibleadapter.items.AbstractFlexibleItem)3 IExpandable (eu.davidea.flexibleadapter.items.IExpandable)3 TodoListHeaderViewModel (de.djuelg.neuronizer.presentation.ui.flexibleadapter.TodoListHeaderViewModel)2 ArrayList (java.util.ArrayList)2 TodoListHeader (de.djuelg.neuronizer.domain.model.todolist.TodoListHeader)1 IFlexible (eu.davidea.flexibleadapter.items.IFlexible)1 AbstractItem (eu.davidea.samples.flexibleadapter.items.AbstractItem)1 ExpandableHeaderItem (eu.davidea.samples.flexibleadapter.items.ExpandableHeaderItem)1 HeaderItem (eu.davidea.samples.flexibleadapter.items.HeaderItem)1 InstagramHeaderItem (eu.davidea.samples.flexibleadapter.items.InstagramHeaderItem)1 StaggeredHeaderItem (eu.davidea.samples.flexibleadapter.items.StaggeredHeaderItem)1 List (java.util.List)1