Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bace2241 authored by Joshua Tsuji's avatar Joshua Tsuji
Browse files

Filter end actions for null, and allow Runnables from Java

Test: atest SystemUITests
Change-Id: I7521937000b624621275670472a49cccdab29d78
parent 4ce22b51
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -367,8 +367,17 @@ class PhysicsAnimator<T> private constructor (val target: T) {
     * animation is explicitly canceled, use [addEndListener]. End listeners have an allEnded param,
     * which indicates that all relevant animations have ended.
     */
    fun withEndActions(vararg endActions: EndAction): PhysicsAnimator<T> {
        this.endActions.addAll(endActions)
    fun withEndActions(vararg endActions: EndAction?): PhysicsAnimator<T> {
        this.endActions.addAll(endActions.filterNotNull())
        return this
    }

    /**
     * Helper overload so that callers from Java can use Runnables or method references as end
     * actions without having to explicitly return Unit.
     */
    fun withEndActions(vararg endActions: Runnable?): PhysicsAnimator<T> {
        this.endActions.addAll(endActions.filterNotNull().map { it::run })
        return this
    }