android-ktx icon indicating copy to clipboard operation
android-ktx copied to clipboard

Return receiver for AnimatorListener-related extensions

Open jlnstrk opened this issue 7 years ago • 1 comments

Usually we construct animators starting with a call to e.g. ValueAnimator#ofXY, continuing with configuration in builder style - because the api allows it. Until now, and also with the current KTX implementation, this builder would get broken as soon as we want to attach an AnimatorListener (or even an AnimatorUpdateListener for ValueAnimator), making code look super ugly.

Instead of returning the AnimatorListener that we passed in the very same statement (which makes it kinda redundant), we could return the function receiver, the Animator we're adding our listener to, in order to maintain builder flow.

jlnstrk avatar Feb 05 '18 20:02 jlnstrk

I noticed that too. I think the purpose might be to allow you to remove the listener if you want. I just wrap the call in an apply {} block.

carlosefonseca avatar Feb 06 '18 10:02 carlosefonseca