Example usage for android.animation Animator setInterpolator

List of usage examples for android.animation Animator setInterpolator

Introduction

In this page you can find the example usage for android.animation Animator setInterpolator.

Prototype

public abstract void setInterpolator(TimeInterpolator value);

Source Link

Document

The time interpolator used in calculating the elapsed fraction of the animation.

Usage

From source file:Main.java

@TargetApi(21)
public static Animator circleReveal(View v, int centerX, int centerY, float startRadius, float endRadius,
        int duration) {
    Animator anim = ViewAnimationUtils.createCircularReveal(v, centerX, centerY, startRadius, endRadius);
    anim.setDuration(duration);//w  ww.  j a v  a 2  s. co  m
    anim.setInterpolator(mAccelerateInterpolator);
    anim.start();
    return anim;
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void show(final View view, final int cornerType, int normalAnimRes,
        final AnimatorListenerAdapter listener) {
    try {/*from   w  w w. j a  v a  2  s .com*/
        int[] amaya = calulateCorner(view, cornerType);
        Animator anim = ViewAnimationUtils.createCircularReveal(view, amaya[0], amaya[1], 0, amaya[2]);
        anim.setInterpolator(new LinearInterpolator());
        anim.setDuration(300);
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                view.setVisibility(View.VISIBLE);
                if (listener != null) {
                    listener.onAnimationStart(animation);
                }
            }

        });
        anim.start();
    } catch (Exception e) {
        e.printStackTrace();
        view.setVisibility(View.VISIBLE);
    }
}

From source file:im.ene.ribbon.AnimUtil.java

static void animate(BottomNavigationView parent, View view, final View backgroundOverlay,
        final ColorDrawable backgroundDrawable, final int newColor, long duration) {
    int centerX = (int) (ViewCompat.getX(view) + (view.getWidth() / 2));
    int centerY = parent.getPaddingTop() + view.getHeight() / 2;

    backgroundOverlay.clearAnimation();/*from ww w .jav a  2s .  c  o m*/

    final Object animator;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Animator currentAnimator = (Animator) backgroundOverlay.getTag(R.id.ribbon_background_overlay_animator);
        if (currentAnimator != null) {
            //currentAnimator.end();
            currentAnimator.cancel();
        }

        final float startRadius = 1;
        final float finalRadius = centerX > parent.getWidth() / 2 ? centerX : parent.getWidth() - centerX;
        animator = ViewAnimationUtils.createCircularReveal(backgroundOverlay, centerX, centerY, startRadius,
                finalRadius);
        backgroundOverlay.setTag(R.id.ribbon_background_overlay_animator, animator);
    } else {
        ViewCompat.setAlpha(backgroundOverlay, 0);
        animator = ViewCompat.animate(backgroundOverlay).alpha(1);
    }

    backgroundOverlay.setBackgroundColor(newColor);
    backgroundOverlay.setVisibility(View.VISIBLE);

    if (animator instanceof ViewPropertyAnimatorCompat) {
        ((ViewPropertyAnimatorCompat) animator).setListener(new ViewPropertyAnimatorListener() {
            boolean cancelled;

            @Override
            public void onAnimationStart(final View view) {
            }

            @Override
            public void onAnimationEnd(final View view) {
                if (!cancelled) {
                    backgroundDrawable.setColor(newColor);
                    backgroundOverlay.setVisibility(View.INVISIBLE);
                    ViewCompat.setAlpha(backgroundOverlay, 1);
                }
            }

            @Override
            public void onAnimationCancel(final View view) {
                cancelled = true;
            }
        }).setDuration(duration).start();
    } else {
        Animator animator1 = (Animator) animator;
        animator1.setDuration(duration);
        animator1.setInterpolator(new DecelerateInterpolator());
        animator1.addListener(new Animator.AnimatorListener() {
            boolean cancelled;

            @Override
            public void onAnimationStart(final Animator animation) {
            }

            @Override
            public void onAnimationEnd(final Animator animation) {
                if (!cancelled) {
                    backgroundDrawable.setColor(newColor);
                    backgroundOverlay.setVisibility(View.INVISIBLE);
                    ViewCompat.setAlpha(backgroundOverlay, 1);
                }
            }

            @Override
            public void onAnimationCancel(final Animator animation) {
                cancelled = true;
            }

            @Override
            public void onAnimationRepeat(final Animator animation) {
            }
        });

        animator1.start();
    }
}

