Search in sources :

Example 21 with AnimatorSet

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

the class KeyButtonView method setPressed.

public void setPressed(boolean pressed) {
    if (mGlowBG != null) {
        if (pressed != isPressed()) {
            if (mPressedAnim != null && mPressedAnim.isRunning()) {
                mPressedAnim.cancel();
            }
            final AnimatorSet as = mPressedAnim = new AnimatorSet();
            if (pressed) {
                if (mGlowScale < GLOW_MAX_SCALE_FACTOR)
                    mGlowScale = GLOW_MAX_SCALE_FACTOR;
                if (mGlowAlpha < BUTTON_QUIESCENT_ALPHA)
                    mGlowAlpha = BUTTON_QUIESCENT_ALPHA;
                setDrawingAlpha(1f);
                as.playTogether(ObjectAnimator.ofFloat(this, "glowAlpha", 1f), ObjectAnimator.ofFloat(this, "glowScale", GLOW_MAX_SCALE_FACTOR));
                as.setDuration(50);
            } else {
                mOldDrawingAlpha = BUTTON_QUIESCENT_ALPHA;
                as.playTogether(ObjectAnimator.ofFloat(this, "glowAlpha", 0f), ObjectAnimator.ofFloat(this, "glowScale", 1f), ObjectAnimator.ofFloat(this, "drawingAlpha", BUTTON_QUIESCENT_ALPHA));
                as.addListener(new Animator.AnimatorListener() {

                    @Override
                    public void onAnimationStart(Animator animation) {
                    }

                    @Override
                    public void onAnimationCancel(Animator animation) {
                    }

                    @Override
                    public void onAnimationRepeat(Animator animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        setDrawingAlpha(BUTTON_QUIESCENT_ALPHA);
                    }
                });
                as.setDuration(500);
            }
            as.start();
        }
    }
    super.setPressed(pressed);
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet)

Example 22 with AnimatorSet

use of android.animation.AnimatorSet 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 23 with AnimatorSet

use of android.animation.AnimatorSet 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 24 with AnimatorSet

use of android.animation.AnimatorSet 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 25 with AnimatorSet

use of android.animation.AnimatorSet in project paper-onboarding-android by Ramotion.

the class PaperOnboardingEngine method createBGAnimatorSet.

/**
     * @param color new background color for new
     * @return animator set with background color circular reveal animation
     */
protected AnimatorSet createBGAnimatorSet(final int color) {
    final View bgColorView = new ImageView(mAppContext);
    bgColorView.setLayoutParams(new RelativeLayout.LayoutParams(mRootLayout.getWidth(), mRootLayout.getHeight()));
    bgColorView.setBackgroundColor(color);
    mBackgroundContainer.addView(bgColorView);
    int[] pos = calculateCurrentCenterCoordinatesOfPagerElement(mActiveElementIndex);
    float finalRadius = mRootLayout.getWidth() > mRootLayout.getHeight() ? mRootLayout.getWidth() : mRootLayout.getHeight();
    AnimatorSet bgAnimSet = new AnimatorSet();
    Animator fadeIn = ObjectAnimator.ofFloat(bgColorView, "alpha", 0, 1);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Animator circularReveal = ViewAnimationUtils.createCircularReveal(bgColorView, pos[0], pos[1], 0, finalRadius);
        circularReveal.setInterpolator(new AccelerateInterpolator());
        bgAnimSet.playTogether(circularReveal, fadeIn);
    } else {
        bgAnimSet.playTogether(fadeIn);
    }
    bgAnimSet.setDuration(ANIM_BACKGROUND_TIME);
    bgAnimSet.addListener(new AnimatorEndListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mRootLayout.setBackgroundColor(color);
            bgColorView.setVisibility(View.GONE);
            mBackgroundContainer.removeView(bgColorView);
        }
    });
    return bgAnimSet;
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimatorEndListener(com.ramotion.paperonboarding.listeners.AnimatorEndListener) RelativeLayout(android.widget.RelativeLayout) AnimatorSet(android.animation.AnimatorSet) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

AnimatorSet (android.animation.AnimatorSet)480 ObjectAnimator (android.animation.ObjectAnimator)336 Animator (android.animation.Animator)278 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)139 View (android.view.View)107 ValueAnimator (android.animation.ValueAnimator)103 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)52 ArrayList (java.util.ArrayList)47 Rect (android.graphics.Rect)43 ViewGroup (android.view.ViewGroup)42 ImageView (android.widget.ImageView)36 TextView (android.widget.TextView)32 PropertyValuesHolder (android.animation.PropertyValuesHolder)25 Paint (android.graphics.Paint)25 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)25 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)23 Bitmap (android.graphics.Bitmap)17 LinearInterpolator (android.view.animation.LinearInterpolator)15 OvershootInterpolator (android.view.animation.OvershootInterpolator)15 Point (android.graphics.Point)14