Search in sources :

Example 66 with Transformation

use of android.view.animation.Transformation in project ListenerMusicPlayer by hefuyicoder.

the class PanelSlideListener method animateToNormal.

private void animateToNormal() {
    //album art
    CoordinatorLayout.LayoutParams imageLayout = (CoordinatorLayout.LayoutParams) albumImage.getLayoutParams();
    imageLayout.height = screenWidth;
    imageLayout.width = screenWidth;
    albumImage.setImageDrawable(albumImageDrawable);
    albumImage.setLayoutParams(imageLayout);
    if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
        albumImage.setForeground(ScrimUtil.makeCubicGradientScrimDrawable(//颜色
        nowPlayingCardColor, //渐变层数
        8, //起始方向
        Gravity.CENTER_HORIZONTAL));
    }
    //animate title and artist
    Animation contentAnimation = new Animation() {

        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            content.setTranslationY(contentFullEndTranslationY + (contentNormalEndTranslationY - contentFullEndTranslationY) * interpolatedTime);
            artist.setTranslationY(artistFullEndTranslationY + (artistNormalEndTranslationY - artistFullEndTranslationY) * interpolatedTime);
        }
    };
    contentAnimation.setDuration(300);
    artist.startAnimation(contentAnimation);
    //adjust lyricview
    Animation lyricAnimation = new Animation() {

        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) lyricView.getLayoutParams();
            layoutParams.height = (int) (lyricFullHeight - (lyricFullHeight - lyricLineHeight) * interpolatedTime);
            lyricView.setLayoutParams(layoutParams);
            lyricView.setTranslationY(lyricFullTranslationY + (lyricLineEndTranslationY - lyricFullTranslationY) * interpolatedTime);
        }
    };
    lyricAnimation.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            lyricView.setPlayable(false);
            lyricView.setHighLightTextColor(lyricView.getDefaultColor());
            lyricView.setTouchable(false);
            lyricView.setClickable(false);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    lyricAnimation.setDuration(300);
    lyricView.setPlayable(false);
    lyricView.startAnimation(lyricAnimation);
    mStatus = Status.EXPANDED;
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Example 67 with Transformation

use of android.view.animation.Transformation in project UltimateAndroid by cymcsg.

the class SearchDrawableActivity method startUpAnimation.

private void startUpAnimation() {
    mStartAnimation = new Animation() {

        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            if (back) {
                searchDrawable.setPhase(1 - interpolatedTime);
                textView.setAlpha(0f);
                textView.setVisibility(View.GONE);
            } else {
                searchDrawable.setPhase(interpolatedTime);
                textView.animate().alpha(1f).setDuration(100).setInterpolator(new AccelerateDecelerateInterpolator());
                textView.setVisibility(View.VISIBLE);
            }
        }
    };
    mStartAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    mStartAnimation.setDuration(START_ANIMATION_DURATION);
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator)

Example 68 with Transformation

use of android.view.animation.Transformation in project UltimateAndroid by cymcsg.

the class MaterialProgressDrawable method setupAnimators.

private void setupAnimators() {
    final Ring ring = mRing;
    final Animation finishRingAnimation = new Animation() {

        public void applyTransformation(float interpolatedTime, Transformation t) {
            // shrink back down and complete a full rotation before starting other circles
            // Rotation goes between [0..1].
            float targetRotation = (float) (Math.floor(ring.getStartingRotation() / MAX_PROGRESS_ARC) + 1f);
            final float startTrim = ring.getStartingStartTrim() + (ring.getStartingEndTrim() - ring.getStartingStartTrim()) * interpolatedTime;
            ring.setStartTrim(startTrim);
            final float rotation = ring.getStartingRotation() + ((targetRotation - ring.getStartingRotation()) * interpolatedTime);
            ring.setRotation(rotation);
            ring.setArrowScale(1 - interpolatedTime);
        }
    };
    finishRingAnimation.setInterpolator(EASE_INTERPOLATOR);
    finishRingAnimation.setDuration(ANIMATION_DURATION / 2);
    finishRingAnimation.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            ring.goToNextColor();
            ring.storeOriginals();
            ring.setShowArrow(false);
            mParent.startAnimation(mAnimation);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    final Animation animation = new Animation() {

        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            // The minProgressArc is calculated from 0 to create an angle that
            // matches the stroke width.
            final float minProgressArc = (float) Math.toRadians(ring.getStrokeWidth() / (2 * Math.PI * ring.getCenterRadius()));
            final float startingEndTrim = ring.getStartingEndTrim();
            final float startingTrim = ring.getStartingStartTrim();
            final float startingRotation = ring.getStartingRotation();
            // Offset the minProgressArc to where the endTrim is located.
            final float minArc = MAX_PROGRESS_ARC - minProgressArc;
            final float endTrim = startingEndTrim + (minArc * START_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime));
            ring.setEndTrim(endTrim);
            final float startTrim = startingTrim + (MAX_PROGRESS_ARC * END_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime));
            ring.setStartTrim(startTrim);
            final float rotation = startingRotation + (0.25f * interpolatedTime);
            ring.setRotation(rotation);
            float groupRotation = ((720.0f / NUM_POINTS) * interpolatedTime) + (720.0f * (mRotationCount / NUM_POINTS));
            setRotation(groupRotation);
        }
    };
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.RESTART);
    animation.setInterpolator(LINEAR_INTERPOLATOR);
    animation.setDuration(ANIMATION_DURATION);
    animation.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
            mRotationCount = 0;
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        // do nothing
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            ring.storeOriginals();
            ring.goToNextColor();
            ring.setStartTrim(ring.getEndTrim());
            mRotationCount = (mRotationCount + 1) % (NUM_POINTS);
        }
    });
    mFinishAnimation = finishRingAnimation;
    mAnimation = animation;
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Example 69 with Transformation

