plaid icon indicating copy to clipboard operation
plaid copied to clipboard

ConcurrentModificationException when ending animation

Open tunjid opened this issue 4 years ago • 0 comments

https://github.com/android/plaid/blob/1115fb60bbc870f296efe50471ad4746873f199e/core/src/main/java/io/plaidapp/core/ui/recyclerview/SlideInItemAnimator.kt#L183

In the endAnimations method, while in a for each loop, the function remove is called on a MutableList<RecyclerView.ViewHolder> which results in a ConcurrentModificationException :(

Substituting the forEach with the following resolves the issue:

    private inline fun <T> Iterable<T>.modifiableForEach(action: (T) -> Unit) {
        iterator().apply {
            while (hasNext()) next().apply(action)
        }
    }

tunjid avatar Sep 11 '19 03:09 tunjid