Search in sources :

Example 81 with Interpolator

use of android.view.animation.Interpolator in project floatingsearchview by arimorty.

the class MenuView method showIfRoomItems.

/**
 * Shows all the menu items that were hidden by hideIfRoomItems(boolean withAnim)
 *
 * @param withAnim
 */
public void showIfRoomItems(boolean withAnim) {
    if (mMenu == -1) {
        return;
    }
    cancelChildAnimListAndClear();
    if (mMenuItems.isEmpty()) {
        return;
    }
    anims = new ArrayList<>();
    for (int i = 0; i < getChildCount(); i++) {
        final View currentView = getChildAt(i);
        // reset all the action item views
        if (i < mActionItems.size()) {
            ImageView action = (ImageView) currentView;
            final MenuItem actionItem = mActionItems.get(i);
            action.setImageDrawable(actionItem.getIcon());
            Util.setIconColor(action, mActionIconColor);
            action.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (mMenuCallback != null) {
                        mMenuCallback.onMenuItemSelected(mMenuBuilder, actionItem);
                    }
                }
            });
        }
        Interpolator interpolator = new DecelerateInterpolator();
        if (i > (mActionShowAlwaysItems.size() - 1)) {
            interpolator = new LinearInterpolator();
        }
        currentView.setClickable(true);
        // simply animate all properties of all action item views back to their default/visible state
        anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                currentView.setTranslationX(0);
            }
        }).setInterpolator(interpolator).translationX(0).get());
        anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                currentView.setScaleX(1.0f);
            }
        }).setInterpolator(interpolator).scaleX(1.0f).get());
        anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                currentView.setScaleY(1.0f);
            }
        }).setInterpolator(interpolator).scaleY(1.0f).get());
        anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                currentView.setAlpha(1.0f);
            }
        }).setInterpolator(interpolator).alpha(1.0f).get());
    }
    if (anims.isEmpty()) {
        return;
    }
    AnimatorSet animSet = new AnimatorSet();
    if (!withAnim) {
        // temporary, from laziness
        animSet.setDuration(0);
    }
    animSet.playTogether(anims.toArray(new ObjectAnimator[anims.size()]));
    animSet.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mOnVisibleWidthChangedListener != null) {
                mVisibleWidth = (getChildCount() * (int) ACTION_DIMENSION_PX) - (mHasOverflow ? Util.dpToPx(8) : 0);
                mOnVisibleWidthChangedListener.onItemsMenuVisibleWidthChanged(mVisibleWidth);
            }
        }
    });
    animSet.start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) ViewPropertyObjectAnimator(com.bartoszlipinski.viewpropertyobjectanimator.ViewPropertyObjectAnimator) MenuItem(android.view.MenuItem) AnimatorSet(android.animation.AnimatorSet) ImageView(android.widget.ImageView) View(android.view.View) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ViewPropertyObjectAnimator(com.bartoszlipinski.viewpropertyobjectanimator.ViewPropertyObjectAnimator) LinearInterpolator(android.view.animation.LinearInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) Interpolator(android.view.animation.Interpolator) LinearInterpolator(android.view.animation.LinearInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ImageView(android.widget.ImageView)

Example 82 with Interpolator

use of android.view.animation.Interpolator in project httpclient by pixmob.

the class KeyframeSet method getValue.

/**
 * Gets the animated value, given the elapsed fraction of the animation (interpolated by the
 * animation's interpolator) and the evaluator used to calculate in-between values. This
 * function maps the input fraction to the appropriate keyframe interval and a fraction
 * between them and returns the interpolated value. Note that the input fraction may fall
 * outside the [0-1] bounds, if the animation's interpolator made that happen (e.g., a
 * spring interpolation that might send the fraction past 1.0). We handle this situation by
 * just using the two keyframes at the appropriate end when the value is outside those bounds.
 *
 * @param fraction The elapsed fraction of the animation
 * @return The animated value.
 */
public Object getValue(float fraction) {
    // Special-case optimization for the common case of only two keyframes
    if (mNumKeyframes == 2) {
        if (mInterpolator != null) {
            fraction = mInterpolator.getInterpolation(fraction);
        }
        return mEvaluator.evaluate(fraction, mFirstKeyframe.getValue(), mLastKeyframe.getValue());
    }
    if (fraction <= 0f) {
        final Keyframe nextKeyframe = mKeyframes.get(1);
        final Interpolator /*Time*/
        interpolator = nextKeyframe.getInterpolator();
        if (interpolator != null) {
            fraction = interpolator.getInterpolation(fraction);
        }
        final float prevFraction = mFirstKeyframe.getFraction();
        float intervalFraction = (fraction - prevFraction) / (nextKeyframe.getFraction() - prevFraction);
        return mEvaluator.evaluate(intervalFraction, mFirstKeyframe.getValue(), nextKeyframe.getValue());
    } else if (fraction >= 1f) {
        final Keyframe prevKeyframe = mKeyframes.get(mNumKeyframes - 2);
        final Interpolator /*Time*/
        interpolator = mLastKeyframe.getInterpolator();
        if (interpolator != null) {
            fraction = interpolator.getInterpolation(fraction);
        }
        final float prevFraction = prevKeyframe.getFraction();
        float intervalFraction = (fraction - prevFraction) / (mLastKeyframe.getFraction() - prevFraction);
        return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), mLastKeyframe.getValue());
    }
    Keyframe prevKeyframe = mFirstKeyframe;
    for (int i = 1; i < mNumKeyframes; ++i) {
        Keyframe nextKeyframe = mKeyframes.get(i);
        if (fraction < nextKeyframe.getFraction()) {
            final Interpolator /*Time*/
            interpolator = nextKeyframe.getInterpolator();
            if (interpolator != null) {
                fraction = interpolator.getInterpolation(fraction);
            }
            final float prevFraction = prevKeyframe.getFraction();
            float intervalFraction = (fraction - prevFraction) / (nextKeyframe.getFraction() - prevFraction);
            return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), nextKeyframe.getValue());
        }
        prevKeyframe = nextKeyframe;
    }
    // shouldn't reach here
    return mLastKeyframe.getValue();
}
Also used : IntKeyframe(com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe) FloatKeyframe(com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe) ObjectKeyframe(com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.ObjectKeyframe) Interpolator(android.view.animation.Interpolator)

