Search in sources :

Example 81 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 82 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 83 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)

Example 84 with AnimatorSet

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

the class PaperOnboardingEngine method createContentIconShowAnimation.

/**
     * @param currentContentIcon currently displayed view with icon
     * @param newContentIcon     newly created and prepared view to display
     * @return animator set with this animation
     */
protected AnimatorSet createContentIconShowAnimation(final View currentContentIcon, final View newContentIcon) {
    int positionDeltaPx = dpToPixels(CONTENT_ICON_POS_DELTA_Y_DP);
    AnimatorSet animations = new AnimatorSet();
    Animator currentContentMoveUp = ObjectAnimator.ofFloat(currentContentIcon, "y", 0, -positionDeltaPx);
    currentContentMoveUp.setDuration(ANIM_CONTENT_ICON_HIDE_TIME);
    currentContentMoveUp.addListener(new AnimatorEndListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mContentIconContainer.removeView(currentContentIcon);
        }
    });
    Animator currentContentFadeOut = ObjectAnimator.ofFloat(currentContentIcon, "alpha", 1, 0);
    currentContentFadeOut.setDuration(ANIM_CONTENT_ICON_HIDE_TIME);
    animations.playTogether(currentContentMoveUp, currentContentFadeOut);
    Animator newContentMoveUp = ObjectAnimator.ofFloat(newContentIcon, "y", positionDeltaPx, 0);
    newContentMoveUp.setDuration(ANIM_CONTENT_ICON_SHOW_TIME);
    Animator newContentFadeIn = ObjectAnimator.ofFloat(newContentIcon, "alpha", 0, 1);
    newContentFadeIn.setDuration(ANIM_CONTENT_ICON_SHOW_TIME);
    animations.playTogether(newContentMoveUp, newContentFadeIn);
    animations.setInterpolator(new DecelerateInterpolator());
    return animations;
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorEndListener(com.ramotion.paperonboarding.listeners.AnimatorEndListener) AnimatorSet(android.animation.AnimatorSet)

Example 85 with AnimatorSet

use of android.animation.AnimatorSet in project Titanic by RomainPiel.

the class Titanic method start.

public void start(final TitanicTextView textView) {
    final Runnable animate = new Runnable() {

        @Override
        public void run() {
            textView.setSinking(true);
            // horizontal animation. 200 = wave.png width
            ObjectAnimator maskXAnimator = ObjectAnimator.ofFloat(textView, "maskX", 0, 200);
            maskXAnimator.setRepeatCount(ValueAnimator.INFINITE);
            maskXAnimator.setDuration(1000);
            maskXAnimator.setStartDelay(0);
            int h = textView.getHeight();
            // vertical animation
            // maskY = 0 -> wave vertically centered
            // repeat mode REVERSE to go back and forth
            ObjectAnimator maskYAnimator = ObjectAnimator.ofFloat(textView, "maskY", h / 2, -h / 2);
            maskYAnimator.setRepeatCount(ValueAnimator.INFINITE);
            maskYAnimator.setRepeatMode(ValueAnimator.REVERSE);
            maskYAnimator.setDuration(10000);
            maskYAnimator.setStartDelay(0);
            // now play both animations together
            animatorSet = new AnimatorSet();
            animatorSet.playTogether(maskXAnimator, maskYAnimator);
            animatorSet.setInterpolator(new LinearInterpolator());
            animatorSet.addListener(new Animator.AnimatorListener() {

                @Override
                public void onAnimationStart(Animator animation) {
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    textView.setSinking(false);
                    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                        textView.postInvalidate();
                    } else {
                        textView.postInvalidateOnAnimation();
                    }
                    animatorSet = null;
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                }

                @Override
                public void onAnimationRepeat(Animator animation) {
                }
            });
            if (animatorListener != null) {
                animatorSet.addListener(animatorListener);
            }
            animatorSet.start();
        }
    };
    if (!textView.isSetUp()) {
        textView.setAnimationSetupCallback(new TitanicTextView.AnimationSetupCallback() {

            @Override
            public void onSetupAnimation(final TitanicTextView target) {
                animate.run();
            }
        });
    } else {
        animate.run();
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) LinearInterpolator(android.view.animation.LinearInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet)

Aggregations

AnimatorSet (android.animation.AnimatorSet)491 ObjectAnimator (android.animation.ObjectAnimator)343 Animator (android.animation.Animator)285 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)144 View (android.view.View)109 ValueAnimator (android.animation.ValueAnimator)103 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)52 ArrayList (java.util.ArrayList)50 Rect (android.graphics.Rect)43 ViewGroup (android.view.ViewGroup)42 ImageView (android.widget.ImageView)36 TextView (android.widget.TextView)32 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)26 PropertyValuesHolder (android.animation.PropertyValuesHolder)25 Paint (android.graphics.Paint)25 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)25 Bitmap (android.graphics.Bitmap)17 Point (android.graphics.Point)15 OvershootInterpolator (android.view.animation.OvershootInterpolator)15 BitmapDrawable (android.graphics.drawable.BitmapDrawable)14