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)));
}
}
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);
}
}
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();
}
}
}
}
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);
}
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));
}
Aggregations