Search in sources :

Example 26 with AnimatorListenerAdapter

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

the class DividerHandleView method animateToTarget.

private void animateToTarget(int targetWidth, int targetHeight, boolean touching) {
    ObjectAnimator widthAnimator = ObjectAnimator.ofInt(this, WIDTH_PROPERTY, mCurrentWidth, targetWidth);
    ObjectAnimator heightAnimator = ObjectAnimator.ofInt(this, HEIGHT_PROPERTY, mCurrentHeight, targetHeight);
    mAnimator = new AnimatorSet();
    mAnimator.playTogether(widthAnimator, heightAnimator);
    mAnimator.setDuration(touching ? DividerView.TOUCH_ANIMATION_DURATION : DividerView.TOUCH_RELEASE_ANIMATION_DURATION);
    mAnimator.setInterpolator(touching ? Interpolators.TOUCH_RESPONSE : Interpolators.FAST_OUT_SLOW_IN);
    mAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mAnimator = null;
        }
    });
    mAnimator.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet)

Example 27 with AnimatorListenerAdapter

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

the class NotificationSettingsIconRow method fadeInSettings.

public void fadeInSettings(final boolean fromLeft, final float transX, final float notiThreshold) {
    if (mDismissing || mAnimating) {
        return;
    }
    if (isIconLocationChange(transX)) {
        setGearAlpha(0f);
    }
    setIconLocation(transX > 0);
    mFadeAnimator = ValueAnimator.ofFloat(mGearIcon.getAlpha(), 1);
    mFadeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            final float absTrans = Math.abs(transX);
            boolean pastGear = (fromLeft && transX <= notiThreshold) || (!fromLeft && absTrans <= notiThreshold);
            if (pastGear && !mSettingsFadedIn) {
                setGearAlpha((float) animation.getAnimatedValue());
            }
        }
    });
    mFadeAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            mAnimating = true;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            // TODO should animate back to 0f from current alpha
            mGearIcon.setAlpha(0f);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mAnimating = false;
            mSettingsFadedIn = mGearIcon.getAlpha() == 1;
        }
    });
    mFadeAnimator.setInterpolator(Interpolators.ALPHA_IN);
    mFadeAnimator.setDuration(GEAR_ALPHA_ANIM_DURATION);
    mFadeAnimator.start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 28 with AnimatorListenerAdapter

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

the class ActivatableNotificationView method startAppearAnimation.

