plaid
plaid copied to clipboard
Added modifiableForEach extension method that allows for in place ListModification during traversal
:loudspeaker: Type of change
- [x] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
:scroll: Description
Added modifiableForEach extension method that allows for in place List modification during traversal.
:bulb: Motivation and Context
Adresses #767
If the SlideInItemAnimator is running during an orientation change, a ConcurrentModificationException
will be thrown. This change allows for traversal with an iterator, allowing for in place modifications to the list.
:green_heart: How did you test it?
I used the animator in another project where the SlideInItemAnimator runs continuously, and triggered Activity destruction by rotating the phone. Source for that class is here: https://github.com/tunjid/android-bootstrap/blob/develop/app/src/main/java/com/tunjid/androidbootstrap/fragments/ShiftingTileFragment.kt
:pencil: Checklist
- [x] I ran
./gradlew spotlessApply
before submitting the PR - [x] I reviewed submitted code
- [ ] I added tests to verify changes
- [x] All tests passing
:crystal_ball: Next steps
:camera_flash: Screenshots / GIFs
Over to Nick since he's been working on the Animator.
@nickbutcher thanks for the comments! Are rebases preferred to merges when there are changes upstream? I checked the contributing doc, but it doesn't seem to mention it.
@tunjid rebase please. Thanks!
I'm not sure of a better name than removableForEach
, very much open to suggestions. I also narrowed the type on the extension to a MutableIterable
to better communicate intent.
Hmm, I can't think of a great name either and worry that removableForEach
implies that the action may remove an item. What about onEach
? It's similar enough to forEach
to convey what it does without suggesting extra behavior?
That works! What do you think about adding an iterator prefix so the mutable iterator backing is communicated? So iteratorOnEach
?