Example usage for android.animation AnimatorSet setInterpolator

List of usage examples for android.animation AnimatorSet setInterpolator

Introduction

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

Prototype

@Override
public void setInterpolator(TimeInterpolator interpolator) 

Source Link

Document

Sets the TimeInterpolator for all current #getChildAnimations() child animations of this AnimatorSet.

Usage

From source file:Main.java

@NonNull
public static AnimatorSet getAnimatorSet(long duration, Interpolator interpolator) {
    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(duration);/* w  w w .j  ava  2s . co  m*/
    if (interpolator != null) {
        animatorSet.setInterpolator(interpolator);
    }
    return animatorSet;
}

From source file:Main.java

public static void animateScaleIn(View view, long duration, Animator.AnimatorListener listener) {
    view.setScaleX(0f);//from   w w  w.  jav a2  s.  c  o m
    view.setScaleY(0f);
    view.setVisibility(View.VISIBLE);

    AnimatorSet scaleSet = new AnimatorSet();
    scaleSet.playTogether(ObjectAnimator.ofFloat(view, View.SCALE_X, 1f),
            ObjectAnimator.ofFloat(view, View.SCALE_Y, 1f));
    scaleSet.setInterpolator(new AccelerateDecelerateInterpolator());
    scaleSet.setDuration(duration);
    if (listener != null) {
        scaleSet.addListener(listener);
    }
    scaleSet.start();
    //return scaleSet;
}

From source file:com.chromium.fontinstaller.util.ViewUtils.java

public static void reveal(Activity activity, View view, View sourceView, int colorRes) {
    if (activity == null || view == null || sourceView == null)
        return;/*from  w  ww . j av a  2  s .  com*/
    if (isLollipop()) {
        final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) activity.getWindow().getDecorView()
                .getOverlay();

        final Rect displayRect = new Rect();
        view.getGlobalVisibleRect(displayRect);

        // Make reveal cover the display and status bar.
        final View revealView = new View(activity);
        revealView.setTop(displayRect.top);
        revealView.setBottom(displayRect.bottom);
        revealView.setLeft(displayRect.left);
        revealView.setRight(displayRect.right);
        revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes));
        groupOverlay.add(revealView);

        final int[] clearLocation = new int[2];
        sourceView.getLocationInWindow(clearLocation);
        clearLocation[0] += sourceView.getWidth() / 2;
        clearLocation[1] += sourceView.getHeight() / 2;

        final int revealCenterX = clearLocation[0] - revealView.getLeft();
        final int revealCenterY = clearLocation[1] - revealView.getTop();

        final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
        final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
        final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
        final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

        try {
            final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX,
                    revealCenterY, 0.0f, revealRadius);
            revealAnimator
                    .setDuration(activity.getResources().getInteger(android.R.integer.config_mediumAnimTime));

            final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
            alphaAnimator
                    .setDuration(activity.getResources().getInteger(android.R.integer.config_shortAnimTime));
            alphaAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in));
                    view.setVisibility(View.VISIBLE);
                }
            });

            final AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.play(revealAnimator).before(alphaAnimator);
            animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
            animatorSet.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    groupOverlay.remove(revealView);
                }
            });

            animatorSet.start();
        } catch (IllegalStateException e) {
            Timber.i("View is detached - not animating");
        }
    } else {
        view.setVisibility(View.VISIBLE);
    }
}

From source file:cn.edu.zucc.list.FabAnimation.MorphDialogToFab.java

@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
        TransitionValues endValues) {//  w w  w .j  av  a  2  s .  co  m
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius);

    // hide child views (offset down & fade out)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L)
                    .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(),
                            android.R.interpolator.fast_out_linear_in))
                    .start();
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setInterpolator(
            AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    transition.setDuration(300);
    return transition;
}

From source file:com.liyu.huahui.ui.widgets.MorphDialogToFab.java

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override/*  w  ww .ja  v a  2 s  . c  om*/
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
        TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius);

    // hide child views (offset down & fade out)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L)
                    .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(),
                            android.R.interpolator.fast_out_linear_in))
                    .start();
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setInterpolator(
            AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    transition.setDuration(300);
    return transition;
}

