Search in sources :

Example 16 with Animator

use of com.nineoldandroids.animation.Animator in project Carbon by ZieIony.

the class RelativeLayout method startReveal.

@Override
public Animator startReveal(int x, int y, float startRadius, float finishRadius) {
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
        android.animation.Animator circularReveal = ViewAnimationUtils.createCircularReveal(this, x, y, startRadius, finishRadius);
        circularReveal.start();
        return new Animator() {

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public long getStartDelay() {
                return circularReveal.getStartDelay();
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public void setStartDelay(long startDelay) {
                circularReveal.setStartDelay(startDelay);
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public Animator setDuration(long duration) {
                circularReveal.setDuration(duration);
                return this;
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public long getDuration() {
                return circularReveal.getDuration();
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public void setInterpolator(Interpolator value) {
                circularReveal.setInterpolator(value);
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public boolean isRunning() {
                return circularReveal.isRunning();
            }
        };
    } else {
        reveal = new Reveal(x, y, startRadius);
        ValueAnimator animator = ValueAnimator.ofFloat(startRadius, finishRadius);
        animator.setDuration(Carbon.getDefaultRevealDuration());
        animator.addUpdateListener(animation -> {
            reveal.radius = (float) animation.getAnimatedValue();
            reveal.mask.reset();
            reveal.mask.addCircle(reveal.x, reveal.y, Math.max(reveal.radius, 1), Path.Direction.CW);
            postInvalidate();
        });
        animator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationCancel(Animator animation) {
                reveal = null;
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                reveal = null;
            }
        });
        animator.start();
        return animator;
    }
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) StateAnimator(carbon.animation.StateAnimator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) Interpolator(android.view.animation.Interpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Reveal(carbon.internal.Reveal)

Example 17 with Animator

use of com.nineoldandroids.animation.Animator in project Carbon by ZieIony.

the class RelativeLayout method setVisibility.

public void setVisibility(final int visibility) {
    if (visibility == View.VISIBLE && (getVisibility() != View.VISIBLE || animator != null)) {
        if (animator != null)
            animator.cancel();
        if (inAnim != AnimUtils.Style.None) {
            animator = AnimUtils.animateIn(this, inAnim, new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator a) {
                    animator = null;
                    clearAnimation();
                }
            });
        }
        super.setVisibility(visibility);
    } else if (visibility != View.VISIBLE && (getVisibility() == View.VISIBLE || animator != null)) {
        if (animator != null)
            animator.cancel();
        if (outAnim == AnimUtils.Style.None) {
            super.setVisibility(visibility);
            return;
        }
        animator = AnimUtils.animateOut(this, outAnim, new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator a) {
                if (((ValueAnimator) a).getAnimatedFraction() == 1)
                    RelativeLayout.super.setVisibility(visibility);
                animator = null;
                clearAnimation();
            }
        });
    }
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) StateAnimator(carbon.animation.StateAnimator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 18 with Animator

use of com.nineoldandroids.animation.Animator in project Carbon by ZieIony.

the class GridLayout method setVisibility.

public void setVisibility(final int visibility) {
    if (visibility == View.VISIBLE && (getVisibility() != View.VISIBLE || animator != null)) {
        if (animator != null)
            animator.cancel();
        if (inAnim != AnimUtils.Style.None) {
            animator = AnimUtils.animateIn(this, inAnim, new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator a) {
                    animator = null;
                    clearAnimation();
                }
            });
        }
        super.setVisibility(visibility);
    } else if (visibility != View.VISIBLE && (getVisibility() == View.VISIBLE || animator != null)) {
        if (animator != null)
            animator.cancel();
        if (outAnim == AnimUtils.Style.None) {
            super.setVisibility(visibility);
            return;
        }
        animator = AnimUtils.animateOut(this, outAnim, new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator a) {
                if (((ValueAnimator) a).getAnimatedFraction() == 1)
                    GridLayout.super.setVisibility(visibility);
                animator = null;
                clearAnimation();
            }
        });
    }
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) StateAnimator(carbon.animation.StateAnimator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 19 with Animator

use of com.nineoldandroids.animation.Animator in project Carbon by ZieIony.

the class GridLayout method startReveal.

@Override
public Animator startReveal(int x, int y, float startRadius, float finishRadius) {
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
        android.animation.Animator circularReveal = ViewAnimationUtils.createCircularReveal(this, x, y, startRadius, finishRadius);
        circularReveal.start();
        return new Animator() {

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public long getStartDelay() {
                return circularReveal.getStartDelay();
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public void setStartDelay(long startDelay) {
                circularReveal.setStartDelay(startDelay);
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public Animator setDuration(long duration) {
                circularReveal.setDuration(duration);
                return this;
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public long getDuration() {
                return circularReveal.getDuration();
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public void setInterpolator(Interpolator value) {
                circularReveal.setInterpolator(value);
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public boolean isRunning() {
                return circularReveal.isRunning();
            }
        };
    } else {
        reveal = new Reveal(x, y, startRadius);
        ValueAnimator animator = ValueAnimator.ofFloat(startRadius, finishRadius);
        animator.setDuration(Carbon.getDefaultRevealDuration());
        animator.addUpdateListener(animation -> {
            reveal.radius = (float) animation.getAnimatedValue();
            reveal.mask.reset();
            reveal.mask.addCircle(reveal.x, reveal.y, Math.max(reveal.radius, 1), Path.Direction.CW);
            postInvalidate();
        });
        animator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationCancel(Animator animation) {
                reveal = null;
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                reveal = null;
            }
        });
        animator.start();
        return animator;
    }
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) StateAnimator(carbon.animation.StateAnimator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) Interpolator(android.view.animation.Interpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Reveal(carbon.internal.Reveal)

Example 20 with Animator

use of com.nineoldandroids.animation.Animator in project Carbon by ZieIony.

the class FlowLayout method startReveal.

@Override
public Animator startReveal(int x, int y, float startRadius, float finishRadius) {
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
        android.animation.Animator circularReveal = ViewAnimationUtils.createCircularReveal(this, x, y, startRadius, finishRadius);
        circularReveal.start();
        return new Animator() {

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public long getStartDelay() {
                return circularReveal.getStartDelay();
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public void setStartDelay(long startDelay) {
                circularReveal.setStartDelay(startDelay);
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public Animator setDuration(long duration) {
                circularReveal.setDuration(duration);
                return this;
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public long getDuration() {
                return circularReveal.getDuration();
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public void setInterpolator(Interpolator value) {
                circularReveal.setInterpolator(value);
            }

            @Override
            @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
            public boolean isRunning() {
                return circularReveal.isRunning();
            }
        };
    } else {
        reveal = new Reveal(x, y, startRadius);
        ValueAnimator animator = ValueAnimator.ofFloat(startRadius, finishRadius);
        animator.setDuration(Carbon.getDefaultRevealDuration());
        animator.addUpdateListener(animation -> {
            reveal.radius = (float) animation.getAnimatedValue();
            reveal.mask.reset();
            reveal.mask.addCircle(reveal.x, reveal.y, Math.max(reveal.radius, 1), Path.Direction.CW);
            postInvalidate();
        });
        animator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationCancel(Animator animation) {
                reveal = null;
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                reveal = null;
            }
        });
        animator.start();
        return animator;
    }
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) StateAnimator(carbon.animation.StateAnimator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) Interpolator(android.view.animation.Interpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Reveal(carbon.internal.Reveal)

Aggregations

Animator (com.nineoldandroids.animation.Animator)139 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)83 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)67 ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)53 AnimatorSet (com.nineoldandroids.animation.AnimatorSet)29 StateAnimator (carbon.animation.StateAnimator)28 View (android.view.View)27 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)13 Interpolator (android.view.animation.Interpolator)11 Reveal (carbon.internal.Reveal)11 RecyclerView (android.support.v7.widget.RecyclerView)6 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)6 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)6 ViewGroup (android.view.ViewGroup)5 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)4 OvershootInterpolator (android.view.animation.OvershootInterpolator)4 ArcAnimator (io.codetail.animation.arcanimator.ArcAnimator)4 Paint (android.graphics.Paint)3 Rect (android.graphics.Rect)3 GestureDetector (android.view.GestureDetector)3