/RxAnimator

An RxJava2 binding for android Animator

Primary LanguageJavaApache License 2.0Apache-2.0

RxAnimator

An RxJAva2 binding for android Animator

Android app on Google Play

Run sequencially

RxAnimator.ofFloat(view, "translationY", 0, 300).animationDuration(500)
          .flatMap(anim -> RxAnimator.ofFloat(view, "translationX", 0, 300))
          .subscribe(anim -> {});

RxAnimator contains the same methods as ValueAnimator`

.animationDuration(long)

.animationStartDelay(long)

.animationInterpolator(interpolator)

.animationEvaluator(evaluator)

...

Run in parallel

(Using RxBindings for the click observable)

RxView.clicks(view)
          .flatMap(animation ->
                  Observable.zip(
                          RxAnimator.ofFloat(view, "scaleX", 5),
                          RxAnimator.ofFloat(view, "scaleY", 5),
                          RxAnimator.ofFloat(view, "translationY", 300),
                          RxAnimator.ofFloat(view, "translationX", 200),
                          (a, a2, a3, a4) -> a
                  )
          )
          .flatMap(animation ->
                  Observable.zip(
                          RxAnimator.ofFloat(view, "scaleX", 1),
                          RxAnimator.ofFloat(view, "scaleY", 1),
                          RxAnimator.ofFloat(view, "translationX", 0),
                          RxAnimator.ofFloat(view, "translationY", 0),
                          (a, a2, a3, a4) -> a
                  )
          )
          .subscribe(animation -> {});

Trigger event

By default the observable submits when the animator ends You can configure it using .animationTriggerEvent(Event.START / Event.END / Event.CANCEL / EVENT.RESTART)

Download

Buy Me a Coffee at ko-fi.com

In your module Download

compile 'com.github.florent37:rxanimator:1.0.0'

Credits

Author: Florent Champigny

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

#License

Copyright 2017 florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.