You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im running the example App and on the "Headers and Sections" Screen,
if i delete a single item by a swipe to the right, an UnsupportedOperationException is raised.
FATAL EXCEPTION: main
Process: eu.davidea.samples.flexibleadapter, PID: 13125
java.lang.UnsupportedOperationException
at java.util.AbstractList.set(AbstractList.java:132)
at java.util.AbstractList$ListItr.set(AbstractList.java:426)
at java.util.Collections.sort(Collections.java:247)
at eu.davidea.flexibleadapter.FlexibleAdapter.removeItems(FlexibleAdapter.java:3324)
at eu.davidea.flexibleadapter.helpers.UndoHelper.performAction(UndoHelper.java:211)
at eu.davidea.flexibleadapter.helpers.UndoHelper.start(UndoHelper.java:198)
at eu.davidea.samples.flexibleadapter.MainActivity.onItemSwipe(MainActivity.java:791)
at eu.davidea.flexibleadapter.FlexibleAdapter.onItemSwiped(FlexibleAdapter.java:4672)
at eu.davidea.flexibleadapter.helpers.ItemTouchHelperCallback.onSwiped(ItemTouchHelperCallback.java:249)
Checking the size of the items positions list seems to fix the issue.
`
if (selectedPositions.size() >= 2) {
// Reverse-sort the list, start from last position for efficiency
Collections.sort(selectedPositions, new Comparator<Integer>() {
@Override
public int compare(Integer lhs, Integer rhs) {
return rhs - lhs;
}
});
log.v("removeItems after reverse sort selectedPositions=%s", selectedPositions);
}`
The text was updated successfully, but these errors were encountered:
Thanks @ni-ku, it is caused because of the singletonList, created in MainActivity, is an immutable list. However, I will put also that check. The issue remains if the list is immutable with more than 1 item, but then the exception is correct.
This will be a small improvement and not a bug.
Im running the example App and on the "Headers and Sections" Screen,
if i delete a single item by a swipe to the right, an UnsupportedOperationException is raised.
Checking the size of the items positions list seems to fix the issue.
`
The text was updated successfully, but these errors were encountered: