Search in sources :

Example 31 with Animator

use of android.animation.Animator in project Conductor by bluelinelabs.

the class AnimatorChangeHandler method performAnimation.

private void performAnimation(@NonNull final ViewGroup container, @Nullable final View from, @Nullable final View to, final boolean isPush, final boolean toAddedToContainer, @NonNull final ControllerChangeCompletedListener changeListener) {
    if (canceled) {
        complete(changeListener, null);
        return;
    }
    animator = getAnimator(container, from, to, isPush, toAddedToContainer);
    if (animationDuration > 0) {
        animator.setDuration(animationDuration);
    }
    animator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationCancel(Animator animation) {
            if (from != null && (!isPush || removesFromViewOnPush) && needsImmediateCompletion) {
                container.removeView(from);
            }
            complete(changeListener, this);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!canceled && animator != null) {
                if (from != null && (!isPush || removesFromViewOnPush)) {
                    container.removeView(from);
                }
                complete(changeListener, this);
                if (isPush && from != null) {
                    resetFromView(from);
                }
            }
        }
    });
    animator.start();
}
Also used : Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 32 with Animator

use of android.animation.Animator in project platform_frameworks_base by android.

the class DecorView method setHandledPrimaryActionMode.

private void setHandledPrimaryActionMode(ActionMode mode) {
    endOnGoingFadeAnimation();
    mPrimaryActionMode = mode;
    mPrimaryActionMode.invalidate();
    mPrimaryActionModeView.initForMode(mPrimaryActionMode);
    if (mPrimaryActionModePopup != null) {
        post(mShowPrimaryActionModePopup);
    } else {
        if (shouldAnimatePrimaryActionModeView()) {
            mFadeAnim = ObjectAnimator.ofFloat(mPrimaryActionModeView, View.ALPHA, 0f, 1f);
            mFadeAnim.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationStart(Animator animation) {
                    mPrimaryActionModeView.setVisibility(View.VISIBLE);
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    mPrimaryActionModeView.setAlpha(1f);
                    mFadeAnim = null;
                }
            });
            mFadeAnim.start();
        } else {
            mPrimaryActionModeView.setAlpha(1f);
            mPrimaryActionModeView.setVisibility(View.VISIBLE);
        }
    }
    mPrimaryActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 33 with Animator

use of android.animation.Animator in project platform_frameworks_base by android.

the class AppearAnimationUtils method createAnimation.

@Override
public void createAnimation(final View view, long delay, long duration, float translationY, boolean appearing, Interpolator interpolator, final Runnable endRunnable) {
    if (view != null) {
        view.setAlpha(appearing ? 0f : 1.0f);
        view.setTranslationY(appearing ? translationY : 0);
        Animator alphaAnim;
        float targetAlpha = appearing ? 1f : 0f;
        if (view.isHardwareAccelerated()) {
            RenderNodeAnimator alphaAnimRt = new RenderNodeAnimator(RenderNodeAnimator.ALPHA, targetAlpha);
            alphaAnimRt.setTarget(view);
            alphaAnim = alphaAnimRt;
        } else {
            alphaAnim = ObjectAnimator.ofFloat(view, View.ALPHA, view.getAlpha(), targetAlpha);
        }
        alphaAnim.setInterpolator(interpolator);
        alphaAnim.setDuration(duration);
        alphaAnim.setStartDelay(delay);
        if (view.hasOverlappingRendering()) {
            view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            alphaAnim.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    view.setLayerType(View.LAYER_TYPE_NONE, null);
                }
            });
        }
        if (endRunnable != null) {
            alphaAnim.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    endRunnable.run();
                }
            });
        }
        alphaAnim.start();
        startTranslationYAnimation(view, delay, duration, appearing ? 0 : translationY, interpolator);
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) RenderNodeAnimator(android.view.RenderNodeAnimator) Animator(android.animation.Animator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) ValueAnimator(android.animation.ValueAnimator) RenderNodeAnimator(android.view.RenderNodeAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 34 with Animator

use of android.animation.Animator in project platform_frameworks_base by android.

the class AppearAnimationUtils method startTranslationYAnimation.

public static void startTranslationYAnimation(View view, long delay, long duration, float endTranslationY, Interpolator interpolator) {
    Animator translationAnim;
    if (view.isHardwareAccelerated()) {
        RenderNodeAnimator translationAnimRt = new RenderNodeAnimator(RenderNodeAnimator.TRANSLATION_Y, endTranslationY);
        translationAnimRt.setTarget(view);
        translationAnim = translationAnimRt;
    } else {
        translationAnim = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, view.getTranslationY(), endTranslationY);
    }
    translationAnim.setInterpolator(interpolator);
    translationAnim.setDuration(duration);
    translationAnim.setStartDelay(delay);
    translationAnim.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) RenderNodeAnimator(android.view.RenderNodeAnimator) Animator(android.animation.Animator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) ValueAnimator(android.animation.ValueAnimator) RenderNodeAnimator(android.view.RenderNodeAnimator)

Example 35 with Animator

use of android.animation.Animator in project platform_frameworks_base by android.

the class SwipeHelper method snapChild.

public void snapChild(final View animView, final float targetLeft, float velocity) {
    final boolean canBeDismissed = mCallback.canChildBeDismissed(animView);
    AnimatorUpdateListener updateListener = new AnimatorUpdateListener() {

        public void onAnimationUpdate(ValueAnimator animation) {
            onTranslationUpdate(animView, (float) animation.getAnimatedValue(), canBeDismissed);
        }
    };
    Animator anim = getViewTranslationAnimator(animView, targetLeft, updateListener);
    if (anim == null) {
        return;
    }
    int duration = SNAP_ANIM_LEN;
    anim.setDuration(duration);
    anim.addListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator animator) {
            mSnappingChild = false;
            updateSwipeProgressFromOffset(animView, canBeDismissed);
            mCallback.onChildSnappedBack(animView, targetLeft);
        }
    });
    prepareSnapBackAnimation(animView, anim);
    mSnappingChild = true;
    anim.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Aggregations

Animator (android.animation.Animator)1413 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)868 ObjectAnimator (android.animation.ObjectAnimator)724 ValueAnimator (android.animation.ValueAnimator)630 AnimatorSet (android.animation.AnimatorSet)285 View (android.view.View)230 ViewGroup (android.view.ViewGroup)110 ArrayList (java.util.ArrayList)104 PropertyValuesHolder (android.animation.PropertyValuesHolder)96 Paint (android.graphics.Paint)79 StackStateAnimator (com.android.systemui.statusbar.stack.StackStateAnimator)75 ImageView (android.widget.ImageView)68 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)67 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)65 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)64 TextView (android.widget.TextView)61 RenderNodeAnimator (android.view.RenderNodeAnimator)51 ViewPropertyAnimator (android.view.ViewPropertyAnimator)51 Rect (android.graphics.Rect)50 Interpolator (android.view.animation.Interpolator)49