Search in sources :

Example 81 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project android_frameworks_base by AOSPA.

the class ScrimController method updateScrim.

private void updateScrim(boolean animate, View scrim, float alpha, float currentAlpha) {
    if (mKeyguardFadingOutInProgress) {
        return;
    }
    ValueAnimator previousAnimator = StackStateAnimator.getChildTag(scrim, TAG_KEY_ANIM);
    float animEndValue = -1;
    if (previousAnimator != null) {
        if (animate || alpha == currentAlpha) {
            previousAnimator.cancel();
        } else {
            animEndValue = StackStateAnimator.getChildTag(scrim, TAG_END_ALPHA);
        }
    }
    if (alpha != currentAlpha && alpha != animEndValue) {
        if (animate) {
            startScrimAnimation(scrim, alpha);
            scrim.setTag(TAG_START_ALPHA, currentAlpha);
            scrim.setTag(TAG_END_ALPHA, alpha);
        } else {
            if (previousAnimator != null) {
                float previousStartValue = StackStateAnimator.getChildTag(scrim, TAG_START_ALPHA);
                float previousEndValue = StackStateAnimator.getChildTag(scrim, TAG_END_ALPHA);
                // we need to increase all animation keyframes of the previous animator by the
                // relative change to the end value
                PropertyValuesHolder[] values = previousAnimator.getValues();
                float relativeDiff = alpha - previousEndValue;
                float newStartValue = previousStartValue + relativeDiff;
                newStartValue = Math.max(0, Math.min(1.0f, newStartValue));
                values[0].setFloatValues(newStartValue, alpha);
                scrim.setTag(TAG_START_ALPHA, newStartValue);
                scrim.setTag(TAG_END_ALPHA, alpha);
                previousAnimator.setCurrentPlayTime(previousAnimator.getCurrentPlayTime());
            } else {
                // update the alpha directly
                setCurrentScrimAlpha(scrim, alpha);
                updateScrimColor(scrim);
            }
        }
    }
}
Also used : PropertyValuesHolder(android.animation.PropertyValuesHolder) ValueAnimator(android.animation.ValueAnimator)

Example 82 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project android_frameworks_base by AOSPA.

the class FastScroller method animateBounds.

/**
     * Returns an animator for the view's bounds.
     */
private static Animator animateBounds(View v, Rect bounds) {
    final PropertyValuesHolder left = PropertyValuesHolder.ofInt(LEFT, bounds.left);
    final PropertyValuesHolder top = PropertyValuesHolder.ofInt(TOP, bounds.top);
    final PropertyValuesHolder right = PropertyValuesHolder.ofInt(RIGHT, bounds.right);
    final PropertyValuesHolder bottom = PropertyValuesHolder.ofInt(BOTTOM, bounds.bottom);
    return ObjectAnimator.ofPropertyValuesHolder(v, left, top, right, bottom);
}
Also used : PropertyValuesHolder(android.animation.PropertyValuesHolder)

Example 83 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project android_frameworks_base by AOSPA.

the class StackView method transformViewAtIndex.

