Search in sources :

Example 21 with PropertyValuesHolder

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

the class KeyguardWidgetCarousel method animatePagesToCarousel.

void animatePagesToCarousel() {
    if (mChildrenTransformsAnimator != null) {
        mChildrenTransformsAnimator.cancel();
        mChildrenTransformsAnimator = null;
    }
    int count = getChildCount();
    PropertyValuesHolder alpha;
    PropertyValuesHolder outlineAlpha;
    PropertyValuesHolder rotationY;
    PropertyValuesHolder pivotX;
    PropertyValuesHolder pivotY;
    ArrayList<Animator> anims = new ArrayList<Animator>();
    for (int i = 0; i < count; i++) {
        KeyguardWidgetFrame child = getWidgetPageAt(i);
        float finalAlpha = getAlphaForPage(mScreenCenter, i, true);
        float finalOutlineAlpha = getOutlineAlphaForPage(mScreenCenter, i, true);
        getTransformForPage(mScreenCenter, i, mTmpTransform);
        boolean inVisibleRange = (i >= mCurrentPage - 1 && i <= mCurrentPage + 1);
        ObjectAnimator a;
        alpha = PropertyValuesHolder.ofFloat("contentAlpha", finalAlpha);
        outlineAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", finalOutlineAlpha);
        pivotX = PropertyValuesHolder.ofFloat("pivotX", mTmpTransform[0]);
        pivotY = PropertyValuesHolder.ofFloat("pivotY", mTmpTransform[1]);
        rotationY = PropertyValuesHolder.ofFloat("rotationY", mTmpTransform[2]);
        if (inVisibleRange) {
            // for the central pages we animate into a rotated state
            a = ObjectAnimator.ofPropertyValuesHolder(child, alpha, outlineAlpha, pivotX, pivotY, rotationY);
        } else {
            a = ObjectAnimator.ofPropertyValuesHolder(child, alpha, outlineAlpha);
            a.setInterpolator(mFastFadeInterpolator);
        }
        anims.add(a);
    }
    int duration = REORDERING_ZOOM_IN_OUT_DURATION;
    mChildrenTransformsAnimator = new AnimatorSet();
    mChildrenTransformsAnimator.playTogether(anims);
    mChildrenTransformsAnimator.setDuration(duration);
    mChildrenTransformsAnimator.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ArrayList(java.util.ArrayList) PropertyValuesHolder(android.animation.PropertyValuesHolder) AnimatorSet(android.animation.AnimatorSet)

Example 22 with PropertyValuesHolder

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

the class KeyguardWidgetCarousel method animatePagesToNeutral.

void animatePagesToNeutral() {
    if (mChildrenTransformsAnimator != null) {
        mChildrenTransformsAnimator.cancel();
        mChildrenTransformsAnimator = null;
    }
    int count = getChildCount();
    PropertyValuesHolder alpha;
    PropertyValuesHolder outlineAlpha;
    PropertyValuesHolder rotationY;
    ArrayList<Animator> anims = new ArrayList<Animator>();
    for (int i = 0; i < count; i++) {
        KeyguardWidgetFrame child = getWidgetPageAt(i);
        boolean inVisibleRange = (i >= mCurrentPage - 1 && i <= mCurrentPage + 1);
        if (!inVisibleRange) {
            child.setRotationY(0f);
        }
        alpha = PropertyValuesHolder.ofFloat("contentAlpha", 1.0f);
        outlineAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER);
        rotationY = PropertyValuesHolder.ofFloat("rotationY", 0f);
        ObjectAnimator a = ObjectAnimator.ofPropertyValuesHolder(child, alpha, outlineAlpha, rotationY);
        child.setVisibility(VISIBLE);
        if (!inVisibleRange) {
            a.setInterpolator(mSlowFadeInterpolator);
        }
        anims.add(a);
    }
    int duration = REORDERING_ZOOM_IN_OUT_DURATION;
    mChildrenTransformsAnimator = new AnimatorSet();
    mChildrenTransformsAnimator.playTogether(anims);
    mChildrenTransformsAnimator.setDuration(duration);
    mChildrenTransformsAnimator.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ArrayList(java.util.ArrayList) PropertyValuesHolder(android.animation.PropertyValuesHolder) AnimatorSet(android.animation.AnimatorSet)

Example 23 with PropertyValuesHolder

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

the class KeyguardWidgetPager method animateOutlinesAndSidePages.

void animateOutlinesAndSidePages(final boolean show, int duration) {
    if (mChildrenOutlineFadeAnimation != null) {
        mChildrenOutlineFadeAnimation.cancel();
        mChildrenOutlineFadeAnimation = null;
    }
    int count = getChildCount();
    PropertyValuesHolder alpha;
    ArrayList<Animator> anims = new ArrayList<Animator>();
    if (duration == -1) {
        duration = show ? CHILDREN_OUTLINE_FADE_IN_DURATION : CHILDREN_OUTLINE_FADE_OUT_DURATION;
    }
    int curPage = getNextPage();
    for (int i = 0; i < count; i++) {
        float finalContentAlpha;
        if (show) {
            finalContentAlpha = getAlphaForPage(mScreenCenter, i, true);
        } else if (!show && i == curPage) {
            finalContentAlpha = 1f;
        } else {
            finalContentAlpha = 0f;
        }
        KeyguardWidgetFrame child = getWidgetPageAt(i);
        alpha = PropertyValuesHolder.ofFloat("contentAlpha", finalContentAlpha);
        ObjectAnimator a = ObjectAnimator.ofPropertyValuesHolder(child, alpha);
        anims.add(a);
        float finalOutlineAlpha = show ? getOutlineAlphaForPage(mScreenCenter, i, true) : 0f;
        child.fadeFrame(this, show, finalOutlineAlpha, duration);
    }
    mChildrenOutlineFadeAnimation = new AnimatorSet();
    mChildrenOutlineFadeAnimation.playTogether(anims);
    mChildrenOutlineFadeAnimation.setDuration(duration);
    mChildrenOutlineFadeAnimation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            if (show) {
                enablePageContentLayers();
            }
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!show) {
                disablePageContentLayers();
                KeyguardWidgetFrame frame = getWidgetPageAt(mWidgetToResetAfterFadeOut);
                if (frame != null && !(frame == getWidgetPageAt(mCurrentPage) && mViewStateManager.isChallengeOverlapping())) {
                    frame.resetSize();
                }
                mWidgetToResetAfterFadeOut = -1;
                mShowingInitialHints = false;
            }
            updateWidgetFramesImportantForAccessibility();
        }
    });
    mChildrenOutlineFadeAnimation.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ArrayList(java.util.ArrayList) PropertyValuesHolder(android.animation.PropertyValuesHolder) AnimatorSet(android.animation.AnimatorSet)

