Example usage for android.animation Animator start

List of usage examples for android.animation Animator start

Introduction

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

Prototype

public void start() 

Source Link

Document

Starts this animation.

Usage

From source file:com.adkdevelopment.earthquakesurvival.utils.Utilities.java

/**
 * Animates RecyclerView card on click with revealing effect
 * @param viewHolder to make animation on
 *///www.  j  a va 2 s  .c  o m
public static void animationCard(RecyclerView.ViewHolder viewHolder) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        if (mBlueColor == 0) {
            mBlueColor = ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.colorPrimary);
        }
        if (mWhiteColor == 0) {
            mWhiteColor = ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.white);
        }

        int finalRadius = (int) Math.hypot(viewHolder.itemView.getWidth() / 2,
                viewHolder.itemView.getHeight() / 2);

        Animator anim = ViewAnimationUtils.createCircularReveal(viewHolder.itemView,
                viewHolder.itemView.getWidth() / 2, viewHolder.itemView.getHeight() / 2, 0, finalRadius);

        viewHolder.itemView.setBackgroundColor(mBlueColor);
        anim.start();
        anim.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

            }

            @Override
            public void onAnimationEnd(Animator animation) {
                viewHolder.itemView.setBackgroundColor(mWhiteColor);
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
    }
}

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 {//w ww .  j a  va  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:Main.java

public static void enterReveal(final View view) {
    view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override//from   ww  w.  ja va 2  s.  c om
        public void onGlobalLayout() {
            Animator animator = null;

            view.getViewTreeObserver().removeOnGlobalLayoutListener(this);

            int cx = view.getMeasuredWidth() / 2;
            int cy = view.getMeasuredHeight() / 2;

            try {
                final int finalRadius = Math.max(view.getWidth(), view.getHeight()) / 2 + 125;
                animator = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);

                animator.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                    }
                });
            } catch (Exception ignored) {
            }

            view.setVisibility(View.VISIBLE);
            if (animator != null) {
                animator.start();
            }
        }
    });
}

From source file:Main.java

public static void circleReveal(final View targetView, int centerX, int centerY, boolean isReverse) {
    if (targetView == null || !targetView.isAttachedToWindow())
        return;/*from   w w  w . ja va2s . c  om*/
    int radius = (int) Math.hypot(targetView.getHeight(), targetView.getWidth());

    Animator animator;
    if (isReverse) {
        animator = isCircleRevealSupported()
                ? ViewAnimationUtils.createCircularReveal(targetView, centerX, centerY, radius, 0)
                : createFade(targetView, 1, 0);
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                targetView.setVisibility(View.GONE);
            }
        });
    } else {
        animator = isCircleRevealSupported()
                ? ViewAnimationUtils.createCircularReveal(targetView, centerX, centerY, 0, radius)
                : createFade(targetView, 0, 1);
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
                targetView.setVisibility(View.VISIBLE);
            }
        });
    }
    animator.setDuration(DURATION);
    animator.start();
}

From source file:ooo.oxo.apps.materialize.SearchPanelController.java

public void open() {
    if (container.getVisibility() == View.VISIBLE) {
        return;//from  www.  j  av  a2  s .c  om
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Animator animator = makeSearchPanelAnimator(false);
        container.setVisibility(View.VISIBLE);
        animator.start();
    } else {
        container.setVisibility(View.VISIBLE);
    }

    keyword.requestFocus();

    softInputManager.show();
}

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  w  ww  . j  a va  2  s.  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:com.syncedsynapse.kore2.utils.UIUtils.java

/**
 * Launches the remote activity, performing a circular reveal animation if
 * Lollipop or later//from w w w.ja  v  a2 s  .c o  m
 *
 * @param context Context
 * @param centerX Center X of the animation
 * @param centerY Center Y of the animation
 * @param exitTransitionView View to reveal. Should occupy the whole screen and
 *                           be invisible before calling this
 */
@TargetApi(21)
public static void switchToRemoteWithAnimation(final Context context, int centerX, int centerY,
        final View exitTransitionView) {
    final Intent launchIntent = new Intent(context, RemoteActivity.class);
    if (Utils.isLollipopOrLater()) {
        // Show the animation
        int endRadius = Math.max(exitTransitionView.getHeight(), exitTransitionView.getWidth());
        Animator exitAnim = ViewAnimationUtils.createCircularReveal(exitTransitionView, centerX, centerY, 0,
                endRadius);

        exitAnim.setDuration(200);
        exitAnim.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                // Launch remote activity
                context.startActivity(launchIntent);
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }
        });
        exitTransitionView.setVisibility(View.VISIBLE);
        exitAnim.start();
    } else {
        // No animation show, just launch the remote
        context.startActivity(launchIntent);
    }
}

From source file:org.deviceconnect.android.deviceplugin.linking.setting.fragment.LinkingHelpFragment.java

private void createAnimation(final View v) {
    float size = 12.0f * getResources().getDisplayMetrics().density;
    long time = 1000;

    List<Animator> animatorList = new ArrayList<>();

    ObjectAnimator fadeIn = ObjectAnimator.ofFloat(v, "translationY", -size, 0);
    fadeIn.setDuration(time);// w w  w  .  ja  va  2 s  . co  m
    animatorList.add(fadeIn);

    ObjectAnimator fadeOut = ObjectAnimator.ofFloat(v, "translationY", 0, -size);
    fadeOut.setDuration(time);
    animatorList.add(fadeOut);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playSequentially(animatorList);
    animatorSet.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mDestroy) {
                animation.start();
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    animatorSet.start();
}

From source file:org.hawkular.client.android.util.ViewTransformer.java

@UiThread
public void show() {
    Animator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    animator.setDuration(Durations.MEDIUM);

    animator.start();
}

From source file:org.hawkular.client.android.util.ViewTransformer.java

@UiThread
public void hide() {
    Animator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 1, 0);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    animator.setDuration(Durations.MEDIUM);

    animator.start();
}