Search in sources :

Example 86 with Transformation

use of android.view.animation.Transformation in project PhotoNoter by yydcdut.

the class MaterialProgressDrawable method setupAnimators.

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

        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            if (mFinishing) {
                applyFinishTranslation(interpolatedTime, ring);
            } else {
                // 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;
                float endTrim = startingEndTrim + (minArc * START_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime));
                float startTrim = startingTrim + (MAX_PROGRESS_ARC * END_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime));
                final float sweepTrim = endTrim - startTrim;
                //Avoid the ring to be a full circle
                if (Math.abs(sweepTrim) >= 1) {
                    endTrim = startTrim + 0.5f;
                }
                ring.setEndTrim(endTrim);
                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.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());
            if (mFinishing) {
                // finished closing the last ring from the swipe gesture; go
                // into progress mode
                mFinishing = false;
                animation.setDuration(ANIMATION_DURATION);
                ring.setShowArrow(false);
            } else {
                mRotationCount = (mRotationCount + 1) % (NUM_POINTS);
            }
        }
    });
    mAnimation = animation;
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Example 87 with Transformation

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

the class BasicUiUtils method expandViews.

public static void expandViews(final View v) {
    v.measure(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    final int targtetHeight = v.getMeasuredHeight();
    v.getLayoutParams().height = 0;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {

        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1 ? RelativeLayout.LayoutParams.WRAP_CONTENT : (int) (targtetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };
    // 1dp/ms
    a.setDuration((int) (targtetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Example 88 with Transformation

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

the class BasicUiUtils method collapseViews.

public static void collapseViews(final View v) {
    final int initialHeight = v.getMeasuredHeight();
    Animation a = new Animation() {

        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                v.setVisibility(View.GONE);
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };
    // 1dp/ms
    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density) * 1);
    v.startAnimation(a);
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Example 89 with Transformation

use of android.view.animation.Transformation in project android_frameworks_base by AOSPA.

the class ProgressBar method startAnimation.

/**
     * <p>Start the indeterminate progress animation.</p>
     */
void startAnimation() {
    if (getVisibility() != VISIBLE || getWindowVisibility() != VISIBLE) {
        return;
    }
    if (mIndeterminateDrawable instanceof Animatable) {
        mShouldStartAnimationDrawable = true;
        mHasAnimation = false;
    } else {
        mHasAnimation = true;
        if (mInterpolator == null) {
            mInterpolator = new LinearInterpolator();
        }
        if (mTransformation == null) {
            mTransformation = new Transformation();
        } else {
            mTransformation.clear();
        }
        if (mAnimation == null) {
            mAnimation = new AlphaAnimation(0.0f, 1.0f);
        } else {
            mAnimation.reset();
        }
        mAnimation.setRepeatMode(mBehavior);
        mAnimation.setRepeatCount(Animation.INFINITE);
        mAnimation.setDuration(mDuration);
        mAnimation.setInterpolator(mInterpolator);
        mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
    }
    postInvalidate();
}
Also used : Transformation(android.view.animation.Transformation) LinearInterpolator(android.view.animation.LinearInterpolator) Animatable(android.graphics.drawable.Animatable) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 90 with Transformation

use of android.view.animation.Transformation in project BookReader by JustWayward.

the class SwipeRefreshLayout method startScaleUpAnimation.

private void startScaleUpAnimation(AnimationListener listener) {
    mCircleView.setVisibility(View.VISIBLE);
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        // Pre API 11, alpha is used in place of scale up to show the
        // progress circle appearing.
        // Don't adjust the alpha during appearance otherwise.
        mProgress.setAlpha(MAX_ALPHA);
    }
    mScaleAnimation = new Animation() {

        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mScaleAnimation);
}
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