Search in sources :

Example 26 with Interpolator

use of android.view.animation.Interpolator in project android_frameworks_base by ResurrectionRemix.

the class NotificationStackScrollLayout method startTopAnimation.

private void startTopAnimation() {
    int previousEndValue = mEndAnimationRect.top;
    int newEndValue = mBackgroundBounds.top;
    ObjectAnimator previousAnimator = mTopAnimator;
    if (previousAnimator != null && previousEndValue == newEndValue) {
        return;
    }
    if (!mAnimateNextBackgroundTop) {
        // just a local update was performed
        if (previousAnimator != null) {
            // we need to increase all animation keyframes of the previous animator by the
            // relative change to the end value
            int previousStartValue = mStartAnimationRect.top;
            PropertyValuesHolder[] values = previousAnimator.getValues();
            values[0].setIntValues(previousStartValue, newEndValue);
            mStartAnimationRect.top = previousStartValue;
            mEndAnimationRect.top = newEndValue;
            previousAnimator.setCurrentPlayTime(previousAnimator.getCurrentPlayTime());
            return;
        } else {
            // no new animation needed, let's just apply the value
            setBackgroundTop(newEndValue);
            return;
        }
    }
    if (previousAnimator != null) {
        previousAnimator.cancel();
    }
    ObjectAnimator animator = ObjectAnimator.ofInt(this, "backgroundTop", mCurrentBounds.top, newEndValue);
    Interpolator interpolator = Interpolators.FAST_OUT_SLOW_IN;
    animator.setInterpolator(interpolator);
    animator.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
    // remove the tag when the animation is finished
    animator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mStartAnimationRect.top = -1;
            mEndAnimationRect.top = -1;
            mTopAnimator = null;
        }
    });
    animator.start();
    mStartAnimationRect.top = mCurrentBounds.top;
    mEndAnimationRect.top = newEndValue;
    mTopAnimator = animator;
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) TimeAnimator(android.animation.TimeAnimator) ValueAnimator(android.animation.ValueAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PropertyValuesHolder(android.animation.PropertyValuesHolder) Interpolator(android.view.animation.Interpolator) Paint(android.graphics.Paint)

Example 27 with Interpolator

use of android.view.animation.Interpolator in project android_frameworks_base by ResurrectionRemix.

the class AnimatorInflater method loadAnimator.

/**
     * Creates a new animation whose parameters come from the specified context
     * and attributes set.
     *
     * @param res The resources
     * @param attrs The set of attributes holding the animation parameters
     * @param anim Null if this is a ValueAnimator, otherwise this is an
     *            ObjectAnimator
     */
private static ValueAnimator loadAnimator(Resources res, Theme theme, AttributeSet attrs, ValueAnimator anim, float pathErrorScale) throws NotFoundException {
    TypedArray arrayAnimator = null;
    TypedArray arrayObjectAnimator = null;
    if (theme != null) {
        arrayAnimator = theme.obtainStyledAttributes(attrs, R.styleable.Animator, 0, 0);
    } else {
        arrayAnimator = res.obtainAttributes(attrs, R.styleable.Animator);
    }
    // If anim is not null, then it is an object animator.
    if (anim != null) {
        if (theme != null) {
            arrayObjectAnimator = theme.obtainStyledAttributes(attrs, R.styleable.PropertyAnimator, 0, 0);
        } else {
            arrayObjectAnimator = res.obtainAttributes(attrs, R.styleable.PropertyAnimator);
        }
        anim.appendChangingConfigurations(arrayObjectAnimator.getChangingConfigurations());
    }
    if (anim == null) {
        anim = new ValueAnimator();
    }
    anim.appendChangingConfigurations(arrayAnimator.getChangingConfigurations());
    parseAnimatorFromTypeArray(anim, arrayAnimator, arrayObjectAnimator, pathErrorScale);
    final int resID = arrayAnimator.getResourceId(R.styleable.Animator_interpolator, 0);
    if (resID > 0) {
        final Interpolator interpolator = AnimationUtils.loadInterpolator(res, theme, resID);
        if (interpolator instanceof BaseInterpolator) {
            anim.appendChangingConfigurations(((BaseInterpolator) interpolator).getChangingConfiguration());
        }
        anim.setInterpolator(interpolator);
    }
    arrayAnimator.recycle();
    if (arrayObjectAnimator != null) {
        arrayObjectAnimator.recycle();
    }
    return anim;
}
Also used : TypedArray(android.content.res.TypedArray) BaseInterpolator(android.view.animation.BaseInterpolator) Interpolator(android.view.animation.Interpolator) BaseInterpolator(android.view.animation.BaseInterpolator)

Example 28 with Interpolator

use of android.view.animation.Interpolator in project android_frameworks_base by ResurrectionRemix.

the class AssistInteractionSession method playAssistAnimation.

private void playAssistAnimation() {
    Interpolator linearOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(), android.R.interpolator.linear_out_slow_in);
    Interpolator fastOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(), android.R.interpolator.fast_out_slow_in);
    mScrim.setAlpha(0f);
    mScrim.animate().alpha(1f).setStartDelay(100).setDuration(500);
    mBackground.setTranslationY(50 * mDensity);
    mBackground.animate().translationY(0).setDuration(300).setInterpolator(linearOutSlowIn);
    int centerX = mBackground.getWidth() / 2;
    int centerY = (int) (mBackground.getHeight() / 5 * 3.8f);
    int radius = (int) Math.sqrt(centerX * centerX + centerY * centerY) + 1;
    Animator animator = ViewAnimationUtils.createCircularReveal(mBackground, centerX, centerY, 0, radius);
    animator.setDuration(300);
    animator.setInterpolator(fastOutSlowIn);
    animator.start();
    ValueAnimator colorAnim = ValueAnimator.ofArgb(Color.WHITE, 0xffe0e0e0);
    colorAnim.setDuration(300);
    colorAnim.setInterpolator(fastOutSlowIn);
    colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mBackground.setBackgroundColor((Integer) animation.getAnimatedValue());
        }
    });
    colorAnim.start();
    mCard1.setY(mBackground.getHeight());
    mCard2.setTranslationY(mCard1.getTranslationY());
    mCard1.animate().translationY(0).setDuration(500).setInterpolator(linearOutSlowIn).setStartDelay(100);
    mCard2.animate().translationY(0).setInterpolator(linearOutSlowIn).setStartDelay(150).setDuration(500);
    mNavbarScrim.setAlpha(0f);
    mNavbarScrim.animate().alpha(1f).setDuration(500).setStartDelay(100);
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) Interpolator(android.view.animation.Interpolator) ValueAnimator(android.animation.ValueAnimator)

