Search in sources :

Example 21 with Animator

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

the class Toolbar 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 22 with Animator

use of com.nineoldandroids.animation.Animator in project CoCoin by Nightonke.

the class RippleView method onTouchEvent.

@Override
public boolean onTouchEvent(final MotionEvent event) {
    Log.d("TouchEvent", String.valueOf(event.getActionMasked()));
    Log.d("mIsAnimating", String.valueOf(mIsAnimating));
    Log.d("mAnimationIsCancel", String.valueOf(mAnimationIsCancel));
    boolean superResult = super.onTouchEvent(event);
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN && this.isEnabled() && mHover) {
        mRect = new Rect(getLeft(), getTop(), getRight(), getBottom());
        mAnimationIsCancel = false;
        mDownX = event.getX();
        mDownY = event.getY();
        mRadiusAnimator = ObjectAnimator.ofFloat(this, "radius", 0, dp(50)).setDuration(400);
        mRadiusAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
        mRadiusAnimator.addListener(new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animator) {
                mIsAnimating = true;
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                setRadius(0);
                ViewHelper.setAlpha(RippleView.this, 1);
                mIsAnimating = false;
            }

            @Override
            public void onAnimationCancel(Animator animator) {
            }

            @Override
            public void onAnimationRepeat(Animator animator) {
            }
        });
        mRadiusAnimator.start();
        if (!superResult) {
            return true;
        }
    } else if (event.getActionMasked() == MotionEvent.ACTION_MOVE && this.isEnabled() && mHover) {
        mDownX = event.getX();
        mDownY = event.getY();
        // Cancel the ripple animation when moved outside
        if (mAnimationIsCancel = !mRect.contains(getLeft() + (int) event.getX(), getTop() + (int) event.getY())) {
            setRadius(0);
        } else {
            setRadius(dp(50));
        }
        if (!superResult) {
            return true;
        }
    } else if (event.getActionMasked() == MotionEvent.ACTION_UP && !mAnimationIsCancel && this.isEnabled()) {
        mDownX = event.getX();
        mDownY = event.getY();
        final float tempRadius = (float) Math.sqrt(mDownX * mDownX + mDownY * mDownY);
        float targetRadius = Math.max(tempRadius, mMaxRadius);
        if (mIsAnimating) {
            mRadiusAnimator.cancel();
        }
        mRadiusAnimator = ObjectAnimator.ofFloat(this, "radius", dp(50), targetRadius);
        mRadiusAnimator.setDuration(500);
        mRadiusAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
        mRadiusAnimator.addListener(new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animator) {
                mIsAnimating = true;
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                setRadius(0);
                ViewHelper.setAlpha(RippleView.this, 1);
                mIsAnimating = false;
            }

            @Override
            public void onAnimationCancel(Animator animator) {
            }

            @Override
            public void onAnimationRepeat(Animator animator) {
            }
        });
        mRadiusAnimator.start();
        if (!superResult) {
            return true;
        }
    }
    return superResult;
}
Also used : Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator)

Example 23 with Animator

use of com.nineoldandroids.animation.Animator in project ride-read-android by Ride-Read.

the class ShowPictureActivity method MoveView.

private void MoveView() {
    ObjectAnimator.ofFloat(mainView, "alpha", 0.8f).setDuration(0).start();
    mainView.setVisibility(View.VISIBLE);
    AnimatorSet set = new AnimatorSet();
    set.playTogether(ObjectAnimator.ofFloat(showImageView, "translationX", tx).setDuration(200), ObjectAnimator.ofFloat(showImageView, "translationY", ty).setDuration(200), ObjectAnimator.ofFloat(mainView, "alpha", 1).setDuration(200));
    set.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            showImageView.setScaleType(ImageView.ScaleType.FIT_XY);
            spring.setEndValue(1);
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    set.start();
}
Also used : Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 24 with Animator

use of com.nineoldandroids.animation.Animator in project ride-read-android by Ride-Read.

the class ShowPictureActivity method MoveBackView.

private void MoveBackView() {
    AnimatorSet set = new AnimatorSet();
    set.playTogether(ObjectAnimator.ofFloat(showImageView, "translationX", to_x).setDuration(200), ObjectAnimator.ofFloat(showImageView, "translationY", to_y).setDuration(200));
    set.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            finish();
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    set.start();
}
Also used : Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 25 with Animator

use of com.nineoldandroids.animation.Animator in project appsly-android-rest by 47deg.

the class MainActivity method animateContent.

private void animateContent() {
    ViewHelper.setRotation(imageViewIcon, 20);
    ViewHelper.setTranslationY(imageViewIcon, -100);
    ViewHelper.setTranslationX(textViewCity, 100);
    ViewHelper.setAlpha(linearLayoutContent, 0);
    ViewHelper.setTranslationY(descriptionTempContent, 200);
    ViewHelper.setTranslationY(contentBottom, 200);
    animate(imageViewIcon).setDuration(300).setInterpolator(new AccelerateInterpolator()).translationY(0).setListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            iconFall(imageViewIcon, 10);
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    }).start();
    animate(textViewCity).setDuration(1000).setInterpolator(new AccelerateDecelerateInterpolator()).translationX(0).start();
    animate(linearLayoutContent).setDuration(1000).alpha(1).start();
    animate(contentBottom).setDuration(1000).translationY(0).start();
    animate(descriptionTempContent).setDuration(1000).translationY(0).start();
}
Also used : Animator(com.nineoldandroids.animation.Animator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator)

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