RxAnimator

Additional

Language
Java
Version
N/A
Created
Mar 9, 2017
Updated
Jan 4, 2018
Owner
Florent CHAMPIGNY (florent37)
Contributor
Florent CHAMPIGNY (florent37)
1
Activity
Badge
Generate
Download
Source code
APK file

Advertisement

RxAnimator

An RxJAva2 binding for android Animator

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

In your module

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

Credits

Author: Florent Champigny

#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.