Example usage for android.view.animation AccelerateDecelerateInterpolator AccelerateDecelerateInterpolator

List of usage examples for android.view.animation AccelerateDecelerateInterpolator AccelerateDecelerateInterpolator

Introduction

In this page you can find the example usage for android.view.animation AccelerateDecelerateInterpolator AccelerateDecelerateInterpolator.

Prototype

public AccelerateDecelerateInterpolator() 

Source Link

Usage

From source file:com.android.soma.Launcher.java

/**
 * Zoom the camera back into the workspace, hiding 'fromView'.
 * This is the opposite of showAppsCustomizeHelper.
 * @param animated If true, the transition will be animated.
 *//*from   w ww  . j  a v  a 2 s .com*/
private void hideAppsCustomizeHelper(Workspace.State toState, final boolean animated,
        final boolean springLoaded, final Runnable onCompleteRunnable) {

    if (mStateAnimation != null) {
        mStateAnimation.setDuration(0);
        mStateAnimation.cancel();
        mStateAnimation = null;
    }
    Resources res = getResources();

    final int duration = res.getInteger(R.integer.config_appsCustomizeZoomOutTime);
    final int fadeOutDuration = res.getInteger(R.integer.config_appsCustomizeFadeOutTime);
    final float scaleFactor = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor);
    final View fromView = mAppsCustomizeTabHost;
    final View toView = mWorkspace;
    Animator workspaceAnim = null;
    if (toState == Workspace.State.NORMAL) {
        int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger);
        workspaceAnim = mWorkspace.getChangeStateAnimation(toState, animated, stagger, -1);
    } else if (toState == Workspace.State.SPRING_LOADED || toState == Workspace.State.OVERVIEW) {
        workspaceAnim = mWorkspace.getChangeStateAnimation(toState, animated);
    }

    setPivotsForZoom(fromView, scaleFactor);
    showHotseat(animated);
    if (animated) {
        final LauncherViewPropertyAnimator scaleAnim = new LauncherViewPropertyAnimator(fromView);
        scaleAnim.scaleX(scaleFactor).scaleY(scaleFactor).setDuration(duration)
                .setInterpolator(new Workspace.ZoomInInterpolator());

        final ObjectAnimator alphaAnim = LauncherAnimUtils.ofFloat(fromView, "alpha", 1f, 0f)
                .setDuration(fadeOutDuration);
        alphaAnim.setInterpolator(new AccelerateDecelerateInterpolator());
        alphaAnim.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float t = 1f - (Float) animation.getAnimatedValue();
                dispatchOnLauncherTransitionStep(fromView, t);
                dispatchOnLauncherTransitionStep(toView, t);
            }
        });

        mStateAnimation = LauncherAnimUtils.createAnimatorSet();

        dispatchOnLauncherTransitionPrepare(fromView, animated, true);
        dispatchOnLauncherTransitionPrepare(toView, animated, true);
        mAppsCustomizeContent.pauseScrolling();

        mStateAnimation.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                fromView.setVisibility(View.GONE);
                dispatchOnLauncherTransitionEnd(fromView, animated, true);
                dispatchOnLauncherTransitionEnd(toView, animated, true);
                if (onCompleteRunnable != null) {
                    onCompleteRunnable.run();
                }
                mAppsCustomizeContent.updateCurrentPageScroll();
                mAppsCustomizeContent.resumeScrolling();
            }
        });

        mStateAnimation.playTogether(scaleAnim, alphaAnim);
        if (workspaceAnim != null) {
            mStateAnimation.play(workspaceAnim);
        }
        dispatchOnLauncherTransitionStart(fromView, animated, true);
        dispatchOnLauncherTransitionStart(toView, animated, true);
        LauncherAnimUtils.startAnimationAfterNextDraw(mStateAnimation, toView);
    } else {
        fromView.setVisibility(View.GONE);
        dispatchOnLauncherTransitionPrepare(fromView, animated, true);
        dispatchOnLauncherTransitionStart(fromView, animated, true);
        dispatchOnLauncherTransitionEnd(fromView, animated, true);
        dispatchOnLauncherTransitionPrepare(toView, animated, true);
        dispatchOnLauncherTransitionStart(toView, animated, true);
        dispatchOnLauncherTransitionEnd(toView, animated, true);
    }
}

From source file:org.telegram.ui.PassportActivity.java

public void setPage(int page, boolean animated, Bundle params) {
    if (page == 3) {
        doneItem.setVisibility(View.GONE);
    }//from   ww  w . ja v a2  s .co m
    final SlideView outView = views[currentViewNum];
    final SlideView newView = views[page];
    currentViewNum = page;

    newView.setParams(params, false);
    newView.onShow();

    if (animated) {
        newView.setTranslationX(AndroidUtilities.displaySize.x);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
        animatorSet.setDuration(300);
        animatorSet.playTogether(
                ObjectAnimator.ofFloat(outView, "translationX", -AndroidUtilities.displaySize.x),
                ObjectAnimator.ofFloat(newView, "translationX", 0));
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
                newView.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                outView.setVisibility(View.GONE);
                outView.setX(0);
            }
        });
        animatorSet.start();
    } else {
        newView.setTranslationX(0);
        newView.setVisibility(View.VISIBLE);
        if (outView != newView) {
            outView.setVisibility(View.GONE);
        }
    }
}