SubItem is placed under wrong header after change of item
See original GitHub issueI have a list with sticky headers.
After inital load I have two headers: OVERDUE
- “Test 3” with date yesterday
- “Today 8” with date yesterday
TODAY
- “Test 4” with date today
- “Test 5” with date today
- “Test 6” with date today
Now I edit the item “Test 4” and change the date to yesterday. The data will be fetched again from the database and I create the list for the adapter.
The list will be added to the adapter with “updateDataSet” and the list contains this items as of my logs.:
Creating new HeaderItem: Overdue Adding SubItem 3/Test 4 to Header Overdue Adding SubItem 2/Test 3 to Header Overdue Adding SubItem 7/Today 8 to Header Overdue Adding HeaderItem to list: Overdue
Creating new HeaderItem: Today Adding SubItem 4/Test 5 to Header Today Adding SubItem 5/Test 6 to Header Today Adding HeaderItem to list: Today
Reminder List contains 2 items!
Seems all correct and the edited item is also updated with the correct date, BUT the list looks now like this: OVERDUE
- “Test 3” with date yesterday
- “Today 8” with date yesterday
TODAY
- “Test 4” with date yesterday
- “Test 5” with date today
- “Test 6” with date today
So did I miss something? Do I need a refresh of the headers or something?
For the HeaderItem I extend AbstractExpandableHeaderItem. For the SubItems I extend AbstractSectionableItem.
After restart of the app the list is again correct.
Update: Here the logs from FlexibleAdapter. Seems also correct as of the logs:
09-05 08:02:23.546 21953-21953/com.colapps.reminder V/FlexibleAdapter: onViewBound Holder=ActiveReminderHeaderViewHolder position=0 itemId=573358208
09-05 08:02:23.551 21953-21953/com.colapps.reminder V/FlexibleAdapter: onViewBound Holder=ActiveRemindersViewHolder position=1 itemId=50
09-05 08:02:23.569 21953-21953/com.colapps.reminder V/FlexibleAdapter: onViewBound Holder=ActiveRemindersViewHolder position=2 itemId=55
09-05 08:02:23.572 21953-21953/com.colapps.reminder V/FlexibleAdapter: onViewBound Holder=ActiveReminderHeaderViewHolder position=3 itemId=80981793
09-05 08:02:23.573 21953-21953/com.colapps.reminder V/FlexibleAdapter: onViewBound Holder=ActiveRemindersViewHolder position=4 itemId=51
09-05 08:02:23.577 21953-21953/com.colapps.reminder V/FlexibleAdapter: onViewBound Holder=ActiveRemindersViewHolder position=5 itemId=52
09-05 08:02:23.601 21953-21953/com.colapps.reminder V/FlexibleAdapter: onViewBound Holder=ActiveRemindersViewHolder position=6 itemId=53
Another Update: If I collapse “Today” the item “Test 4” is now listed at the bottom. If I collapse “Overdue” and expand it again the item “Test 4” is now correctly displayed under “Overdue”.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Ok thanks for your great support and your awesome library!
@chrisonline,
equals
is used by Collections based on List,hashCode
by Collections based on Hash, necessary to identify the item during the scan to pick it up / remove / update etc… But this is Java concept. In the Adapter both collections are used.I’ve added a method
IFlexible.shouldNotifyChange(newItem)
(similar to DiffUtil concept) that checks if the Item must be really updated or skipped, inside there you can evaluate all the others fields. By default it returnstrue
.The cursor should return only the Expandables as per requirement explained in the Wiki headers and sections. So you have to move the subItem from the subList in order to add it to the other subList before providing the newList of only expandables to the adapter.