Search in sources :

Example 26 with TimeInterpolator

use of android.animation.TimeInterpolator in project assertj-android by square.

the class AbstractAnimatorAssert method hasInterpolator.

@TargetApi(JELLY_BEAN_MR2)
public S hasInterpolator(TimeInterpolator interpolator) {
    isNotNull();
    TimeInterpolator actualInterpolator = actual.getInterpolator();
    // 
    assertThat(actualInterpolator).overridingErrorMessage("Expected interpolator <%s> but was <%s>.", interpolator, // 
    actualInterpolator).isEqualTo(interpolator);
    return myself;
}
Also used : TimeInterpolator(android.animation.TimeInterpolator) TargetApi(android.annotation.TargetApi)

Example 27 with TimeInterpolator

use of android.animation.TimeInterpolator in project assertj-android by square.

the class KeyframeAssert method hasInterpolator.

public KeyframeAssert hasInterpolator(TimeInterpolator interpolator) {
    isNotNull();
    TimeInterpolator actualInterpolator = actual.getInterpolator();
    // 
    assertThat(actualInterpolator).overridingErrorMessage("Expected interpolator <%s> but was <%s>.", interpolator, // 
    actualInterpolator).isSameAs(interpolator);
    return this;
}
Also used : TimeInterpolator(android.animation.TimeInterpolator)

Example 28 with TimeInterpolator

use of android.animation.TimeInterpolator in project TransitionPlayer by linfaxin.

the class ChromeHomeDemo method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.demo_chrome_home);
    swipeLayout = (SwipeLayout) findViewById(R.id.swipeLayout);
    swipeLayout.getDragEdgeMap().clear();
    swipeLayout.addDrag(SwipeLayout.DragEdge.Top, swipeLayout.getChildAt(0));
    swipeLayout.addRevealListener(R.id.placeHolder, new SwipeLayout.OnRevealListener() {

        @Override
        public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
            transitionPlayer.setCurrentFraction(fraction);
        }
    });
    swipeLayout.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            swipeLayout.getViewTreeObserver().removeOnPreDrawListener(this);
            ViewGroup mSceneRoot = (ViewGroup) findViewById(R.id.sceneRootView);
            Scene scene = Scene.getSceneForLayout(mSceneRoot, R.layout.chrome_home_head_state_expand, ChromeHomeDemo.this);
            transitionPlayer.setPlayControl(new ModifyAnimatorsPlayControl() {

                @Override
                protected Animator onModifyAnimator(Transition transition, ValueAnimator animator) {
                    if (!(animator instanceof ObjectAnimator))
                        return animator;
                    Object target = ((ObjectAnimator) animator).getTarget();
                    if (!(target instanceof View))
                        return animator;
                    View targetView = (View) target;
                    // input view
                    if (targetView.getId() == R.id.editText) {
                        if (transition instanceof ChangeBounds) {
                            AnimatorSet animatorSet = new AnimatorSet();
                            for (ValueAnimator subAnimator : AnimatorUtils.splitAnimatorByValues(animator)) {
                                animatorSet.playTogether(subAnimator);
                                // let input view fast animate to right edge
                                if (subAnimator instanceof ObjectAnimator && "right".equals(((ObjectAnimator) subAnimator).getPropertyName())) {
                                    MultiTimeInterpolator multi = new MultiTimeInterpolator();
                                    TimeInterpolator i = animator.getInterpolator();
                                    multi.addInterpolator(i, 6);
                                    LockEndTimeInterpolator end = new LockEndTimeInterpolator(i);
                                    multi.addInterpolator(end, 4);
                                    subAnimator.setInterpolator(multi);
                                }
                            }
                            return animatorSet;
                        } else if (transition instanceof ChangeTextColor) {
                            TimeInterpolator i = animator.getInterpolator();
                            LockEndTimeInterpolator end = new LockEndTimeInterpolator(i);
                            ReverseTimeInterpolator r = new ReverseTimeInterpolator(i);
                            animator.setInterpolator(new MultiTimeInterpolator(i, end, r));
                        }
                    }
                    // logo view
                    if (targetView.getId() == R.id.imageView && transition instanceof ChangeAlpha) {
                        MultiTimeInterpolator multi = new MultiTimeInterpolator();
                        TimeInterpolator i = new DecelerateInterpolator(1.6f);
                        TimeInterpolator start = new LockStartTimeInterpolator(i);
                        multi.addInterpolator(start, 4);
                        multi.addInterpolator(i, 6);
                        animator.setInterpolator(multi);
                    }
                    return animator;
                }
            });
            TransitionManager.go(scene, transitionPlayer);
            // after start transition, then init click.
            mSceneRoot.findViewById(R.id.editText).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    swipeLayout.close();
                }
            });
            return false;
        }
    });
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AnimatorSet(android.animation.AnimatorSet) ChangeTextColor(com.linfaxin.transitionplayer.transitions.ChangeTextColor) ValueAnimator(android.animation.ValueAnimator) ChangeAlpha(com.linfaxin.transitionplayer.transitions.ChangeAlpha) LockStartTimeInterpolator(com.linfaxin.transitionplayer.interpolators.LockStartTimeInterpolator) LockEndTimeInterpolator(com.linfaxin.transitionplayer.interpolators.LockEndTimeInterpolator) SwipeLayout(com.daimajia.swipe.SwipeLayout) ViewTreeObserver(android.view.ViewTreeObserver) ViewGroup(android.view.ViewGroup) ObjectAnimator(android.animation.ObjectAnimator) ChangeBounds(android.transitions.everywhere.ChangeBounds) Scene(android.transitions.everywhere.Scene) View(android.view.View) TimeInterpolator(android.animation.TimeInterpolator) ReverseTimeInterpolator(com.linfaxin.transitionplayer.interpolators.ReverseTimeInterpolator) MultiTimeInterpolator(com.linfaxin.transitionplayer.interpolators.MultiTimeInterpolator) LockEndTimeInterpolator(com.linfaxin.transitionplayer.interpolators.LockEndTimeInterpolator) LockStartTimeInterpolator(com.linfaxin.transitionplayer.interpolators.LockStartTimeInterpolator) ReverseTimeInterpolator(com.linfaxin.transitionplayer.interpolators.ReverseTimeInterpolator) MultiTimeInterpolator(com.linfaxin.transitionplayer.interpolators.MultiTimeInterpolator) ModifyAnimatorsPlayControl(com.linfaxin.transitionplayer.control.ModifyAnimatorsPlayControl) Transition(android.transitions.everywhere.Transition)

