How to merge new items with same Header
See original GitHub issueIf I use FlexibleAdapter with sticky Headers, how can I add new List of items to the adapter which may contain Header that is already in the list?
Like:
List<ISectionable> originalItems = new ArrayList();
IHeader headerA1 = new Header(1);
ISectionable itemA1 = new Item(A1);
itemA1.setHeader(headerA1);
originalItems.add(itemA1);
ISectionable itemA2 = new Item(12);
itemA2.setHeader(headerA1);
originalItems.add(itemA2);
// ...originalItems contains more Headers and items as well
FlexibleAdapter adapter = new FlexibleAdapter(originalItems);
// .. setup
List<ISectionable> newItems = new ArrayList();
IHeader headerB1 = new Header(1);
ISectionable itemB1 = new Item(B1);
itemB1.setHeader(headerB1);
newItems.add(itemB1);
// ...newItems contains more headers and items
// How to add newItems to the list to have only one Header(1)?
// Even though headerA1.equals(headerB1) is true, addItems() will result in a second Header(1) added to the list:
adapter.addItems(0, newItems);
So does FlexibleAdapter support some automatic merging of the headers that are equal or do I have to do that manually by using the correct references of the actual header objects? Either by using addItemToSection(), or with addItems() but with replacing headerB1 with headerA1 for the items in newItems before adding them.
Thanks.
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (8 by maintainers)
Top Results From Across the Web
How to merge multiple sheets with same headers in Excel?
1. Activate the workbook you want to merge the sheets, press Alt + F11 keys to open Microsoft Visual Basic for Applications window....
Read more >Solved: Merging Tables with same Headers
For the first part, you would use "Append Queries" rather than mergeing them. It is all the way on the right side of...
Read more >Combine Excel tables based on common headers - Ablebits
Combine Excel tables based on common headers · Start Combine Sheets · Step 1: Select worksheets and ranges to join · Step 2:...
Read more >Merge columns with same header containing split data
1 Answer 1 · Navigate to Tools > References · Scroll down and select Microsoft Scripting Runtime · Click anywhere inside the code...
Read more >How can I merge two or more tables? - Microsoft Support
Merge two tables using the VLOOKUP function · Copy the headings Sales ID and Region in the Orange table (only those two cells)....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We don’t really need a sorting and comparison because the items are provided in correct order by our API and I think the Comparator wouldn’t have helped, because as I come to understand the problem is simply that when adding items to a RecycerView to a postion which is visible, it of course shows them and pushes everything down. And because the IHeader was a visible item, adding anything under it naturally pushes the rest down. Only if items are added above it (at position 0), then RecyclerView adds them ‘outside’ of the screen. During trying out different ways to solve this, I finally ‘stumbled upon’ one that worked: simply removing the IHeader item before adding the new items.
This is how I do it now and seems to work:
I am afraid we don’t have time for checking it now thoroughly so I wouldn’t like to touch that code currently unless it’s necessary, to avoid getting bogged down or causing any side effects. But it’s good to hear that there were improvements and thanks for letting me know. I’ll keep in mind to update the version and check back on the workarounds when we need to touch that part of the code base again.
Feel free to close this issue of course, I will create a new one if I encounter anything later.