Search in sources :

Example 1 with AnimatorSet

use of android.animation.AnimatorSet in project kickmaterial by byoutline.

the class AnimatorUtils method getScaleAnimator.

public static AnimatorSet getScaleAnimator(View view, float startScale, float endScale) {
    AnimatorSet set = new AnimatorSet();
    ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(view, View.SCALE_X, startScale, endScale);
    ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(view, View.SCALE_Y, startScale, endScale);
    set.playTogether(scaleXAnimator, scaleYAnimator);
    return set;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet)

Example 2 with AnimatorSet

use of android.animation.AnimatorSet in project kickmaterial by byoutline.

the class CircleTransition method createAnimator.

@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, final TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }
    Rect startBounds = (Rect) startValues.values.get(PROPERTY_BOUNDS);
    Rect endBounds = (Rect) endValues.values.get(PROPERTY_BOUNDS);
    boolean boundsEqual = startBounds == null || endBounds == null || startBounds.equals(endBounds);
    if (boundsEqual) {
        return null;
    }
    int[] sceneRootLoc = new int[2];
    sceneRoot.getLocationInWindow(sceneRootLoc);
    int[] startLoc = (int[]) startValues.values.get(PROPERTY_POSITION);
    final View startView = getStartView(sceneRoot, startValues, sceneRootLoc, startLoc);
    final View endView = endValues.view;
    endView.setAlpha(0f);
    Path circlePath = getMovePath(endValues, startView, sceneRootLoc, startLoc, endView);
    Animator circleAnimator = ObjectAnimator.ofFloat(startView, View.TRANSLATION_X, View.TRANSLATION_Y, circlePath);
    circleAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            startView.setVisibility(View.INVISIBLE);
            endView.setAlpha(1f);
            sceneRoot.getOverlay().remove(startView);
        }
    });
    AnimatorSet moveSet = new AnimatorSet();
    float scaleRatio = ((float) endView.getWidth()) / startView.getWidth();
    ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(startView, View.SCALE_X, 1, scaleRatio);
    ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(startView, View.SCALE_Y, 1, scaleRatio);
    moveSet.playTogether(circleAnimator, scaleXAnimator, scaleYAnimator);
    return moveSet;
}
Also used : Path(android.graphics.Path) Rect(android.graphics.Rect) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) View(android.view.View)

Example 3 with AnimatorSet

use of android.animation.AnimatorSet in project cw-omnibus by commonsguy.

the class AsyncDemoFragment method changeMenuIconAnimation.

// based on https://goo.gl/3IUM8K
private void changeMenuIconAnimation(final FloatingActionMenu menu) {
    AnimatorSet set = new AnimatorSet();
    final ImageView v = menu.getMenuIconView();
    ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(v, "scaleX", 1.0f, 0.2f);
    ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(v, "scaleY", 1.0f, 0.2f);
    ObjectAnimator scaleInX = ObjectAnimator.ofFloat(v, "scaleX", 0.2f, 1.0f);
    ObjectAnimator scaleInY = ObjectAnimator.ofFloat(v, "scaleY", 0.2f, 1.0f);
    scaleOutX.setDuration(50);
    scaleOutY.setDuration(50);
    scaleInX.setDuration(150);
    scaleInY.setDuration(150);
    scaleInX.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            v.setImageResource(menu.isOpened() ? R.drawable.ic_action_settings : R.drawable.ic_close);
        }
    });
    set.play(scaleOutX).with(scaleOutY);
    set.play(scaleInX).with(scaleInY).after(scaleOutX);
    set.setInterpolator(new OvershootInterpolator(2));
    menu.setIconToggleAnimatorSet(set);
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) OvershootInterpolator(android.view.animation.OvershootInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet) ImageView(android.widget.ImageView)

Example 4 with AnimatorSet

use of android.animation.AnimatorSet in project kickmaterial by byoutline.

the class CategoriesListActivity method runFinishAnimation.

