use of eu.davidea.flexibleadapter.items.AbstractFlexibleItem in project FlexibleAdapter by davideas.
the class FragmentAnimators method performFabAction.
@Override
public void performFabAction() {
int size = 1 + DatabaseService.getInstance().getDatabaseList().size();
AbstractFlexibleItem item = DatabaseService.newAnimatorItem(size);
DatabaseService.getInstance().addItem(item);
mAdapter.addItem(mAdapter.getItemCount(), item);
}
use of eu.davidea.flexibleadapter.items.AbstractFlexibleItem in project FlexibleAdapter by davideas.
the class HeadersSectionsTest method testIsHeader.
@Test
public void testIsHeader() throws Exception {
mAdapter = new FlexibleAdapter<>(mItems);
mAdapter.setDisplayHeadersAtStartUp(true);
AbstractFlexibleItem item = mAdapter.getItem(0);
assertNotNull(item);
assertTrue(mAdapter.isHeader(item));
}
use of eu.davidea.flexibleadapter.items.AbstractFlexibleItem 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));
}
use of eu.davidea.flexibleadapter.items.AbstractFlexibleItem in project FlexibleAdapter by davideas.
the class HeadersSectionsTest method testHasHeader.
@Test
public void testHasHeader() throws Exception {
mAdapter = new FlexibleAdapter<>(mItems);
mAdapter.setDisplayHeadersAtStartUp(true);
AbstractFlexibleItem item = mAdapter.getItem(1);
assertNotNull(item);
assertTrue(mAdapter.hasHeader(item));
}
use of eu.davidea.flexibleadapter.items.AbstractFlexibleItem in project FlexibleAdapter by davideas.
the class MainActivity method onDeleteConfirmed.
@Override
public void onDeleteConfirmed(int action) {
// Disable Refreshing
mSwipeRefreshLayout.setRefreshing(false);
// Removing items from Database. Example:
for (AbstractFlexibleItem adapterItem : mAdapter.getDeletedItems()) {
try {
// NEW! You can take advantage of AutoMap and differentiate logic by viewType using "switch" statement
switch(adapterItem.getLayoutRes()) {
case R.layout.recycler_sub_item:
SubItem subItem = (SubItem) adapterItem;
DatabaseService.getInstance().removeSubItem(mAdapter.getExpandableOfDeletedChild(subItem), subItem);
Log.d(TAG, "Confirm removed " + subItem.getTitle());
break;
case R.layout.recycler_expandable_item:
DatabaseService.getInstance().removeItem(adapterItem);
Log.d(TAG, "Confirm removed " + adapterItem);
break;
}
} catch (IllegalStateException e) {
// AutoMap is disabled, fallback to if-else with "instanceof" statement
if (adapterItem instanceof SubItem) {
// SubItem
SubItem subItem = (SubItem) adapterItem;
IExpandable expandable = mAdapter.getExpandableOf(subItem);
DatabaseService.getInstance().removeSubItem(expandable, subItem);
Log.d(TAG, "Confirm removed " + subItem.getTitle());
} else if (adapterItem instanceof SimpleItem || adapterItem instanceof ExpandableItem) {
DatabaseService.getInstance().removeItem(adapterItem);
Log.d(TAG, "Confirm removed " + adapterItem);
}
}
}
}
Aggregations