Example 29 with Interpolator

use of android.view.animation.Interpolator in project ride-read-android by Ride-Read.

the class MapFragment method addSignInMarker.

private void addSignInMarker(LatLng latLng) {
    final Marker marker = addMarker(latLng);
    if (marker != null) {
        final long start = SystemClock.uptimeMillis();
        Projection proj = mAMap.getProjection();
        Point markerPoint = proj.toScreenLocation(latLng);
        markerPoint.offset(0, -500);
        final LatLng startLatLng = proj.fromScreenLocation(markerPoint);
        final long duration = 2000;
        final Interpolator interpolator = new BounceInterpolator();
        mHandler.post(new Runnable() {

            @Override
            public void run() {
                long elapsed = SystemClock.uptimeMillis() - start;
                float t = interpolator.getInterpolation((float) elapsed / duration);
                double lng = t * latLng.longitude + (1 - t) * startLatLng.longitude;
                double lat = t * latLng.latitude + (1 - t) * startLatLng.latitude;
                marker.setPosition(new LatLng(lat, lng));
                if (t < 1.0) {
                    mHandler.postDelayed(this, 16);
                }
            }
        });
    }
    mHandler.postDelayed(() -> {
        mSignInDialogFragment = SignInDialogFragment.newInstance(AMapLocationUtils.getLocDetail());
        mSignInDialogFragment.show(getFragmentManager(), "sign_in");
    }, 1000L);
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) Projection(com.amap.api.maps.Projection) BounceInterpolator(android.view.animation.BounceInterpolator) Interpolator(android.view.animation.Interpolator) Marker(com.amap.api.maps.model.Marker) LatLonPoint(com.amap.api.services.core.LatLonPoint) Point(android.graphics.Point) LatLng(com.amap.api.maps.model.LatLng)

