wirecube / android_additive_animations

Additive animations for Android!
Apache License 2.0
991 stars 72 forks source link

Provide Kotlin extensions #13

Closed turastory closed 5 years ago

turastory commented 5 years ago
AdditiveAnimator.animate(this)
    .addEndAction(object : AnimationEndListener() {
        override fun onAnimationEnd(wasCancelled: Boolean) {

        }
    })

Function above can be simplified using typealias and lambda.

typealias AnimationEndListener =
    (wasCancelled: Boolean) -> Unit

fun AdditiveAnimator.addEndAction(listener: AnimationEndListener) {
    addEndAction(object : AnimationEndListener() {
        override fun onAnimationEnd(wasCancelled: Boolean) {
            listener(wasCancelled)
        }
    })
}

// Use
AdditiveAnimator.animate(this)
    .addEndAction { wasCancelled ->

    }

Do you have any plans to do something like this? (Support Kotlin)

davidganster commented 5 years ago

Hi,

which version of the library are you using? The new syntax should already be supported via Java Lambdas since 1.7.1! Please let me know if upgrading to this version fixes this issue.

I just realized I didn't make an official release for that because I wanted to tidy something up – I'll fix that today and update the readme/releases for the latest version!

turastory commented 5 years ago

Yep, I used version 1.6.2. When I upgrade to 1.7.2 it fixes the issue.

And thanks for updates - visibility animations are pretty useful!