Search in sources :

Example 6 with TimeInterpolator

use of android.animation.TimeInterpolator in project assertj-android by square.

the class ViewPropertyAnimatorAssert method hasInterpolator.

@TargetApi(JELLY_BEAN_MR2)
public ViewPropertyAnimatorAssert hasInterpolator(TimeInterpolator interpolator) {
    isNotNull();
    TimeInterpolator actualInterpolator = actual.getInterpolator();
    //
    assertThat(actualInterpolator).overridingErrorMessage("Expected interpolator <%s> but was <%s>.", interpolator, //
    actualInterpolator).isEqualTo(interpolator);
    return this;
}
Also used : TimeInterpolator(android.animation.TimeInterpolator) TargetApi(android.annotation.TargetApi)

Example 7 with TimeInterpolator

use of android.animation.TimeInterpolator in project weex-example by KalicyZhou.

the class DimensionUpdateListener method onAnimationUpdate.

@Override
public void onAnimationUpdate(ValueAnimator animation) {
    if (view.getLayoutParams() != null) {
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        TimeInterpolator interpolator = animation.getInterpolator();
        float fraction = animation.getAnimatedFraction();
        int preWidth = layoutParams.width;
        int preHeight = layoutParams.height;
        if (width != null) {
            layoutParams.width = intEvaluator.evaluate(interpolator.getInterpolation(fraction), width.first, width.second);
        }
        if (height != null) {
            layoutParams.height = intEvaluator.evaluate(interpolator.getInterpolation(fraction), height.first, height.second);
        }
        if (preHeight != layoutParams.height || preWidth != layoutParams.width) {
            view.requestLayout();
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) TimeInterpolator(android.animation.TimeInterpolator)

Example 8 with TimeInterpolator

use of android.animation.TimeInterpolator in project android_frameworks_base by AOSPA.

the class ViewPropertyAnimatorRT method doStartAnimation.

private void doStartAnimation(ViewPropertyAnimator parent) {
    int size = parent.mPendingAnimations.size();
    long startDelay = parent.getStartDelay();
    long duration = parent.getDuration();
    TimeInterpolator interpolator = parent.getInterpolator();
    if (interpolator == null) {
        // Documented to be LinearInterpolator in ValueAnimator.setInterpolator
        interpolator = sLinearInterpolator;
    }
    if (!RenderNodeAnimator.isNativeInterpolator(interpolator)) {
        interpolator = new FallbackLUTInterpolator(interpolator, duration);
    }
    for (int i = 0; i < size; i++) {
        NameValuesHolder holder = parent.mPendingAnimations.get(i);
        int property = RenderNodeAnimator.mapViewPropertyToRenderProperty(holder.mNameConstant);
        final float finalValue = holder.mFromValue + holder.mDeltaValue;
        RenderNodeAnimator animator = new RenderNodeAnimator(property, finalValue);
        animator.setStartDelay(startDelay);
        animator.setDuration(duration);
        animator.setInterpolator(interpolator);
        animator.setTarget(mView);
        animator.start();
        mAnimators[property] = animator;
    }
    parent.mPendingAnimations.clear();
}
Also used : FallbackLUTInterpolator(com.android.internal.view.animation.FallbackLUTInterpolator) NameValuesHolder(android.view.ViewPropertyAnimator.NameValuesHolder) TimeInterpolator(android.animation.TimeInterpolator)

Example 9 with TimeInterpolator

use of android.animation.TimeInterpolator in project android_frameworks_base by ResurrectionRemix.

the class ViewPropertyAnimatorRT method doStartAnimation.

private void doStartAnimation(ViewPropertyAnimator parent) {
    int size = parent.mPendingAnimations.size();
    long startDelay = parent.getStartDelay();
    long duration = parent.getDuration();
    TimeInterpolator interpolator = parent.getInterpolator();
    if (interpolator == null) {
        // Documented to be LinearInterpolator in ValueAnimator.setInterpolator
        interpolator = sLinearInterpolator;
    }
    if (!RenderNodeAnimator.isNativeInterpolator(interpolator)) {
        interpolator = new FallbackLUTInterpolator(interpolator, duration);
    }
    for (int i = 0; i < size; i++) {
        NameValuesHolder holder = parent.mPendingAnimations.get(i);
        int property = RenderNodeAnimator.mapViewPropertyToRenderProperty(holder.mNameConstant);
        final float finalValue = holder.mFromValue + holder.mDeltaValue;
        RenderNodeAnimator animator = new RenderNodeAnimator(property, finalValue);
        animator.setStartDelay(startDelay);
        animator.setDuration(duration);
        animator.setInterpolator(interpolator);
        animator.setTarget(mView);
        animator.start();
        mAnimators[property] = animator;
    }
    parent.mPendingAnimations.clear();
}
Also used : FallbackLUTInterpolator(com.android.internal.view.animation.FallbackLUTInterpolator) NameValuesHolder(android.view.ViewPropertyAnimator.NameValuesHolder) TimeInterpolator(android.animation.TimeInterpolator)

Example 10 with TimeInterpolator

use of android.animation.TimeInterpolator in project android_packages_apps_Launcher2 by CyanogenMod.

the class DeleteDropTarget method onFlingToDelete.

public void onFlingToDelete(final DragObject d, int x, int y, PointF vel) {
    final boolean isAllApps = d.dragSource instanceof AppsCustomizePagedView;
    // Don't highlight the icon as it's animating
    d.dragView.setColor(0);
    d.dragView.updateInitialScaleToCurrentScale();
    // Don't highlight the target if we are flinging from AllApps
    if (isAllApps) {
        resetHoverColor();
    }
    if (mFlingDeleteMode == MODE_FLING_DELETE_TO_TRASH) {
        // Defer animating out the drop target if we are animating to it
        mSearchDropTargetBar.deferOnDragEnd();
        mSearchDropTargetBar.finishAnimations();
    }
    final ViewConfiguration config = ViewConfiguration.get(mLauncher);
    final DragLayer dragLayer = mLauncher.getDragLayer();
    final int duration = FLING_DELETE_ANIMATION_DURATION;
    final long startTime = AnimationUtils.currentAnimationTimeMillis();
    // NOTE: Because it takes time for the first frame of animation to actually be
    // called and we expect the animation to be a continuation of the fling, we have
    // to account for the time that has elapsed since the fling finished.  And since
    // we don't have a startDelay, we will always get call to update when we call
    // start() (which we want to ignore).
    final TimeInterpolator tInterpolator = new TimeInterpolator() {

        private int mCount = -1;

        private float mOffset = 0f;

        @Override
        public float getInterpolation(float t) {
            if (mCount < 0) {
                mCount++;
            } else if (mCount == 0) {
                mOffset = Math.min(0.5f, (float) (AnimationUtils.currentAnimationTimeMillis() - startTime) / duration);
                mCount++;
            }
            return Math.min(1f, mOffset + t);
        }
    };
    AnimatorUpdateListener updateCb = null;
    if (mFlingDeleteMode == MODE_FLING_DELETE_TO_TRASH) {
        updateCb = createFlingToTrashAnimatorListener(dragLayer, d, vel, config);
    } else if (mFlingDeleteMode == MODE_FLING_DELETE_ALONG_VECTOR) {
        updateCb = createFlingAlongVectorAnimatorListener(dragLayer, d, vel, startTime, duration, config);
    }
    Runnable onAnimationEndRunnable = new Runnable() {

        @Override
        public void run() {
            mSearchDropTargetBar.onDragEnd();
            // itself, otherwise, complete the drop to initiate the deletion process
            if (!isAllApps) {
                mLauncher.exitSpringLoadedDragMode();
                completeDrop(d);
            }
            mLauncher.getDragController().onDeferredEndFling(d);
        }
    };
    dragLayer.animateView(d.dragView, updateCb, duration, tInterpolator, onAnimationEndRunnable, DragLayer.ANIMATION_END_DISAPPEAR, null);
}
Also used : ViewConfiguration(android.view.ViewConfiguration) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) TimeInterpolator(android.animation.TimeInterpolator)

Aggregations

TimeInterpolator (android.animation.TimeInterpolator)29 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)14 ValueAnimator (android.animation.ValueAnimator)10 ObjectAnimator (android.animation.ObjectAnimator)8 Animator (android.animation.Animator)5 Rect (android.graphics.Rect)5 View (android.view.View)5 NameValuesHolder (android.view.ViewPropertyAnimator.NameValuesHolder)5 FallbackLUTInterpolator (com.android.internal.view.animation.FallbackLUTInterpolator)5 ArrayList (java.util.ArrayList)4 AnimatorListener (android.animation.Animator.AnimatorListener)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 AnimatorSet (android.animation.AnimatorSet)3 PropertyValuesHolder (android.animation.PropertyValuesHolder)3 Resources (android.content.res.Resources)3 ViewConfiguration (android.view.ViewConfiguration)3 ViewGroup (android.view.ViewGroup)3 TargetApi (android.annotation.TargetApi)2 Transition (android.transitions.everywhere.Transition)2 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)2