Example 30 with Interpolator

use of android.view.animation.Interpolator in project android_frameworks_base by ResurrectionRemix.

the class KeyguardAffordanceView method setCircleRadius.

private void setCircleRadius(float circleRadius, boolean slowAnimation, boolean noAnimation) {
    // Check if we need a new animation
    boolean radiusHidden = (mCircleAnimator != null && mCircleWillBeHidden) || (mCircleAnimator == null && mCircleRadius == 0.0f);
    boolean nowHidden = circleRadius == 0.0f;
    boolean radiusNeedsAnimation = (radiusHidden != nowHidden) && !noAnimation;
    if (!radiusNeedsAnimation) {
        if (mCircleAnimator == null) {
            mCircleRadius = circleRadius;
            updateIconColor();
            invalidate();
            if (nowHidden) {
                if (mPreviewView != null) {
                    mPreviewView.setVisibility(View.INVISIBLE);
                }
            }
        } else if (!mCircleWillBeHidden) {
            // We just update the end value
            float diff = circleRadius - mMinBackgroundRadius;
            PropertyValuesHolder[] values = mCircleAnimator.getValues();
            values[0].setFloatValues(mCircleStartValue + diff, circleRadius);
            mCircleAnimator.setCurrentPlayTime(mCircleAnimator.getCurrentPlayTime());
        }
    } else {
        cancelAnimator(mCircleAnimator);
        cancelAnimator(mPreviewClipper);
        ValueAnimator animator = getAnimatorToRadius(circleRadius);
        Interpolator interpolator = circleRadius == 0.0f ? Interpolators.FAST_OUT_LINEAR_IN : Interpolators.LINEAR_OUT_SLOW_IN;
        animator.setInterpolator(interpolator);
        long duration = 250;
        if (!slowAnimation) {
            float durationFactor = Math.abs(mCircleRadius - circleRadius) / (float) mMinBackgroundRadius;
            duration = (long) (CIRCLE_APPEAR_DURATION * durationFactor);
            duration = Math.min(duration, CIRCLE_DISAPPEAR_MAX_DURATION);
        }
        animator.setDuration(duration);
        animator.start();
        if (mPreviewView != null && mPreviewView.getVisibility() == View.VISIBLE) {
            mPreviewView.setVisibility(View.VISIBLE);
            mPreviewClipper = ViewAnimationUtils.createCircularReveal(mPreviewView, getLeft() + mCenterX, getTop() + mCenterY, mCircleRadius, circleRadius);
            mPreviewClipper.setInterpolator(interpolator);
            mPreviewClipper.setDuration(duration);
            mPreviewClipper.addListener(mClipEndListener);
            mPreviewClipper.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    mPreviewView.setVisibility(View.INVISIBLE);
                }
            });
            mPreviewClipper.start();
        }
    }
}
Also used : Animator(android.animation.Animator) RenderNodeAnimator(android.view.RenderNodeAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Interpolator(android.view.animation.Interpolator) ValueAnimator(android.animation.ValueAnimator)

Aggregations

Interpolator (android.view.animation.Interpolator)229 Animator (android.animation.Animator)60 ValueAnimator (android.animation.ValueAnimator)49 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)46 ObjectAnimator (android.animation.ObjectAnimator)39 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)25 PathInterpolator (android.view.animation.PathInterpolator)25 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)23 LinearInterpolator (android.view.animation.LinearInterpolator)18 Paint (android.graphics.Paint)17 View (android.view.View)17 PropertyValuesHolder (android.animation.PropertyValuesHolder)16 FloatKeyframe (com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe)16 IntKeyframe (com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe)16 TimeAnimator (android.animation.TimeAnimator)15 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)14 TypedArray (android.content.res.TypedArray)14 Animation (android.view.animation.Animation)13 AnimatorSet (android.animation.AnimatorSet)12 TimeInterpolator (android.animation.TimeInterpolator)11