Search in sources :

Example 31 with AnimatorListenerAdapter

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

the class ExpandableNotificationRow method getTranslateViewAnimator.

public Animator getTranslateViewAnimator(final float leftTarget, AnimatorUpdateListener listener) {
    if (mTranslateAnim != null) {
        mTranslateAnim.cancel();
    }
    if (areGutsExposed()) {
        // No translation if guts are exposed.
        return null;
    }
    final ObjectAnimator translateAnim = ObjectAnimator.ofFloat(this, TRANSLATE_CONTENT, leftTarget);
    if (listener != null) {
        translateAnim.addUpdateListener(listener);
    }
    translateAnim.addListener(new AnimatorListenerAdapter() {

        boolean cancelled = false;

        @Override
        public void onAnimationCancel(Animator anim) {
            cancelled = true;
        }

        @Override
        public void onAnimationEnd(Animator anim) {
            if (!cancelled && mSettingsIconRow != null && leftTarget == 0) {
                mSettingsIconRow.resetState();
                mTranslateAnim = null;
            }
        }
    });
    mTranslateAnim = translateAnim;
    return translateAnim;
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) StackStateAnimator(com.android.systemui.statusbar.stack.StackStateAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 32 with AnimatorListenerAdapter

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

the class KeyguardAffordanceView method finishAnimation.

public void finishAnimation(float velocity, final Runnable mAnimationEndRunnable) {
    cancelAnimator(mCircleAnimator);
    cancelAnimator(mPreviewClipper);
    mFinishing = true;
    mCircleStartRadius = mCircleRadius;
    final float maxCircleSize = getMaxCircleSize();
    Animator animatorToRadius;
    if (mSupportHardware) {
        initHwProperties();
        animatorToRadius = getRtAnimatorToRadius(maxCircleSize);
        startRtAlphaFadeIn();
    } else {
        animatorToRadius = getAnimatorToRadius(maxCircleSize);
    }
    mFlingAnimationUtils.applyDismissing(animatorToRadius, mCircleRadius, maxCircleSize, velocity, maxCircleSize);
    animatorToRadius.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mAnimationEndRunnable.run();
            mFinishing = false;
            mCircleRadius = maxCircleSize;
            invalidate();
        }
    });
    animatorToRadius.start();
    setImageAlpha(0, true);
    if (mPreviewView != null) {
        mPreviewView.setVisibility(View.VISIBLE);
        mPreviewClipper = ViewAnimationUtils.createCircularReveal(mPreviewView, getLeft() + mCenterX, getTop() + mCenterY, mCircleRadius, maxCircleSize);
        mFlingAnimationUtils.applyDismissing(mPreviewClipper, mCircleRadius, maxCircleSize, velocity, maxCircleSize);
        mPreviewClipper.addListener(mClipEndListener);
        mPreviewClipper.start();
        if (mSupportHardware) {
            startRtCircleFadeOut(animatorToRadius.getDuration());
        }
    }
}
Also used : Animator(android.animation.Animator) RenderNodeAnimator(android.view.RenderNodeAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 33 with AnimatorListenerAdapter

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

the class StackStateAnimator method startHeightAnimation.

private void startHeightAnimation(final ExpandableView child, StackViewState viewState, long duration, long delay) {
    Integer previousStartValue = getChildTag(child, TAG_START_HEIGHT);
    Integer previousEndValue = getChildTag(child, TAG_END_HEIGHT);
    int newEndValue = viewState.height;
    if (previousEndValue != null && previousEndValue == newEndValue) {
        return;
    }
    ValueAnimator previousAnimator = getChildTag(child, TAG_ANIMATOR_HEIGHT);
    if (!mAnimationFilter.animateHeight) {
        // just a local update was performed
        if (previousAnimator != null) {
            // we need to increase all animation keyframes of the previous animator by the
            // relative change to the end value
            PropertyValuesHolder[] values = previousAnimator.getValues();
            int relativeDiff = newEndValue - previousEndValue;
            int newStartValue = previousStartValue + relativeDiff;
            values[0].setIntValues(newStartValue, newEndValue);
            child.setTag(TAG_START_HEIGHT, newStartValue);
            child.setTag(TAG_END_HEIGHT, newEndValue);
            previousAnimator.setCurrentPlayTime(previousAnimator.getCurrentPlayTime());
            return;
        } else {
            // no new animation needed, let's just apply the value
            child.setActualHeight(newEndValue, false);
            return;
        }
    }
    ValueAnimator animator = ValueAnimator.ofInt(child.getActualHeight(), newEndValue);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            child.setActualHeight((int) animation.getAnimatedValue(), false);
        }
    });
    animator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
    long newDuration = cancelAnimatorAndGetNewDuration(duration, previousAnimator);
    animator.setDuration(newDuration);
    if (delay > 0 && (previousAnimator == null || previousAnimator.getAnimatedFraction() == 0)) {
        animator.setStartDelay(delay);
    }
    animator.addListener(getGlobalAnimationFinishedListener());
    // remove the tag when the animation is finished
    animator.addListener(new AnimatorListenerAdapter() {

        boolean mWasCancelled;

        @Override
        public void onAnimationEnd(Animator animation) {
            child.setTag(TAG_ANIMATOR_HEIGHT, null);
            child.setTag(TAG_START_HEIGHT, null);
            child.setTag(TAG_END_HEIGHT, null);
            child.setActualHeightAnimating(false);
            if (!mWasCancelled && child instanceof ExpandableNotificationRow) {
                ((ExpandableNotificationRow) child).setGroupExpansionChanging(false);
            }
        }

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

        @Override
        public void onAnimationCancel(Animator animation) {
            mWasCancelled = true;
        }
    });
    startAnimator(animator);
    child.setTag(TAG_ANIMATOR_HEIGHT, animator);
    child.setTag(TAG_START_HEIGHT, child.getActualHeight());
    child.setTag(TAG_END_HEIGHT, newEndValue);
    child.setActualHeightAnimating(true);
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PropertyValuesHolder(android.animation.PropertyValuesHolder) ValueAnimator(android.animation.ValueAnimator) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Example 34 with AnimatorListenerAdapter

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