From source file:Main.java

@NonNull
private static AnimatorSet createDisappearAnim(View startBtn, View pick1, View pick2, View image,
        View headline) {/*from  w  ww .  jav  a2s . c o m*/
    AnimatorSet animAll = new AnimatorSet();

    Animator anim1_1 = ObjectAnimator.ofFloat(headline, View.ALPHA, 1, 0);
    Animator anim1_2 = ObjectAnimator.ofFloat(startBtn, View.ALPHA, 1, 0);
    Animator anim1_3 = ObjectAnimator.ofFloat(startBtn, View.ALPHA, 1, 0);
    Animator anim1_4 = ObjectAnimator.ofFloat(pick1, View.ALPHA, 1, 0);
    Animator anim1_5 = ObjectAnimator.ofFloat(pick2, View.ALPHA, 1, 0);
    setBatchTiming(400, 0, anim1_1, anim1_2, anim1_3, anim1_4, anim1_5);
    animAll.play(anim1_1).with(anim1_2).with(anim1_3).with(anim1_4).with(anim1_5);

    Interpolator interpolator2 = new DecelerateInterpolator();
    Animator anim2_1 = ObjectAnimator.ofFloat(image, View.ALPHA, 1, 0);
    Animator anim2_2 = ObjectAnimator.ofFloat(image, View.SCALE_X, 1f, 2f);
    Animator anim2_3 = ObjectAnimator.ofFloat(image, View.SCALE_Y, 1f, 2f);
    anim2_1.setInterpolator(interpolator2);
    anim2_2.setInterpolator(interpolator2);
    anim2_3.setInterpolator(interpolator2);
    setBatchTiming(800, 0, anim2_1, anim2_2, anim2_3);
    animAll.play(anim2_1).with(anim2_2).with(anim2_3).after(anim1_1);
    return animAll;
}

From source file:Main.java

@NonNull
private static AnimatorSet createDisappearAnim(View btnPanel, View recyclerView, View locationTxt,
        View headline) {/*  w ww.  j a  v  a2s .c o  m*/
    AnimatorSet animAll = new AnimatorSet();

    Animator anim1_1 = ObjectAnimator.ofFloat(headline, View.ALPHA, 1, 0);
    Animator anim1_2 = ObjectAnimator.ofFloat(btnPanel, View.ALPHA, 1, 0);
    Animator anim1_3 = ObjectAnimator.ofFloat(btnPanel, View.ALPHA, 1, 0);
    Animator anim1_4 = ObjectAnimator.ofFloat(recyclerView, View.ALPHA, 1, 0);
    setBatchTiming(400, 0, anim1_1, anim1_2, anim1_3, anim1_4, anim1_4);
    animAll.play(anim1_1).with(anim1_2).with(anim1_3).with(anim1_4);

    Interpolator interpolator2 = new DecelerateInterpolator();
    Animator anim2_1 = ObjectAnimator.ofFloat(locationTxt, View.ALPHA, 1, 0);
    Animator anim2_2 = ObjectAnimator.ofFloat(locationTxt, View.SCALE_X, 1f, 2f);
    Animator anim2_3 = ObjectAnimator.ofFloat(locationTxt, View.SCALE_Y, 1f, 2f);
    anim2_1.setInterpolator(interpolator2);
    anim2_2.setInterpolator(interpolator2);
    anim2_3.setInterpolator(interpolator2);
    setBatchTiming(800, 0, anim2_1, anim2_2, anim2_3);
    animAll.play(anim2_1).with(anim2_2).with(anim2_3).after(anim1_1);
    return animAll;
}