Example 24 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project UltimateAndroid by cymcsg.

the class AnimationUtils method leftRightShake.

/**
     * Shake the view from left to right
     *
     * @param view
     * @return
     */
public static ObjectAnimator leftRightShake(View view) {
    // int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium);
    int delta = 40;
    PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X, Keyframe.ofFloat(0f, 0), Keyframe.ofFloat(.10f, -delta), Keyframe.ofFloat(.26f, delta), Keyframe.ofFloat(.42f, -delta), Keyframe.ofFloat(.58f, delta), Keyframe.ofFloat(.74f, -delta), Keyframe.ofFloat(.90f, delta), Keyframe.ofFloat(1f, 0f));
    return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).setDuration(500);
}
Also used : PropertyValuesHolder(android.animation.PropertyValuesHolder)

Example 25 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project UltimateAndroid by cymcsg.

the class AnimationUtils method nope.

public static ObjectAnimator nope(View view) {
    // int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium);
    int delta = 40;
    PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X, Keyframe.ofFloat(0f, 0), Keyframe.ofFloat(.10f, -delta), Keyframe.ofFloat(.26f, delta), Keyframe.ofFloat(.42f, -delta), Keyframe.ofFloat(.58f, delta), Keyframe.ofFloat(.74f, -delta), Keyframe.ofFloat(.90f, delta), Keyframe.ofFloat(1f, 0f));
    return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).setDuration(500);
}
Also used : PropertyValuesHolder(android.animation.PropertyValuesHolder)

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