diff --git a/flexible-adapter-app/src/main/java/eu/davidea/samples/flexibleadapter/MainActivity.java b/flexible-adapter-app/src/main/java/eu/davidea/samples/flexibleadapter/MainActivity.java index f54c10cd..6051883f 100644 --- a/flexible-adapter-app/src/main/java/eu/davidea/samples/flexibleadapter/MainActivity.java +++ b/flexible-adapter-app/src/main/java/eu/davidea/samples/flexibleadapter/MainActivity.java @@ -482,6 +482,8 @@ public boolean onOptionsItemSelected(MenuItem item) { item.setTitle(R.string.mode_single); Snackbar.make(findViewById(R.id.main_view), "Selection MODE_IDLE is enabled", Snackbar.LENGTH_SHORT).show(); } + } else if (id == R.id.action_reset || id == R.id.action_delete) { + showFab(); } //TODO: Add toggle for mAdapter.toggleFastScroller(); //TODO: Add dialog configuration settings diff --git a/flexible-adapter-app/src/main/java/eu/davidea/samples/flexibleadapter/services/DatabaseService.java b/flexible-adapter-app/src/main/java/eu/davidea/samples/flexibleadapter/services/DatabaseService.java index d4f11154..d6a406ab 100644 --- a/flexible-adapter-app/src/main/java/eu/davidea/samples/flexibleadapter/services/DatabaseService.java +++ b/flexible-adapter-app/src/main/java/eu/davidea/samples/flexibleadapter/services/DatabaseService.java @@ -188,12 +188,18 @@ public void createStaggeredDatabase(Context context) { protected void createMergedItems() { //Simulating merged items - mergeItem((StaggeredItem) mItems.get(1), (StaggeredItem) mItems.remove(2)); - mergeItem((StaggeredItem) mItems.get(4), (StaggeredItem) mItems.remove(5)); - mergeItem((StaggeredItem) mItems.get(4), (StaggeredItem) mItems.remove(9)); - mergeItem((StaggeredItem) mItems.get(8), (StaggeredItem) mItems.remove(9)); - mergeItem((StaggeredItem) mItems.get(8), (StaggeredItem) mItems.remove(9)); - mergeItem((StaggeredItem) mItems.get(8), (StaggeredItem) mItems.remove(10)); + if (mItems.size() > 2) + mergeItem((StaggeredItem) mItems.get(1), (StaggeredItem) mItems.remove(2)); + if (mItems.size() > 5) + mergeItem((StaggeredItem) mItems.get(4), (StaggeredItem) mItems.remove(5)); + if (mItems.size() > 7) + mergeItem((StaggeredItem) mItems.get(4), (StaggeredItem) mItems.remove(7)); + if (mItems.size() > 8) + mergeItem((StaggeredItem) mItems.get(7), (StaggeredItem) mItems.remove(8)); + if (mItems.size() > 8) + mergeItem((StaggeredItem) mItems.get(7), (StaggeredItem) mItems.remove(8)); + if (mItems.size() > 9) + mergeItem((StaggeredItem) mItems.get(7), (StaggeredItem) mItems.remove(9)); } /*---------------*/ @@ -384,8 +390,8 @@ public void resetItems() { for (AbstractFlexibleItem item : mItems) { if (item instanceof StaggeredItem) { StaggeredItem staggeredItem = (StaggeredItem) item; - staggeredItem.setStatus(StaggeredItemStatus.A); - staggeredItem.setHeader(headers.get(StaggeredItemStatus.A)); + staggeredItem.setStatus(StaggeredItemStatus.C); + staggeredItem.setHeader(headers.get(StaggeredItemStatus.C)); mergedItems.addAll(staggeredItem.splitAllItems()); } } @@ -394,8 +400,7 @@ public void resetItems() { } mItems.addAll(mergedItems); Collections.sort(mItems, new ItemComparatorById()); - if (mItems.size() > 20) - createMergedItems(); + createMergedItems(); } public void mergeItem(StaggeredItem mainItem, StaggeredItem itemToMerge) {