use of android.view.animation.Transformation in project UltimateAndroid by cymcsg.

the class MaterialProgressDrawable method setupAnimators.

private void setupAnimators() {
    final Ring ring = mRing;
    final Animation finishRingAnimation = new Animation() {

        public void applyTransformation(float interpolatedTime, Transformation t) {
            // shrink back down and complete a full rotation before starting other circles
            // Rotation goes between [0..1].
            float targetRotation = (float) (Math.floor(ring.getStartingRotation() / MAX_PROGRESS_ARC) + 1f);
            final float startTrim = ring.getStartingStartTrim() + (ring.getStartingEndTrim() - ring.getStartingStartTrim()) * interpolatedTime;
            ring.setStartTrim(startTrim);
            final float rotation = ring.getStartingRotation() + ((targetRotation - ring.getStartingRotation()) * interpolatedTime);
            ring.setRotation(rotation);
            ring.setArrowScale(1 - interpolatedTime);
        }
    };
    finishRingAnimation.setInterpolator(EASE_INTERPOLATOR);
    finishRingAnimation.setDuration(ANIMATION_DURATION / 2);
    finishRingAnimation.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            ring.goToNextColor();
            ring.storeOriginals();
            ring.setShowArrow(false);
            mParent.startAnimation(mAnimation);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    final Animation animation = new Animation() {

        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            // The minProgressArc is calculated from 0 to create an angle that
            // matches the stroke width.
            final float minProgressArc = (float) Math.toRadians(ring.getStrokeWidth() / (2 * Math.PI * ring.getCenterRadius()));
            final float startingEndTrim = ring.getStartingEndTrim();
            final float startingTrim = ring.getStartingStartTrim();
            final float startingRotation = ring.getStartingRotation();
            // Offset the minProgressArc to where the endTrim is located.
            final float minArc = MAX_PROGRESS_ARC - minProgressArc;
            final float endTrim = startingEndTrim + (minArc * START_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime));
            ring.setEndTrim(endTrim);
            final float startTrim = startingTrim + (MAX_PROGRESS_ARC * END_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime));
            ring.setStartTrim(startTrim);
            final float rotation = startingRotation + (0.25f * interpolatedTime);
            ring.setRotation(rotation);
            float groupRotation = ((720.0f / NUM_POINTS) * interpolatedTime) + (720.0f * (mRotationCount / NUM_POINTS));
            setRotation(groupRotation);
        }
    };
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.RESTART);
    animation.setInterpolator(LINEAR_INTERPOLATOR);
    animation.setDuration(ANIMATION_DURATION);
    animation.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
            mRotationCount = 0;
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        // do nothing
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            ring.storeOriginals();
            ring.goToNextColor();
            ring.setStartTrim(ring.getEndTrim());
            mRotationCount = (mRotationCount + 1) % (NUM_POINTS);
        }
    });
    mFinishAnimation = finishRingAnimation;
    mAnimation = animation;
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Example 70 with Transformation

use of android.view.animation.Transformation in project remusic by aa112901.

the class SwipeRefreshLayout method startScaleDownReturnToStartAnimation.

private void startScaleDownReturnToStartAnimation(int from, AnimationListener listener) {
    mFrom = from;
    mStartingScale = ViewCompat.getScaleX(mHeadViewContainer);
    mScaleDownToStartAnimation = new Animation() {

        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            float targetScale = (mStartingScale + (-mStartingScale * interpolatedTime));
            setAnimationProgress(targetScale);
            moveToStart(interpolatedTime);
        }
    };
    mScaleDownToStartAnimation.setDuration(SCALE_DOWN_DURATION);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mScaleDownToStartAnimation);
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Aggregations

Transformation (android.view.animation.Transformation)108 Animation (android.view.animation.Animation)61 Point (android.graphics.Point)24 Paint (android.graphics.Paint)22 AlphaAnimation (android.view.animation.AlphaAnimation)18 Animatable (android.graphics.drawable.Animatable)17 LinearInterpolator (android.view.animation.LinearInterpolator)17 Matrix (android.graphics.Matrix)15 RectF (android.graphics.RectF)13 Rect (android.graphics.Rect)7 Bitmap (android.graphics.Bitmap)6 MagnificationSpec (android.view.MagnificationSpec)5 View (android.view.View)3 BezierDecelerateInterpolator (acr.browser.lightning.interpolator.BezierDecelerateInterpolator)2 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)2 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)2 WindowPanel (com.android.server.wm.WindowManagerService.WindowPanel)2 Fragment (android.app.Fragment)1 FragmentTransaction (android.app.FragmentTransaction)1 Intent (android.content.Intent)1