From source file:com.wolski_msk.collector.sample.transition.MorphDialogToFab.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override/*from   w  ww.ja  v  a2  s  . com*/
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
        TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius);

    // hide child views (offset down & fade out)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L)
                    .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(),
                            android.R.interpolator.fast_out_linear_in))
                    .start();
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setInterpolator(
            AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    transition.setDuration(300);
    return transition;
}

From source file:com.metinkale.prayerapp.compass._2D.Frag2D.java

public void show() {
    mHidden = false;/*from w w w . ja  v a2s. c  om*/
    mCompassView.post(new Runnable() {
        @Override
        public void run() {
            ObjectAnimator scaleX = ObjectAnimator.ofFloat(mCompassView, "scaleX", 0, 1);
            ObjectAnimator scaleY = ObjectAnimator.ofFloat(mCompassView, "scaleY", 0, 1);

            ObjectAnimator scaleX2 = ObjectAnimator.ofFloat(mInfo, "scaleX", 0, 1);
            ObjectAnimator scaleY2 = ObjectAnimator.ofFloat(mInfo, "scaleY", 0, 1);
            AnimatorSet animSetXY = new AnimatorSet();
            animSetXY.playTogether(scaleX, scaleY, scaleX2, scaleY2);
            animSetXY.setInterpolator(overshootInterpolator);
            animSetXY.setDuration(300);
            animSetXY.start();
        }
    });

}

From source file:com.metinkale.prayerapp.compass._2D.Frag2D.java

public void hide() {
    mHidden = true;//w  w  w.  j  a  va 2s  .c  o m
    mCompassView.post(new Runnable() {
        @Override
        public void run() {
            ObjectAnimator scaleX = ObjectAnimator.ofFloat(mCompassView, "scaleX", 1, 0);
            ObjectAnimator scaleY = ObjectAnimator.ofFloat(mCompassView, "scaleY", 1, 0);

            ObjectAnimator scaleX2 = ObjectAnimator.ofFloat(mInfo, "scaleX", 1, 0);
            ObjectAnimator scaleY2 = ObjectAnimator.ofFloat(mInfo, "scaleY", 1, 0);

            AnimatorSet animSetXY = new AnimatorSet();
            animSetXY.playTogether(scaleX, scaleY, scaleX2, scaleY2);
            animSetXY.setInterpolator(accelerateInterpolator);
            animSetXY.setDuration(300);
            animSetXY.start();
        }
    });

}

From source file:com.hitherejoe.animate.util.MorphButtonToDialog.java

@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
        final TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null)
        return null;

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);

    if (startColor == null || endColor == null)
        return null;

    MorphDrawable background = new MorphDrawable(startColor, 0);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor);

    // ease in the dialog's child views (slide up & fade_fast in)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        float offset = vg.getHeight() / 3;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.setTranslationY(offset);//from w  ww  .  ja v  a  2  s.c  o  m
            v.setAlpha(0f);
            v.animate().alpha(1f).translationY(0f).setDuration(150).setStartDelay(150).setInterpolator(
                    AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_slow_in));
            offset *= 1.8f;
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, color);
    transition.setDuration(300);
    transition.setInterpolator(
            AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    return transition;
}

From source file:com.angelatech.yeyelive.view.PeriscopeLayout.java

private AnimatorSet getEnterAnimtor(final View target) {
    ObjectAnimator alpha = ObjectAnimator.ofFloat(target, View.ALPHA, 0.2f, 1f);
    ObjectAnimator scaleX = ObjectAnimator.ofFloat(target, View.SCALE_X, 0.2f, 1f);
    ObjectAnimator scaleY = ObjectAnimator.ofFloat(target, View.SCALE_Y, 0.2f, 1f);
    AnimatorSet enter = new AnimatorSet();
    enter.setDuration(500);//w w  w. j a va  2 s.  com
    enter.setInterpolator(new LinearInterpolator());
    enter.playTogether(alpha, scaleX, scaleY);
    enter.setTarget(target);
    return enter;
}