Search in sources :

Example 1 with SupportAnimator

use of org.aisen.weibo.sina.ui.widget.io.codetail.animation.SupportAnimator in project AisenWeiBo by wangdan.

the class MaterialSheetAnimation method startCircularRevealAnim.

protected void startCircularRevealAnim(View view, int centerX, int centerY, float startRadius, float endRadius, long duration, Interpolator interpolator, final AnimationListener listener) {
    // Use native circular reveal on Android 5.0+
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // Native circular reveal uses coordinates relative to the view
        int relativeCenterX = (int) (centerX - view.getX());
        int relativeCenterY = (int) (centerY - view.getY());
        // Setup animation
        Animator anim = ViewAnimationUtils.createCircularReveal(view, relativeCenterX, relativeCenterY, startRadius, endRadius);
        anim.setDuration(duration);
        anim.setInterpolator(interpolator);
        // Add listener
        anim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animation) {
                if (listener != null) {
                    listener.onStart();
                }
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                if (listener != null) {
                    listener.onEnd();
                }
            }
        });
        // Start animation
        anim.start();
    } else {
        // Circular reveal library uses absolute coordinates
        // Setup animation
        SupportAnimator anim = org.aisen.weibo.sina.ui.widget.io.codetail.animation.ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius);
        anim.setDuration((int) duration);
        anim.setInterpolator(interpolator);
        // Add listener
        anim.addListener(new SupportAnimator.SimpleAnimatorListener() {

            @Override
            public void onAnimationStart() {
                if (listener != null) {
                    listener.onStart();
                }
            }

            @Override
            public void onAnimationEnd() {
                if (listener != null) {
                    listener.onEnd();
                }
            }
        });
        // Start animation
        anim.start();
    }
}
Also used : SupportAnimator(org.aisen.weibo.sina.ui.widget.io.codetail.animation.SupportAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) SupportAnimator(org.aisen.weibo.sina.ui.widget.io.codetail.animation.SupportAnimator)

Aggregations

Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ValueAnimator (android.animation.ValueAnimator)1 SupportAnimator (org.aisen.weibo.sina.ui.widget.io.codetail.animation.SupportAnimator)1