private void runFinishAnimation(Runnable finishAction) {
    if (summaryScrolledValue > 0) {
        binding.categoriesRv.smoothScrollToPosition(0);
    }
    ViewUtils.showView(binding.selectCategoryTv, false);
    ObjectAnimator imageFade = ObjectAnimator.ofFloat(binding.selectedCategoryIv, View.ALPHA, 1, 0);
    AnimatorSet set = new AnimatorSet();
    AnimatorSet closeButtonScale = AnimatorUtils.getScaleAnimator(binding.closeCategoriesIv, 1, 0.1f);
    set.playTogether(closeButtonScale, imageFade);
    set.setDuration(FINISH_ANIMATION_DURATION);
    set.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (revealAnimation != null) {
                revealAnimation.cancel();
            }
            ViewUtils.showView(binding.categoryCircleRevealIv, false);
            binding.closeCategoriesIv.setScaleX(0);
            binding.closeCategoriesIv.setScaleY(0);
            finishAction.run();
        }
    });
    binding.categoriesRv.startAnimation(LUtils.loadAnimationWithLInterpolator(getApplicationContext(), R.anim.slide_to_bottom));
    set.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet)

Example 5 with AnimatorSet

use of android.animation.AnimatorSet in project nmid-headline by miao1007.

the class ImagesFeedAdapter method updateHeartButton.

private void updateHeartButton(final StreamViewHolder holder, boolean animated, final boolean isLike) {
    if (animated) {
        if (!likeAnimations.containsKey(holder)) {
            AnimatorSet animatorSet = new AnimatorSet();
            likeAnimations.put(holder, animatorSet);
            ObjectAnimator rotationAnim = ObjectAnimator.ofFloat(holder.mBtn_like, "rotation", 0f, 360f);
            rotationAnim.setDuration(300);
            rotationAnim.setInterpolator(ACCELERATE_INTERPOLATOR);
            ObjectAnimator bounceAnimX = ObjectAnimator.ofFloat(holder.mBtn_like, "scaleX", 0.2f, 1f);
            bounceAnimX.setDuration(300);
            bounceAnimX.setInterpolator(OVERSHOOT_INTERPOLATOR);
            ObjectAnimator bounceAnimY = ObjectAnimator.ofFloat(holder.mBtn_like, "scaleY", 0.2f, 1f);
            bounceAnimY.setDuration(300);
            bounceAnimY.setInterpolator(OVERSHOOT_INTERPOLATOR);
            bounceAnimY.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationStart(Animator animation) {
                    if (isLike) {
                        holder.mBtn_like.setImageResource(R.drawable.ic_heart_red);
                    } else {
                        holder.mBtn_like.setImageResource(R.drawable.ic_heart_outline_grey);
                    }
                }
            });
            animatorSet.play(rotationAnim);
            animatorSet.play(bounceAnimX).with(bounceAnimY).after(rotationAnim);
            animatorSet.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    resetLikeAnimationState(holder);
                }
            });
            animatorSet.start();
        }
    } else {
        if (likedPositions.contains(holder.getPosition())) {
            holder.mBtn_like.setImageResource(R.drawable.ic_heart_red);
        } else {
            holder.mBtn_like.setImageResource(R.drawable.ic_heart_outline_grey);
        }
    }
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet)

Aggregations

AnimatorSet (android.animation.AnimatorSet)697 ObjectAnimator (android.animation.ObjectAnimator)498 Animator (android.animation.Animator)407 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)202 ValueAnimator (android.animation.ValueAnimator)151 View (android.view.View)143 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)82 ArrayList (java.util.ArrayList)66 Rect (android.graphics.Rect)52 ViewGroup (android.view.ViewGroup)50 ImageView (android.widget.ImageView)48 TextView (android.widget.TextView)48 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)44 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)40 LinearInterpolator (android.view.animation.LinearInterpolator)30 Paint (android.graphics.Paint)29 PropertyValuesHolder (android.animation.PropertyValuesHolder)28 Point (android.graphics.Point)22 Bitmap (android.graphics.Bitmap)18 SuppressLint (android.annotation.SuppressLint)17