From source file:com.google.samples.apps.ourstreets.view.ViewUtils.java

/**
 * Basically a reverse {@link #createCircularReveal(Point, int, View, Interpolator)}.
 *
 * @param center The center x and y coordinates of the final circle.
 * @param width The final width of the view's coordinates.
 * @param startView The view which will initially displayed.
 * @param interpolator The interpolator to use.
 * @return The created circular conceal.
 *///w w  w  .  ja va  2  s .  c  om
public static Animator createCircularConceal(@NonNull Point center, int width, @NonNull View startView,
        @NonNull Interpolator interpolator) {
    final Animator circularReveal = ViewAnimationUtils.createCircularReveal(startView, center.x, center.y,
            (float) Math.hypot(center.x, center.y), width);
    circularReveal.setInterpolator(interpolator);
    return circularReveal;
}

From source file:com.google.samples.apps.ourstreets.view.ViewUtils.java

/**
 * Create a simple circular reveal from a given start view to it's target view.
 * This reveal will start from the start view's boundaries until it fills the target view.
 *
 * @param center The center x and y coordinates of the start circle.
 * @param width The initial width of the view's coordinates.
 * @param targetView The target view which will be displayed once the reveal is done.
 * @param interpolator The interpolator to use.
 * @return The created circular reveal./*from w  ww  .j a va 2  s  .c o  m*/
 */
@NonNull
public static Animator createCircularReveal(@NonNull Point center, int width, @NonNull View targetView,
        @NonNull Interpolator interpolator) {
    final Animator circularReveal = ViewAnimationUtils.createCircularReveal(targetView, center.x, center.y,
            width, (float) Math.hypot(center.x, center.y));
    circularReveal.setInterpolator(interpolator);
    return circularReveal;
}

From source file:com.fastbootmobile.encore.utils.Utils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Animator animateCircleReveal(final View view, final int cx, final int cy, final int startRadius,
        final int endRadius, final long duration, final long startDelay) {
    Animator animator = ViewAnimationUtils.createCircularReveal(view, cx, cy, startRadius, endRadius)
            .setDuration(duration);/*from  w w  w .  ja v a  2  s . c o m*/
    animator.setStartDelay(startDelay);
    animator.setInterpolator(new DecelerateInterpolator());
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
            view.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (startRadius > endRadius) {
                view.setVisibility(View.INVISIBLE);
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    animator.start();

    return animator;
}

From source file:com.taobao.weex.ui.animation.WXAnimationModule.java

public static void startAnimation(WXSDKInstance mWXSDKInstance, WXComponent component,
        @NonNull WXAnimationBean animationBean, @Nullable String callback) {
    if (component == null) {
        return;//w  w w .j a  v  a 2  s  .c  o m
    }
    if (component.getHostView() == null) {
        AnimationHolder holder = new AnimationHolder(animationBean, callback);
        component.postAnimation(holder);
        return;
    }
    try {
        Animator animator = createAnimator(animationBean, component.getHostView(),
                mWXSDKInstance.getViewPortWidth());
        if (animator != null) {
            Animator.AnimatorListener animatorCallback = createAnimatorListener(mWXSDKInstance, callback);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
                component.getHostView().setLayerType(View.LAYER_TYPE_HARDWARE, null);
            }
            Interpolator interpolator = createTimeInterpolator(animationBean);
            if (animatorCallback != null) {
                animator.addListener(animatorCallback);
            }
            if (interpolator != null) {
                animator.setInterpolator(interpolator);
            }
            animator.setDuration(animationBean.duration);
            animator.start();
        }
    } catch (RuntimeException e) {
        e.printStackTrace();
        WXLogUtils.e("", e);
    }
}

From source file:android.support.designox.widget.FloatingActionButtonLollipop.java

private Animator setupAnimator(Animator animator) {
    animator.setInterpolator(mInterpolator);
    return animator;
}