the class StackStateAnimator method animateOverScrollToAmount.

public void animateOverScrollToAmount(float targetAmount, final boolean onTop, final boolean isRubberbanded) {
    final float startOverScrollAmount = mHostLayout.getCurrentOverScrollAmount(onTop);
    if (targetAmount == startOverScrollAmount) {
        return;
    }
    cancelOverScrollAnimators(onTop);
    ValueAnimator overScrollAnimator = ValueAnimator.ofFloat(startOverScrollAmount, targetAmount);
    overScrollAnimator.setDuration(ANIMATION_DURATION_STANDARD);
    overScrollAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float currentOverScroll = (float) animation.getAnimatedValue();
            mHostLayout.setOverScrollAmount(currentOverScroll, onTop, false, /* animate */
            false, /* cancelAnimators */
            isRubberbanded);
        }
    });
    overScrollAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
    overScrollAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (onTop) {
                mTopOverScrollAnimator = null;
            } else {
                mBottomOverScrollAnimator = null;
            }
        }
    });
    overScrollAnimator.start();
    if (onTop) {
        mTopOverScrollAnimator = overScrollAnimator;
    } else {
        mBottomOverScrollAnimator = overScrollAnimator;
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 35 with AnimatorListenerAdapter

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

the class RemoteInputView method onDefocus.

private void onDefocus(boolean animate) {
    mController.removeRemoteInput(mEntry, mToken);
    mEntry.remoteInputText = mEditText.getText();
    // case to prevent flicker.
    if (!mRemoved) {
        if (animate && mRevealR > 0) {
            Animator reveal = ViewAnimationUtils.createCircularReveal(this, mRevealCx, mRevealCy, mRevealR, 0);
            reveal.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN);
            reveal.setDuration(StackStateAnimator.ANIMATION_DURATION_CLOSE_REMOTE_INPUT);
            reveal.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    setVisibility(INVISIBLE);
                }
            });
            reveal.start();
        } else {
            setVisibility(INVISIBLE);
        }
    }
    MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_REMOTE_INPUT_CLOSE, mEntry.notification.getPackageName());
}
Also used : Animator(android.animation.Animator) StackStateAnimator(com.android.systemui.statusbar.stack.StackStateAnimator) 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