/** * Set to true if you want the items to be selectable. * By default, no items are selectable * * @param selectable true if items are selectable * @return this */ public FastAdapter<Item> withSelectable(boolean selectable) { if (selectable) { addExtension(mSelectExtension); } else { mExtensions.remove(mSelectExtension.getClass()); } //TODO revisit this --> false means anyways that it is not in the extension list! mSelectExtension.withSelectable(selectable); return this; }
/** * Define a custom Adapter which will be used in the drawer * NOTE: this is not recommender * WARNING: if you do this after adding items you will loose those! * * @param adapter the FastAdapter to use with this drawer * @return this */ public DrawerBuilder withAdapter(@NonNull FastAdapter<IDrawerItem> adapter) { this.mAdapter = adapter; //we have to rewrap as a different FastAdapter was provided adapter.addAdapter(0, mHeaderAdapter); adapter.addAdapter(1, mItemAdapter); adapter.addAdapter(2, mFooterAdapter); adapter.addExtension(mExpandableExtension); return this; }
/** * creates a new FastAdapter with the provided adapters * if adapters is null, a default ItemAdapter is defined * * @param adapters the adapters which this FastAdapter should use * @return a new FastAdapter */ @SuppressWarnings("unchecked") public static <Item extends IItem, A extends IAdapter> FastAdapter<Item> with(@Nullable Collection<A> adapters, @Nullable Collection<IAdapterExtension<Item>> extensions) { FastAdapter<Item> fastAdapter = new FastAdapter<>(); if (adapters == null) { fastAdapter.mAdapters.add((IAdapter<Item>) items()); } else { fastAdapter.mAdapters.addAll((Collection<IAdapter<Item>>) adapters); } for (int i = 0; i < fastAdapter.mAdapters.size(); i++) { fastAdapter.mAdapters.get(i).withFastAdapter(fastAdapter).setOrder(i); } fastAdapter.cacheSizes(); if (extensions != null) { for (IAdapterExtension<Item> extension : extensions) { fastAdapter.addExtension(extension); } } return fastAdapter; }
@Before public void setUp() throws Exception { itemAdapter = new ItemAdapter<>(); adapter = FastAdapter.with(itemAdapter); selectExtension = new SelectExtension<>(); adapter.addExtension(selectExtension); //adapter.withPositionBasedStateManagement(true); }
@Before public void setUp() throws Exception { itemAdapter = new ItemAdapter<>(); expandableExtension = new ExpandableExtension<>(); adapter = FastAdapter.with(itemAdapter); adapter.addExtension(expandableExtension); //adapter.withPositionBasedStateManagement(true); }