private void transformViewAtIndex(int index, final View view, boolean animate) {
    final float maxPerspectiveShiftY = mPerspectiveShiftY;
    final float maxPerspectiveShiftX = mPerspectiveShiftX;
    if (mStackMode == ITEMS_SLIDE_DOWN) {
        index = mMaxNumActiveViews - index - 1;
        if (index == mMaxNumActiveViews - 1)
            index--;
    } else {
        index--;
        if (index < 0)
            index++;
    }
    float r = (index * 1.0f) / (mMaxNumActiveViews - 2);
    final float scale = 1 - PERSPECTIVE_SCALE_FACTOR * (1 - r);
    float perspectiveTranslationY = r * maxPerspectiveShiftY;
    float scaleShiftCorrectionY = (scale - 1) * (getMeasuredHeight() * (1 - PERSPECTIVE_SHIFT_FACTOR_Y) / 2.0f);
    final float transY = perspectiveTranslationY + scaleShiftCorrectionY;
    float perspectiveTranslationX = (1 - r) * maxPerspectiveShiftX;
    float scaleShiftCorrectionX = (1 - scale) * (getMeasuredWidth() * (1 - PERSPECTIVE_SHIFT_FACTOR_X) / 2.0f);
    final float transX = perspectiveTranslationX + scaleShiftCorrectionX;
    // this animation so as not to interfere with the new transformation.
    if (view instanceof StackFrame) {
        ((StackFrame) view).cancelTransformAnimator();
    }
    if (animate) {
        PropertyValuesHolder translationX = PropertyValuesHolder.ofFloat("translationX", transX);
        PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", transY);
        PropertyValuesHolder scalePropX = PropertyValuesHolder.ofFloat("scaleX", scale);
        PropertyValuesHolder scalePropY = PropertyValuesHolder.ofFloat("scaleY", scale);
        ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(view, scalePropX, scalePropY, translationY, translationX);
        oa.setDuration(STACK_RELAYOUT_DURATION);
        if (view instanceof StackFrame) {
            ((StackFrame) view).setTransformAnimator(oa);
        }
        oa.start();
    } else {
        view.setTranslationX(transX);
        view.setTranslationY(transY);
        view.setScaleX(scale);
        view.setScaleY(scale);
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder)

Example 84 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project android_frameworks_base by AOSPA.

the class NotificationStackScrollLayout method startBottomAnimation.

private void startBottomAnimation() {
    int previousStartValue = mStartAnimationRect.bottom;
    int previousEndValue = mEndAnimationRect.bottom;
    int newEndValue = mBackgroundBounds.bottom;
    ObjectAnimator previousAnimator = mBottomAnimator;
    if (previousAnimator != null && previousEndValue == newEndValue) {
        return;
    }
    if (!mAnimateNextBackgroundBottom) {
        // 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();
            values[0].setIntValues(previousStartValue, newEndValue);
            mStartAnimationRect.bottom = previousStartValue;
            mEndAnimationRect.bottom = newEndValue;
            previousAnimator.setCurrentPlayTime(previousAnimator.getCurrentPlayTime());
            return;
        } else {
            // no new animation needed, let's just apply the value
            setBackgroundBottom(newEndValue);
            return;
        }
    }
    if (previousAnimator != null) {
        previousAnimator.cancel();
    }
    ObjectAnimator animator = ObjectAnimator.ofInt(this, "backgroundBottom", mCurrentBounds.bottom, newEndValue);
    Interpolator interpolator = Interpolators.FAST_OUT_SLOW_IN;
    animator.setInterpolator(interpolator);
    animator.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
    // remove the tag when the animation is finished
    animator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mStartAnimationRect.bottom = -1;
            mEndAnimationRect.bottom = -1;
            mBottomAnimator = null;
        }
    });
    animator.start();
    mStartAnimationRect.bottom = mCurrentBounds.bottom;
    mEndAnimationRect.bottom = newEndValue;
    mBottomAnimator = animator;
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) TimeAnimator(android.animation.TimeAnimator) ValueAnimator(android.animation.ValueAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PropertyValuesHolder(android.animation.PropertyValuesHolder) Interpolator(android.view.animation.Interpolator) Paint(android.graphics.Paint)

Example 85 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project android_frameworks_base by DirtyUnicorns.

the class FragmentManagerImpl method modifiesAlpha.

static boolean modifiesAlpha(Animator anim) {
    if (anim == null) {
        return false;
    }
    if (anim instanceof ValueAnimator) {
        ValueAnimator valueAnim = (ValueAnimator) anim;
        PropertyValuesHolder[] values = valueAnim.getValues();
        for (int i = 0; i < values.length; i++) {
            if (("alpha").equals(values[i].getPropertyName())) {
                return true;
            }
        }
    } else if (anim instanceof AnimatorSet) {
        List<Animator> animList = ((AnimatorSet) anim).getChildAnimations();
        for (int i = 0; i < animList.size(); i++) {
            if (modifiesAlpha(animList.get(i))) {
                return true;
            }
        }
    }
    return false;
}
Also used : PropertyValuesHolder(android.animation.PropertyValuesHolder) AnimatorSet(android.animation.AnimatorSet) ArrayList(java.util.ArrayList) List(java.util.List) ValueAnimator(android.animation.ValueAnimator)

Aggregations

PropertyValuesHolder (android.animation.PropertyValuesHolder)210 ObjectAnimator (android.animation.ObjectAnimator)144 Animator (android.animation.Animator)96 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)70 ValueAnimator (android.animation.ValueAnimator)64 Paint (android.graphics.Paint)33 AnimatorSet (android.animation.AnimatorSet)25 NonNull (android.support.annotation.NonNull)18 LinearInterpolator (android.view.animation.LinearInterpolator)18 Interpolator (android.view.animation.Interpolator)16 ArrayList (java.util.ArrayList)16 ViewGroup (android.view.ViewGroup)14 View (android.view.View)12 IntEvaluator (android.animation.IntEvaluator)11 Point (android.graphics.Point)11 Keyframe (android.animation.Keyframe)10 TimeAnimator (android.animation.TimeAnimator)10 Path (android.graphics.Path)10 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)8 Rect (android.graphics.Rect)7