Example 29 with TimeInterpolator

use of android.animation.TimeInterpolator in project TransitionPlayer by linfaxin.

the class TransitionPlayer method runAnimators.

@Override
protected void runAnimators() {
    reflectSetupStartEndListeners();
    animMap.clear();
    for (int i = 0, count = getTransitionCount(); i < count; i++) {
        Transition transition = getTransitionAt(i);
        ArrayList<ValueAnimator> valueAnimators = new ArrayList<>();
        for (Animator animator : AnimatorUtils.collectAnimators(transition)) {
            valueAnimators.addAll(AnimatorUtils.collectValueAnimators(animator));
        }
        // insure animator's duration, startDelay, Interpolator same as this transition
        long duration = (long) (getDuration() / AnimatorUtils.getAnimatorDurationScale());
        long startDelay = getStartDelay();
        TimeInterpolator interpolator = getInterpolator();
        for (ValueAnimator animator : valueAnimators) {
            if (duration >= 0)
                animator.setDuration(duration);
            if (startDelay >= 0)
                animator.setStartDelay(startDelay + animator.getStartDelay());
            if (interpolator != null)
                animator.setInterpolator(interpolator);
        }
        animMap.put(transition, valueAnimators);
        // you can change transition's duration, startDelay and Interpolator at here
        if (playControl != null)
            playControl.onPreRunAnimator(transition, valueAnimators);
    }
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) Transition(android.transitions.everywhere.Transition) ChangeTransition(com.linfaxin.transitionplayer.transitions.ChangeTransition) ArrayList(java.util.ArrayList) ValueAnimator(android.animation.ValueAnimator) TimeInterpolator(android.animation.TimeInterpolator)

Aggregations

TimeInterpolator (android.animation.TimeInterpolator)29 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)14 ValueAnimator (android.animation.ValueAnimator)10 ObjectAnimator (android.animation.ObjectAnimator)8 Animator (android.animation.Animator)5 Rect (android.graphics.Rect)5 View (android.view.View)5 NameValuesHolder (android.view.ViewPropertyAnimator.NameValuesHolder)5 FallbackLUTInterpolator (com.android.internal.view.animation.FallbackLUTInterpolator)5 ArrayList (java.util.ArrayList)4 AnimatorListener (android.animation.Animator.AnimatorListener)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 AnimatorSet (android.animation.AnimatorSet)3 PropertyValuesHolder (android.animation.PropertyValuesHolder)3 Resources (android.content.res.Resources)3 ViewConfiguration (android.view.ViewConfiguration)3 ViewGroup (android.view.ViewGroup)3 TargetApi (android.annotation.TargetApi)2 Transition (android.transitions.everywhere.Transition)2 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)2