private void startAppearAnimation(boolean isAppearing, float translationDirection, long delay, long duration, final Runnable onFinishedRunnable) {
    cancelAppearAnimation();
    mAnimationTranslationY = translationDirection * getActualHeight();
    if (mAppearAnimationFraction == -1.0f) {
        // not initialized yet, we start anew
        if (isAppearing) {
            mAppearAnimationFraction = 0.0f;
            mAppearAnimationTranslation = mAnimationTranslationY;
        } else {
            mAppearAnimationFraction = 1.0f;
            mAppearAnimationTranslation = 0;
        }
    }
    float targetValue;
    if (isAppearing) {
        mCurrentAppearInterpolator = mSlowOutFastInInterpolator;
        mCurrentAlphaInterpolator = Interpolators.LINEAR_OUT_SLOW_IN;
        targetValue = 1.0f;
    } else {
        mCurrentAppearInterpolator = Interpolators.FAST_OUT_SLOW_IN;
        mCurrentAlphaInterpolator = mSlowOutLinearInInterpolator;
        targetValue = 0.0f;
    }
    mAppearAnimator = ValueAnimator.ofFloat(mAppearAnimationFraction, targetValue);
    mAppearAnimator.setInterpolator(Interpolators.LINEAR);
    mAppearAnimator.setDuration((long) (duration * Math.abs(mAppearAnimationFraction - targetValue)));
    mAppearAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mAppearAnimationFraction = (float) animation.getAnimatedValue();
            updateAppearAnimationAlpha();
            updateAppearRect();
            invalidate();
        }
    });
    if (delay > 0) {
        // we need to apply the initial state already to avoid drawn frames in the wrong state
        updateAppearAnimationAlpha();
        updateAppearRect();
        mAppearAnimator.setStartDelay(delay);
    }
    mAppearAnimator.addListener(new AnimatorListenerAdapter() {

        private boolean mWasCancelled;

        @Override
        public void onAnimationEnd(Animator animation) {
            if (onFinishedRunnable != null) {
                onFinishedRunnable.run();
            }
            if (!mWasCancelled) {
                enableAppearDrawing(false);
                onAppearAnimationFinished(isAppearing);
            }
        }

        @Override
        public void onAnimationStart(Animator animation) {
            mWasCancelled = false;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            mWasCancelled = true;
        }
    });
    mAppearAnimator.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) StackStateAnimator(com.android.systemui.statusbar.stack.StackStateAnimator) TimeAnimator(android.animation.TimeAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 29 with AnimatorListenerAdapter

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

the class ActivatableNotificationView method startActivateAnimation.

private void startActivateAnimation(final boolean reverse) {
    if (!isAttachedToWindow()) {
        return;
    }
    int widthHalf = mBackgroundNormal.getWidth() / 2;
    int heightHalf = mBackgroundNormal.getActualHeight() / 2;
    float radius = (float) Math.sqrt(widthHalf * widthHalf + heightHalf * heightHalf);
    Animator animator;
    if (reverse) {
        animator = ViewAnimationUtils.createCircularReveal(mBackgroundNormal, widthHalf, heightHalf, radius, 0);
    } else {
        animator = ViewAnimationUtils.createCircularReveal(mBackgroundNormal, widthHalf, heightHalf, 0, radius);
    }
    mBackgroundNormal.setVisibility(View.VISIBLE);
    Interpolator interpolator;
    Interpolator alphaInterpolator;
    if (!reverse) {
        interpolator = Interpolators.LINEAR_OUT_SLOW_IN;
        alphaInterpolator = Interpolators.LINEAR_OUT_SLOW_IN;
    } else {
        interpolator = ACTIVATE_INVERSE_INTERPOLATOR;
        alphaInterpolator = ACTIVATE_INVERSE_ALPHA_INTERPOLATOR;
    }
    animator.setInterpolator(interpolator);
    animator.setDuration(ACTIVATE_ANIMATION_LENGTH);
    if (reverse) {
        mBackgroundNormal.setAlpha(1f);
        animator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                updateBackground();
            }
        });
        animator.start();
    } else {
        mBackgroundNormal.setAlpha(0.4f);
        animator.start();
    }
    mBackgroundNormal.animate().alpha(reverse ? 0f : 1f).setInterpolator(alphaInterpolator).setUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float animatedFraction = animation.getAnimatedFraction();
            if (reverse) {
                animatedFraction = 1.0f - animatedFraction;
            }
            setNormalBackgroundVisibilityAmount(animatedFraction);
        }
    }).setDuration(ACTIVATE_ANIMATION_LENGTH);
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) StackStateAnimator(com.android.systemui.statusbar.stack.StackStateAnimator) TimeAnimator(android.animation.TimeAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PathInterpolator(android.view.animation.PathInterpolator) Interpolator(android.view.animation.Interpolator) ValueAnimator(android.animation.ValueAnimator)

Example 30 with AnimatorListenerAdapter

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

the class ActivatableNotificationView method fadeDimmedBackground.

/**
     * Fades the background when the dimmed state changes.
     */
private void fadeDimmedBackground() {
    mBackgroundDimmed.animate().cancel();
    mBackgroundNormal.animate().cancel();
    if (mActivated) {
        updateBackground();
        return;
    }
    if (!shouldHideBackground()) {
        if (mDimmed) {
            mBackgroundDimmed.setVisibility(View.VISIBLE);
        } else {
            mBackgroundNormal.setVisibility(View.VISIBLE);
        }
    }
    float startAlpha = mDimmed ? 1f : 0;
    float endAlpha = mDimmed ? 0 : 1f;
    int duration = BACKGROUND_ANIMATION_LENGTH_MS;
    // Check whether there is already a background animation running.
    if (mBackgroundAnimator != null) {
        startAlpha = (Float) mBackgroundAnimator.getAnimatedValue();
        duration = (int) mBackgroundAnimator.getCurrentPlayTime();
        mBackgroundAnimator.removeAllListeners();
        mBackgroundAnimator.cancel();
        if (duration <= 0) {
            updateBackground();
            return;
        }
    }
    mBackgroundNormal.setAlpha(startAlpha);
    mBackgroundAnimator = ObjectAnimator.ofFloat(mBackgroundNormal, View.ALPHA, startAlpha, endAlpha);
    mBackgroundAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
    mBackgroundAnimator.setDuration(duration);
    mBackgroundAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            updateBackground();
            mBackgroundAnimator = null;
            if (mFadeInFromDarkAnimator == null) {
                mDimmedBackgroundFadeInAmount = -1;
            }
        }
    });
    mBackgroundAnimator.addUpdateListener(mBackgroundVisibilityUpdater);
    mBackgroundAnimator.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) StackStateAnimator(com.android.systemui.statusbar.stack.StackStateAnimator) TimeAnimator(android.animation.TimeAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Aggregations

Animator (android.animation.Animator)868 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)868 ObjectAnimator (android.animation.ObjectAnimator)464 ValueAnimator (android.animation.ValueAnimator)459 AnimatorSet (android.animation.AnimatorSet)144 View (android.view.View)131 ViewGroup (android.view.ViewGroup)92 PropertyValuesHolder (android.animation.PropertyValuesHolder)70 StackStateAnimator (com.android.systemui.statusbar.stack.StackStateAnimator)70 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)62 ImageView (android.widget.ImageView)45 TextView (android.widget.TextView)43 Interpolator (android.view.animation.Interpolator)42 Paint (android.graphics.Paint)41 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)41 Rect (android.graphics.Rect)40 RenderNodeAnimator (android.view.RenderNodeAnimator)36 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)36 TimeAnimator (android.animation.TimeAnimator)30 TargetApi (android.annotation.TargetApi)30