本文整理汇总了Java中eu.davidea.flexibleadapter.items.AbstractFlexibleItem类的典型用法代码示例。如果您正苦于以下问题:Java AbstractFlexibleItem类的具体用法?Java AbstractFlexibleItem怎么用?Java AbstractFlexibleItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractFlexibleItem类属于eu.davidea.flexibleadapter.items包,在下文中一共展示了AbstractFlexibleItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: resetItems
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
public void resetItems() {
List<StaggeredItem> mergedItems = new ArrayList<>();
for (AbstractFlexibleItem item : mItems) {
if (item instanceof StaggeredItem) {
StaggeredItem staggeredItem = (StaggeredItem) item;
staggeredItem.setStatus(StaggeredItemStatus.C);
staggeredItem.setHeader(headers.get(StaggeredItemStatus.C));
mergedItems.addAll(staggeredItem.splitAllItems());
}
}
for (StaggeredHeaderItem header : headers.values()) {
header.setHidden(true);
}
mItems.addAll(mergedItems);
Collections.sort(mItems, new ItemComparatorById());
createMergedItems();
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:DatabaseService.java
示例2: testCalculatePositionFor_AddItem
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@Test
public void testCalculatePositionFor_AddItem() {
FlexibleAdapter<AbstractFlexibleItem> adapter = new FlexibleAdapter<>(initItems);
adapter.setDisplayHeadersAtStartUp(true);
SimpleItem aa = new SimpleItem(headers[0], "aa");
SimpleItem ab = new SimpleItem(headers[0], "ab");
SimpleItem ac = new SimpleItem(headers[0], "ac");
System.out.println("addItem precondition: " + initItems);
adapter.addItem(adapter.calculatePositionFor(ab, comparator), ab);
assertEquals(1, adapter.getGlobalPositionOf(ab));
System.out.println("addItem item ab: " + initItems);
adapter.addItem(adapter.calculatePositionFor(aa, comparator), aa);
assertEquals(1, adapter.getGlobalPositionOf(aa));
System.out.println("addItem item aa: " + initItems);
adapter.addItem(adapter.calculatePositionFor(ac, comparator), ac);
assertEquals(3, adapter.getGlobalPositionOf(ac));
System.out.println("addItem item ac: " + initItems);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:ItemComparatorTest.java
示例3: testCalculatePositionFor_AddSection
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@Test
public void testCalculatePositionFor_AddSection() {
FlexibleAdapter<AbstractFlexibleItem> adapter = new FlexibleAdapter<>(initItems);
adapter.setDisplayHeadersAtStartUp(true);
//TEST1 - Head of the list
int position = adapter.calculatePositionFor(headers[0], comparator);
adapter.addItem(position, headers[0]);
assertEquals(0, adapter.getGlobalPositionOf(headers[0]));
System.out.println("addItem new Section a (Head): " + initItems);
//TEST1 - Tail of the list
SimpleHeader d = new SimpleHeader("d");
position = adapter.calculatePositionFor(d, comparator);
adapter.addItem(position, d);
assertEquals(9, adapter.getGlobalPositionOf(d));
System.out.println("addItem new Section d (Tail): " + initItems);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:ItemComparatorTest.java
示例4: testComparator_AddItemToSection
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@Test
public void testComparator_AddItemToSection() {
FlexibleAdapter<AbstractFlexibleItem> adapter = new FlexibleAdapter<>(initItems);
adapter.setDisplayHeadersAtStartUp(true);
SimpleItem aa = new SimpleItem(headers[0], "aa");
SimpleItem ab = new SimpleItem(headers[0], "ab");
//TEST1 = New Item for a New Section (internal use of calculatePositionFor())
adapter.addItemToSection(aa, headers[0], comparator);
assertEquals(1, adapter.getGlobalPositionOf(aa));
System.out.println("addItemToSection item aa, new Section: " + initItems);
//TEST2 = New Item for an Existing Section
adapter.addItemToSection(ab, headers[0], comparator);
assertEquals(2, adapter.getGlobalPositionOf(ab));
System.out.println("addItemToSection item ab, existing Section: " + initItems);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:ItemComparatorTest.java
示例5: testComparator
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@Test
public void testComparator() {
SimpleItem aa = new SimpleItem(headers[0], "aa");
SimpleItem ba = new SimpleItem(headers[1], "ba");
SimpleItem cb = new SimpleItem(headers[2], "cb");
List<AbstractFlexibleItem> sortArray = new ArrayList<>();
sortArray.add(ba);
sortArray.add(aa);
sortArray.add(cb);
sortArray.add(headers[2]);
sortArray.add(headers[0]);
sortArray.add(headers[1]);
Collections.sort(sortArray, comparator);
assertEquals(sortArray.get(0), headers[0]);
assertEquals(sortArray.get(1), aa);
assertEquals(sortArray.get(2), headers[1]);
assertEquals(sortArray.get(3), ba);
assertEquals(sortArray.get(4), headers[2]);
assertEquals(sortArray.get(5), cb);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:ItemComparatorTest.java
示例6: initializeActionModeHelper
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
private void initializeActionModeHelper() {
//this = ActionMode.Callback instance
mActionModeHelper = new ActionModeHelper(mAdapter, R.menu.menu_action_header, this) {
// Override to customize the title
@Override
public void updateContextTitle(int count) {
// You can use the internal mActionMode instance
if (mActionMode != null) {
int position = mAdapter.getSelectedPositions().get(0);
AbstractFlexibleItem item = mAdapter.getItem(position);
mActionMode.setTitle(fontifyString(getActivity(), getString(R.string.action_edit_category, item)));
}
}
}.withDefaultMode(SelectableAdapter.Mode.SINGLE);
mActionModeHelper.withDefaultMode(SelectableAdapter.Mode.SINGLE);
mAdapter.setMode(SelectableAdapter.Mode.SINGLE);
}
开发者ID:djuelg,项目名称:Neuronizer,代码行数:18,代码来源:TodoListFragment.java
示例7: onDeleteConfirmed
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@Override
public void onDeleteConfirmed(int action) {
if (mAdapter == null || mPresenter == null) return;
for (AbstractFlexibleItem adapterItem : mAdapter.getDeletedItems()) {
switch (adapterItem.getLayoutRes()) {
case R.layout.todo_list_header:
if (mAdapter.isPermanentDelete() && mActionModeHelper != null) mActionModeHelper.destroyActionModeIfCan();
mPresenter.deleteHeader(((TodoListHeaderViewModel)adapterItem).getHeader().getUuid());
break;
case R.layout.todo_list_item:
mPresenter.deleteItem(((TodoListItemViewModel)adapterItem).getItem().getUuid());
break;
}
}
mListener.onUpdateAllWidgets(50);
}
开发者ID:djuelg,项目名称:Neuronizer,代码行数:17,代码来源:TodoListFragment.java
示例8: permanentDeleteItem
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
public void permanentDeleteItem(int position) {
if (mAdapter == null || mPresenter == null) return;
AbstractFlexibleItem adapterItem = mAdapter.getItem(position);
if (adapterItem != null) {
switch (adapterItem.getLayoutRes()) {
case R.layout.todo_list_header:
if (mActionModeHelper != null) mActionModeHelper.destroyActionModeIfCan();
mPresenter.deleteHeader(((TodoListHeaderViewModel)adapterItem).getHeader().getUuid());
break;
case R.layout.todo_list_item:
mPresenter.deleteItem(((TodoListItemViewModel)adapterItem).getItem().getUuid());
break;
}
}
mListener.onUpdateAllWidgets(50);
mAdapter.removeItem(position);
}
开发者ID:djuelg,项目名称:Neuronizer,代码行数:18,代码来源:TodoListFragment.java
示例9: onActionConfirmed
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@Override
public void onActionConfirmed(@UndoHelper.Action int action, int event) {
if (action == UndoHelper.Action.UPDATE) {
mAdapter.removeItems(mAdapter.getUndoPositions());
}
// Disable Refreshing
mRefreshHandler.sendEmptyMessage(REFRESH_STOP);
// Removing items from Database. Example:
for (AbstractFlexibleItem adapterItem : mAdapter.getDeletedItems()) {
// 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("Confirm removed %s", subItem);
break;
case R.layout.recycler_simple_item:
case R.layout.recycler_expandable_item:
DatabaseService.getInstance().removeItem(adapterItem);
Log.d("Confirm removed %s", adapterItem);
break;
}
}
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:25,代码来源:MainActivity.java
示例10: resetItems
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
public void resetItems() {
List<StaggeredItem> mergedItems = new ArrayList<>();
for (AbstractFlexibleItem item : mItems) {
if (item instanceof StaggeredItem) {
StaggeredItem staggeredItem = (StaggeredItem) item;
staggeredItem.setStatus(StaggeredItemStatus.C);
staggeredItem.setHeader(headers.get(StaggeredItemStatus.C));
mergedItems.addAll(staggeredItem.splitAllItems());
}
}
for (StaggeredHeaderItem header : headers.values()) {
header.setHidden(true);
}
mItems.addAll(mergedItems);
sort(new ItemComparatorById());
createMergedItems();
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:18,代码来源:DatabaseService.java
示例11: testCalculatePositionFor_AddItem
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@Test
public void testCalculatePositionFor_AddItem() {
FlexibleAdapter<AbstractFlexibleItem> adapter = new FlexibleAdapter<>(initItems);
adapter.setDisplayHeadersAtStartUp(true);
SimpleItem aa = new SimpleItem(headers[0], "aa");
SimpleItem ab = new SimpleItem(headers[0], "ab");
SimpleItem ac = new SimpleItem(headers[0], "ac");
System.out.println("addItem precondition: " + initItems);
adapter.addItem(adapter.calculatePositionFor(ab, comparator), ab);
assertEquals(1, adapter.getGlobalPositionOf(ab));
System.out.println("addItem item ab: " + initItems);
adapter.addItem(adapter.calculatePositionFor(aa, comparator), aa);
assertEquals(1, adapter.getGlobalPositionOf(aa));
System.out.println("addItem item aa: " + initItems);
adapter.addItem(adapter.calculatePositionFor(ac, comparator), ac);
assertEquals(3, adapter.getGlobalPositionOf(ac));
System.out.println("addItem item ac: " + initItems);
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:23,代码来源:ItemComparatorTest.java
示例12: testCalculatePositionFor_AddSection
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@Test
public void testCalculatePositionFor_AddSection() {
FlexibleAdapter<AbstractFlexibleItem> adapter = new FlexibleAdapter<>(initItems);
adapter.setDisplayHeadersAtStartUp(true);
//TEST1 - Head of the list
int position = adapter.calculatePositionFor(headers[0], comparator);
adapter.addItem(position, headers[0]);
assertEquals(0, adapter.getGlobalPositionOf(headers[0]));
System.out.println("addItem new Section a (Head): " + initItems);
//TEST1 - Tail of the list
SimpleHeader d = new SimpleHeader("d");
position = adapter.calculatePositionFor(d, comparator);
adapter.addItem(position, d);
assertEquals(9, adapter.getGlobalPositionOf(d));
System.out.println("addItem new Section d (Tail): " + initItems);
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:19,代码来源:ItemComparatorTest.java
示例13: testComparator_AddItemToSection
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@Test
public void testComparator_AddItemToSection() {
FlexibleAdapter<AbstractFlexibleItem> adapter = new FlexibleAdapter<>(initItems);
adapter.setDisplayHeadersAtStartUp(true);
SimpleItem aa = new SimpleItem(headers[0], "aa");
SimpleItem ab = new SimpleItem(headers[0], "ab");
//TEST1 = New Item for a New Section (internal use of calculatePositionFor())
adapter.addItemToSection(aa, headers[0], comparator);
assertEquals(1, adapter.getGlobalPositionOf(aa));
System.out.println("addItemToSection item aa, new Section: " + initItems);
//TEST2 = New Item for an Existing Section
adapter.addItemToSection(ab, headers[0], comparator);
assertEquals(2, adapter.getGlobalPositionOf(ab));
System.out.println("addItemToSection item ab, existing Section: " + initItems);
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:19,代码来源:ItemComparatorTest.java
示例14: testComparator
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@Test
public void testComparator() {
SimpleItem aa = new SimpleItem(headers[0], "aa");
SimpleItem ba = new SimpleItem(headers[1], "ba");
SimpleItem cb = new SimpleItem(headers[2], "cb");
List<AbstractFlexibleItem> sortArray = new ArrayList<>();
sortArray.add(ba);
sortArray.add(aa);
sortArray.add(cb);
sortArray.add(headers[2]);
sortArray.add(headers[0]);
sortArray.add(headers[1]);
Collections.sort(sortArray, comparator);
assertEquals(sortArray.get(0), headers[0]);
assertEquals(sortArray.get(1), aa);
assertEquals(sortArray.get(2), headers[1]);
assertEquals(sortArray.get(3), ba);
assertEquals(sortArray.get(4), headers[2]);
assertEquals(sortArray.get(5), cb);
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:24,代码来源:ItemComparatorTest.java
示例15: testClearAllBut_WithScrollableItems
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@Test
public void testClearAllBut_WithScrollableItems() {
// Grab the LayoutRes to retain
AbstractFlexibleItem headerItem = mAdapter.getItem(0);
// Add scrollable items
mAdapter.addScrollableHeader(scrollableHeader);
mAdapter.addScrollableFooter(scrollableFooter);
assertEquals(37, mAdapter.getItemCount());
assertEquals(35, mAdapter.getMainItemCount());
// Clear all simple items, retains header items (...and scrollable items)
mAdapter.clearAllBut(headerItem.getItemViewType());
assertEquals(7, mAdapter.getItemCount());
assertEquals(5, mAdapter.getMainItemCount());
assertEquals(scrollableHeader, mAdapter.getItem(0));
assertEquals(scrollableFooter, mAdapter.getItem(mAdapter.getItemCount() - 1));
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:19,代码来源:ClearItemsTest.java
示例16: createSectionableItems
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@Test
public void createSectionableItems() throws Exception {
Map<String, HeaderModel> headers = new HashMap<>(2);
headers.put("H1", new HeaderModel("H1"));
headers.put("H2", new HeaderModel("H2"));
List<ItemModel> items = new ArrayList<>(2);
ItemModel item1 = new ItemModel("I1", "H1");
ItemModel item2 = new ItemModel("I2", "H2");
items.add(item1);
items.add(item2);
SectionableFactory sectionableFactory = new SectionableFactory(headers);
List<AbstractFlexibleItem> adapterItems = FlexibleItemProvider
.with(sectionableFactory)
.from(items);
assertTrue(adapterItems.get(0) instanceof ItemHolder);
assertEquals(items.size(), adapterItems.size());
assertEquals(item1, ((ItemHolder) adapterItems.get(0)).getModel());
assertEquals(item2, ((ItemHolder) adapterItems.get(1)).getModel());
assertEquals(headers.get("H1"), ((ItemHolder) adapterItems.get(0)).getHeader().getModel());
assertEquals(headers.get("H2"), ((ItemHolder) adapterItems.get(1)).getHeader().getModel());
}
开发者ID:davideas,项目名称:FlexibleAdapter,代码行数:25,代码来源:FlexibleFactoryTest.java
示例17: performFabAction
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@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);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:FragmentAnimators.java
示例18: onLoadMore
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
/**
* Loads more data.
* <p>Use {@code lastPosition} and {@code currentPage} to know what to load next.</p>
* {@code lastPosition} is the count of the main items without Scrollable Headers.
*
* @param lastPosition the position of the last main item in the adapter
* @param currentPage the current page
* @since 5.0.0-b6
* <br/>5.0.0-rc1 added {@code lastPosition} and {@code currentPage} as parameters
*/
@Override
public void onLoadMore(int lastPosition, int currentPage) {
Log.i(TAG, "onLoadMore invoked!");
// Simulating asynchronous call
new Handler().postDelayed(new Runnable() {
@SuppressWarnings("unchecked")
@Override
public void run() {
final List<AbstractFlexibleItem> newItems = new ArrayList<>(3);
// Simulating success/failure
int totalItemsOfType = mAdapter.getItemCountOfTypes(R.layout.recycler_instagram_item);
for (int i = 1; i <= 3; i++) {
newItems.add(DatabaseService.newInstagramItem(totalItemsOfType + i));
}
// Callback the Adapter to notify the change
// Items will be added to the end of the main list
mAdapter.onLoadMoreComplete(newItems);
Log.d(TAG, "newItemsSize=" + newItems.size());
Log.d(TAG, "EndlessCurrentPage=" + mAdapter.getEndlessCurrentPage());
Log.d(TAG, "EndlessPageSize=" + mAdapter.getEndlessPageSize());
Log.d(TAG, "EndlessTargetCount=" + mAdapter.getEndlessTargetCount());
// Notify user
if (getActivity() != null && newItems.size() > 0) {
Toast.makeText(getActivity(),
"Fetched " + newItems.size() + " new items",
Toast.LENGTH_SHORT).show();
}
}
}, 3000);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:44,代码来源:FragmentInstagramHeaders.java
示例19: ExampleAdapter
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
public ExampleAdapter(List<AbstractFlexibleItem> items, Object listeners) {
//stableIds ? true = Items implement hashCode() so they can have stableIds!
super(items, listeners, true);
//In case you need a Handler, do this:
//- Overrides the internal Handler with a custom callback that extends the internal one
mHandler = new Handler(Looper.getMainLooper(), new MyHandlerCallback());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:ExampleAdapter.java
示例20: updateDataSet
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; //导入依赖的package包/类
@Override
public void updateDataSet(List<AbstractFlexibleItem> items, boolean animate) {
// NOTE: To have views/items not changed, set them into "items" before passing the final
// list to the Adapter.
// Overwrite the list and fully notify the change, pass false to not animate changes.
// Watch out! The original list must a copy.
super.updateDataSet(items, animate);
// onPostUpdate() will automatically be called at the end of the Asynchronous update
// process. Manipulate the list inside that method only or you won't see the changes.
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:ExampleAdapter.java
注:本文中的eu.davidea.flexibleadapter.items.AbstractFlexibleItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论