Search in sources :

Example 86 with Interpolator

use of android.view.animation.Interpolator in project android_packages_apps_Dialer by LineageOS.

the class SwipeButtonView method setCircleRadius.

private void setCircleRadius(float circleRadius, boolean slowAnimation, boolean noAnimation) {
    // Check if we need a new animation
    boolean radiusHidden = (circleAnimator != null && circleWillBeHidden) || (circleAnimator == null && this.circleRadius == 0.0f);
    boolean nowHidden = circleRadius == 0.0f;
    boolean radiusNeedsAnimation = (radiusHidden != nowHidden) && !noAnimation;
    if (!radiusNeedsAnimation) {
        if (circleAnimator == null) {
            this.circleRadius = circleRadius;
            updateIconColor();
            invalidate();
            if (nowHidden) {
                if (previewView != null) {
                    previewView.setVisibility(View.INVISIBLE);
                }
            }
        } else if (!circleWillBeHidden) {
            // We just update the end value
            float diff = circleRadius - minBackgroundRadius;
            PropertyValuesHolder[] values = circleAnimator.getValues();
            values[0].setFloatValues(circleStartValue + diff, circleRadius);
            circleAnimator.setCurrentPlayTime(circleAnimator.getCurrentPlayTime());
        }
    } else {
        cancelAnimator(circleAnimator);
        cancelAnimator(previewClipper);
        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(this.circleRadius - circleRadius) / (float) minBackgroundRadius;
            duration = (long) (CIRCLE_APPEAR_DURATION * durationFactor);
            duration = Math.min(duration, CIRCLE_DISAPPEAR_MAX_DURATION);
        }
        animator.setDuration(duration);
        animator.start();
        if (previewView != null && previewView.getVisibility() == View.VISIBLE) {
            previewView.setVisibility(View.VISIBLE);
            previewClipper = ViewAnimationUtils.createCircularReveal(previewView, getLeft() + centerX, getTop() + centerY, this.circleRadius, circleRadius);
            previewClipper.setInterpolator(interpolator);
            previewClipper.setDuration(duration);
            previewClipper.addListener(clipEndListener);
            previewClipper.addListener(new AnimatorListenerAdapter() {

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

Example 87 with Interpolator

use of android.view.animation.Interpolator in project android_packages_apps_Settings by omnirom.

the class PreviewPagerAdapter method setVisibility.

private void setVisibility(final View view, final int visibility, boolean animate) {
    final float alpha = (visibility == View.VISIBLE ? 1.0f : 0.0f);
    if (!animate) {
        view.setAlpha(alpha);
        view.setVisibility(visibility);
    } else {
        final Interpolator interpolator = (visibility == View.VISIBLE ? FADE_IN_INTERPOLATOR : FADE_OUT_INTERPOLATOR);
        if (visibility == View.VISIBLE) {
            // Fade in animation.
            view.animate().alpha(alpha).setInterpolator(FADE_IN_INTERPOLATOR).setDuration(CROSS_FADE_DURATION_MS).setListener(new PreviewFrameAnimatorListener()).withStartAction(new Runnable() {

                @Override
                public void run() {
                    view.setVisibility(visibility);
                }
            });
        } else {
            // Fade out animation.
            view.animate().alpha(alpha).setInterpolator(FADE_OUT_INTERPOLATOR).setDuration(CROSS_FADE_DURATION_MS).setListener(new PreviewFrameAnimatorListener()).withEndAction(new Runnable() {

                @Override
                public void run() {
                    view.setVisibility(visibility);
                }
            });
        }
    }
}
Also used : Interpolator(android.view.animation.Interpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator)

Example 88 with Interpolator

use of android.view.animation.Interpolator in project android_packages_apps_Settings by SudaMod.

the class PreviewPagerAdapter method setVisibility.

private void setVisibility(final View view, final int visibility, boolean animate) {
    final float alpha = (visibility == View.VISIBLE ? 1.0f : 0.0f);
    if (!animate) {
        view.setAlpha(alpha);
        view.setVisibility(visibility);
    } else {
        final Interpolator interpolator = (visibility == View.VISIBLE ? FADE_IN_INTERPOLATOR : FADE_OUT_INTERPOLATOR);
        if (visibility == View.VISIBLE) {
            // Fade in animation.
            view.animate().alpha(alpha).setInterpolator(FADE_IN_INTERPOLATOR).setDuration(CROSS_FADE_DURATION_MS).setListener(new PreviewFrameAnimatorListener()).withStartAction(new Runnable() {

                @Override
                public void run() {
                    view.setVisibility(visibility);
                }
            });
        } else {
            // Fade out animation.
            view.animate().alpha(alpha).setInterpolator(FADE_OUT_INTERPOLATOR).setDuration(CROSS_FADE_DURATION_MS).setListener(new PreviewFrameAnimatorListener()).withEndAction(new Runnable() {

                @Override
                public void run() {
                    view.setVisibility(visibility);
                }
            });
        }
    }
}
Also used : Interpolator(android.view.animation.Interpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator)

Example 89 with Interpolator

use of android.view.animation.Interpolator in project android_packages_apps_Dialer by MoKee.

the class SearchFragment method updatePosition.

/**
 * Updates the position and padding of the search fragment, depending on whether the dialpad is
 * shown. This can be optionally animated.
 * @param animate
 */
public void updatePosition(boolean animate) {
    // Use negative shadow height instead of 0 to account for the 9-patch's shadow.
    int startTranslationValue = mActivity.isDialpadShown() ? mActionBarHeight - mShadowHeight : -mShadowHeight;
    int endTranslationValue = 0;
    // Prevents ListView from being translated down after a rotation when the ActionBar is up.
    if (animate || mActivity.isActionBarShowing()) {
        endTranslationValue = mActivity.isDialpadShown() ? 0 : mActionBarHeight - mShadowHeight;
    }
    if (animate) {
        // If the dialpad will be shown, then this animation involves sliding the list up.
        final boolean slideUp = mActivity.isDialpadShown();
        Interpolator interpolator = slideUp ? AnimUtils.EASE_IN : AnimUtils.EASE_OUT;
        int duration = slideUp ? mShowDialpadDuration : mHideDialpadDuration;
        getView().setTranslationY(startTranslationValue);
        getView().animate().translationY(endTranslationValue).setInterpolator(interpolator).setDuration(duration).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animation) {
                if (!slideUp) {
                    resizeListView();
                }
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                if (slideUp) {
                    resizeListView();
                }
            }
        });
    } else {
        getView().setTranslationY(endTranslationValue);
        resizeListView();
    }
    // There is padding which should only be applied when the dialpad is not shown.
    int paddingTop = mActivity.isDialpadShown() ? 0 : mPaddingTop;
    final ListView listView = getListView();
    listView.setPaddingRelative(listView.getPaddingStart(), paddingTop, listView.getPaddingEnd(), listView.getPaddingBottom());
}
Also used : Animator(android.animation.Animator) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Interpolator(android.view.animation.Interpolator)

Example 90 with Interpolator

use of android.view.animation.Interpolator in project android_packages_apps_Gallery2 by LineageOS.

the class Animation method calculate.

public boolean calculate(long currentTimeMillis) {
    if (mStartTime == NO_ANIMATION)
        return false;
    if (mStartTime == ANIMATION_START)
        mStartTime = currentTimeMillis;
    int elapse = (int) (currentTimeMillis - mStartTime);
    float x = Utils.clamp((float) elapse / mDuration, 0f, 1f);
    Interpolator i = mInterpolator;
    onCalculate(i != null ? i.getInterpolation(x) : x);
    if (elapse >= mDuration)
        mStartTime = NO_ANIMATION;
    return mStartTime != NO_ANIMATION;
}
Also used : Interpolator(android.view.animation.Interpolator)

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