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.destin.sehaikun.AnimationUtils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void reveal(View view, int centerX, int centerY, float startRadius, float endRadius,
        Animator.AnimatorListener listener) {
    Animator animator = ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius);
    animator.setDuration(ANIMATION_DURATION_MEDIUM);
    if (listener != null) {
        animator.addListener(listener);/*from  ww  w.j  a  v a2 s.  com*/
    }
    animator.start();
}

From source file:com.andryr.guitartuner.Utils.java

public static void reveal(View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // get the center for the clipping circle
        int cx = view.getWidth() / 2;
        int cy = view.getHeight() / 2;

        // get the final radius for the clipping circle
        float finalRadius = (float) Math.hypot(cx, cy);

        // create the animator for this view (the start radius is zero)
        Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);

        // make the view visible and start the animation
        view.setVisibility(View.VISIBLE);
        anim.start();
    } else {//  w  w w.j a v  a2 s  .c  o m
        view.setVisibility(View.VISIBLE);
        view.animate().alpha(1f).start();
    }
}

From source file:Main.java

public static void revealColorFromCoordinates(int x, int y, View viewRoot) {
    float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());
    Animator anim = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        anim = ViewAnimationUtils.createCircularReveal(viewRoot, x, y, 0, finalRadius);
    }/*from w ww . j a  v a2 s. c  o  m*/
    //viewRoot.setBackgroundColor(ContextCompat.getColor(viewRoot.getContext(), R.color.colorPrimary));
    anim.setDuration(1000);
    anim.start();
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static Animator createHideAnim(final View viewRoot, int x, int y) {

    float initialRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());

    Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, x, y, initialRadius, 0);
    anim.addListener(new AnimatorListenerAdapter() {
        @Override/*from   ww  w. j  a va 2  s  .c o  m*/
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            viewRoot.setVisibility(View.GONE);
        }
    });

    anim.start();
    return anim;
}

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

/**
 * Animates RecyclerView card on click with revealing effect
 * @param viewHolder to make animation on
 *///from   www.  j a va2 s  . co m
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void animationCard(RecyclerView.ViewHolder viewHolder) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (sBlueColor == 0) {
            sBlueColor = ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.colorPrimary);
        }
        if (sWhiteColor == 0) {
            sWhiteColor = 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(sBlueColor);
        anim.start();
        anim.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

            }

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

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
    }
}

From source file:Main.java

public static void hideRevealEffect(final View v, int centerX, int centerY, int initialRadius) {

    v.setVisibility(View.VISIBLE);

    // create the animation (the final radius is zero)
    Animator anim = ViewAnimationUtils.createCircularReveal(v, centerX, centerY, initialRadius, 0);

    anim.setDuration(350);/*from  w  w w .j ava  2  s.c o m*/

    // make the view invisible when the animation is done
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            v.setVisibility(View.INVISIBLE);
        }
    });

    anim.start();
}

From source file:Main.java

public static void startAnimationAfterNextDraw(final Animator animator, final View view) {
    view.getViewTreeObserver().addOnDrawListener(new ViewTreeObserver.OnDrawListener() {
        private boolean mStarted = false;

        public void onDraw() {
            if (mStarted)
                return;
            mStarted = true;//from  w  w w  .  jav a  2 s .  c o m
            // Use this as a signal that the animation was cancelled
            if (animator.getDuration() == 0) {
                return;
            }
            animator.start();

            final ViewTreeObserver.OnDrawListener listener = this;
            view.post(new Runnable() {
                public void run() {
                    view.getViewTreeObserver().removeOnDrawListener(listener);
                }
            });
        }
    });
}

From source file:Main.java

public static void startActivity(final Activity thisActivity, final Intent intent, final View triggerView,
        int colorOrImageRes, final long durationMills) {
    int[] location = new int[2];
    triggerView.getLocationInWindow(location);
    final int cx = location[0] + triggerView.getWidth();
    final int cy = location[1] + triggerView.getHeight() + (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 160, thisActivity.getResources().getDisplayMetrics());
    final ImageView view = new ImageView(thisActivity);
    view.setScaleType(ImageView.ScaleType.CENTER_CROP);
    view.setImageResource(colorOrImageRes);
    final ViewGroup decorView = (ViewGroup) thisActivity.getWindow().getDecorView();
    int w = decorView.getWidth();
    int h = decorView.getHeight();
    decorView.addView(view, w, h);//from   w  w  w .j av  a  2 s  .  c o m
    final int finalRadius = (int) Math.sqrt(w * w + h * h) + 1;
    Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);
    anim.setDuration(durationMills);
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            thisActivity.startActivity(intent);
            thisActivity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
        }
    });
    anim.start();
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void hide(final View view, int cornerType, int animRes, final boolean goneOrInvisible,
        final AnimatorListenerAdapter listener) {
    int[] amaya = calulateCorner(view, cornerType);
    //            if(view)
    Animator anim = ViewAnimationUtils.createCircularReveal(view, amaya[0], amaya[1], amaya[2], 0);
    anim.addListener(new AnimatorListenerAdapter() {
        @Override//from  ww w .j a va2s .c om
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            view.setVisibility(goneOrInvisible ? View.GONE : View.INVISIBLE);
            if (listener != null)
                listener.onAnimationEnd(animation);
        }
    });
    anim.setDuration(300);
    anim.start();
}

From source file:com.andryr.guitartuner.Utils.java

public static void hide(final View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // get the center for the clipping circle
        int cx = view.getWidth() / 2;
        int cy = view.getHeight() / 2;

        // get the initial radius for the clipping circle
        float initialRadius = (float) Math.hypot(cx, cy);

        // create the animation (the final radius is zero)
        Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0);

        // make the view invisible when the animation is done
        anim.addListener(new AnimatorListenerAdapter() {
            @Override//from  w w  w.ja  v  a  2  s. co m
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                view.setVisibility(View.INVISIBLE);
            }
        });

        // start the animation
        anim.start();
    } else {
        view.animate().alpha(0f).setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                view.setVisibility(View.INVISIBLE);
            }
        }).start();
    }
}