Example 83 with Interpolator

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

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 84 with Interpolator

use of android.view.animation.Interpolator in project weiui by kuaifan.

the class RxAnimationTool method cardFilpAnimation.

/**
 * 卡片翻转动画
 *
 * @param beforeView
 * @param AfterView
 */
public static void cardFilpAnimation(final View beforeView, final View AfterView) {
    Interpolator accelerator = new AccelerateInterpolator();
    Interpolator decelerator = new DecelerateInterpolator();
    if (beforeView.getVisibility() == View.GONE) {
        // 局部layout可达到字体翻转 背景不翻转
        invisToVis = ObjectAnimator.ofFloat(beforeView, "rotationY", -90f, 0f);
        visToInvis = ObjectAnimator.ofFloat(AfterView, "rotationY", 0f, 90f);
    } else if (AfterView.getVisibility() == View.GONE) {
        invisToVis = ObjectAnimator.ofFloat(AfterView, "rotationY", -90f, 0f);
        visToInvis = ObjectAnimator.ofFloat(beforeView, "rotationY", 0f, 90f);
    }
    // 翻转速度
    visToInvis.setDuration(250);
    // 在动画开始的地方速率改变比较慢,然后开始加速
    visToInvis.setInterpolator(accelerator);
    invisToVis.setDuration(250);
    invisToVis.setInterpolator(decelerator);
    visToInvis.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationEnd(Animator arg0) {
            if (beforeView.getVisibility() == View.GONE) {
                AfterView.setVisibility(View.GONE);
                invisToVis.start();
                beforeView.setVisibility(View.VISIBLE);
            } else {
                AfterView.setVisibility(View.GONE);
                visToInvis.start();
                beforeView.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onAnimationCancel(Animator arg0) {
        }

        @Override
        public void onAnimationRepeat(Animator arg0) {
        }

        @Override
        public void onAnimationStart(Animator arg0) {
        }
    });
    visToInvis.start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) Interpolator(android.view.animation.Interpolator) AnticipateOvershootInterpolator(android.view.animation.AnticipateOvershootInterpolator) LinearInterpolator(android.view.animation.LinearInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator)

Example 85 with Interpolator

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

the class VideoCallFragment method enterFullscreenMode.

private void enterFullscreenMode() {
    LogUtil.i("VideoCallFragment.enterFullscreenMode", null);
    hideSystemUI();
    Interpolator fastOutLinearInInterpolator = new FastOutLinearInInterpolator();
    // Animate controls to the hidden state.
    Point offset = getControlsOffsetEndHidden(controls);
    controls.animate().translationX(offset.x).translationY(offset.y).setInterpolator(fastOutLinearInInterpolator).alpha(0).start();
    // Animate onHold to the hidden state.
    offset = getSwitchOnHoldOffsetEndHidden(switchOnHoldButton);
    switchOnHoldButton.animate().translationX(offset.x).translationY(offset.y).setInterpolator(fastOutLinearInInterpolator).alpha(0);
    View contactGridView = contactGridManager.getContainerView();
    // Animate contact grid to the hidden state.
    offset = getContactGridOffsetEndHidden(contactGridView);
    contactGridView.animate().translationX(offset.x).translationY(offset.y).setInterpolator(fastOutLinearInInterpolator).alpha(0);
    offset = getEndCallOffsetEndHidden(endCallButton);
    // Use a fast out interpolator to quickly fade out the button. This is important because the
    // button can't draw under the navigation bar which means that it'll look weird if it just
    // abruptly disappears when it reaches the edge of the naivgation bar.
    endCallButton.animate().translationX(offset.x).translationY(offset.y).setInterpolator(fastOutLinearInInterpolator).alpha(0).withEndAction(new Runnable() {

        @Override
        public void run() {
            endCallButton.setVisibility(View.INVISIBLE);
        }
    }).setInterpolator(new FastOutLinearInInterpolator()).start();
    // a fixed position.
    if (!isInGreenScreenMode) {
        for (View view : getAllPreviewRelatedViews()) {
            // Animate down with the navigation bar hidden.
            view.animate().translationX(0).translationY(0).setInterpolator(new AccelerateDecelerateInterpolator()).start();
        }
    }
    updateOverlayBackground();
}
Also used : FastOutLinearInInterpolator(android.support.v4.view.animation.FastOutLinearInInterpolator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) LinearOutSlowInInterpolator(android.support.v4.view.animation.LinearOutSlowInInterpolator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) Interpolator(android.view.animation.Interpolator) FastOutLinearInInterpolator(android.support.v4.view.animation.FastOutLinearInInterpolator) Point(android.graphics.Point) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) TextureView(android.view.TextureView)

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