Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.dynamicanimation.animation.SpringAnimation.TRANSLATION_Y
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.RecyclerView
import io.plaidapp.core.util.listenForAllSpringsEnd
import io.plaidapp.core.util.onEach
import io.plaidapp.core.util.spring

/**
Expand Down Expand Up @@ -108,10 +109,10 @@ open class SlideInItemAnimator @JvmOverloads constructor(
}

override fun endAnimations() {
pendingAdds.forEach(::endPendingAdd)
runningAdds.forEach(::endRunningAdd)
pendingMoves.forEach(::endPendingMove)
runningMoves.forEach(::endRunningMove)
pendingAdds.onEach(::endPendingAdd)
runningAdds.onEach(::endRunningAdd)
pendingMoves.onEach(::endPendingMove)
runningMoves.onEach(::endRunningMove)
super.endAnimations()
}

Expand Down
9 changes: 9 additions & 0 deletions core/src/main/java/io/plaidapp/core/util/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ package io.plaidapp.core.util
*/
val <T> T.exhaustive: T
get() = this

/**
* A for each loop where traversal is backed by an [MutableIterator] allowing for removal
* during iteration.
*/
inline fun <T> MutableIterable<T>.onEach(action: (T) -> Unit) {
val iterator = iterator()
while (iterator.hasNext()) action(iterator.next())
}