/** * get the adapter (null safe) * * @return the FastAdapter used with this drawer */ protected FastAdapter<IDrawerItem> getAdapter() { if (mAdapter == null) { mAdapter = FastAdapter.with(Arrays.asList(mHeaderAdapter, mItemAdapter, mFooterAdapter), Arrays.<IAdapterExtension<IDrawerItem>>asList(mExpandableExtension)); mAdapter.withSelectable(true); mAdapter.withMultiSelect(false); mAdapter.withAllowDeselection(false); mAdapter.setHasStableIds(mHasStableIds); } return mAdapter; }
@Test public void withSelectable() throws Exception { assertThat(adapter.withSelectable(false).isSelectable()).isFalse(); assertThat(adapter.withSelectable(true).isSelectable()).isTrue(); }
@Test public void withSelectable() throws Exception { assertThat(adapter.withSelectable(true).isSelectable()).isTrue(); assertThat(adapter.withSelectable(false).isSelectable()).isFalse(); }
@Test public void select() throws Exception { adapter.withSelectable(true); itemAdapter.set(TestDataGenerator.genTestItemList(100)); assertThat(adapter.getSelectedItems().size()).isEqualTo(0); assertThat(adapter.getSelections().size()).isEqualTo(0); adapter.select(10); assertThat(adapter.getSelectedItems().size()).isEqualTo(1); assertThat(adapter.getSelectedItems().iterator().next().getIdentifier()).isEqualTo(10); assertThat(adapter.getSelections().size()).isEqualTo(1); assertThat(adapter.getSelections().iterator().next()).isEqualTo(10); }
mAdapter.withSelectable(true); mAdapter.withAllowDeselection(false); mRecyclerView.setAdapter(mAdapter);
fastAdapter.withSelectable(true);
itemAdapter = new ItemAdapter<>(itemListImpl); fastAdapter = FastAdapter.with(itemAdapter); fastAdapter.withSelectable(true);
fastAdapter.withSelectable(true);
fastAdapter.withSelectable(true);
mFastAdapter.withSelectable(true); mFastAdapter.withMultiSelect(true); mFastAdapter.withSelectOnLongClick(true);
fastAdapter.withSelectable(true);
mFastAdapter.withSelectable(true); mFastAdapter.withMultiSelect(true); mFastAdapter.withSelectOnLongClick(true);
.withSelectable(true) .withMultiSelect(true) .withSelectOnLongClick(true)
mFastAdapter.withSelectable(true); mFastAdapter.withMultiSelect(true); mFastAdapter.withSelectOnLongClick(false);
mFastAdapter.withSelectable(true); mFastAdapter.withMultiSelect(true); mFastAdapter.withSelectOnLongClick(false);