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.stanleyidesis.quotograph.ui.activity.LWQSettingsActivity.java

ViewPropertyAnimator animateFABRotation(final boolean rotate) {
    final ViewPropertyAnimator animate = fabAdd.animate();
    animate.rotation(rotate ? 45f : 0f).setInterpolator(new AccelerateDecelerateInterpolator())
            .setDuration(150);//from  w w  w  .  j av  a  2  s.c o  m
    return animate;
}

From source file:com.zertinteractive.wallpaper.MainActivity.java

@SuppressWarnings("NewApi")
private android.animation.Animator animateRevealColorFromCoordinates(ViewGroup viewRoot, @ColorRes int color,
        int x, int y) {
    float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());

    android.animation.Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, x, y, 0, finalRadius);
    viewRoot.setBackgroundColor(ContextCompat.getColor(this, color));
    anim.setDuration(getResources().getInteger(R.integer.anim_duration_long));
    anim.setInterpolator(new AccelerateDecelerateInterpolator());
    anim.start();//from   w w  w  .j  ava 2  s  .  co m
    return anim;
}

From source file:com.stanleyidesis.quotograph.ui.activity.LWQSettingsActivity.java

Animator animateFAB(final View fabToAnimate, final boolean dismiss) {
    fabToAnimate.setVisibility(View.VISIBLE);
    float[] toFrom = dismiss ? new float[] { 1f, .2f } : new float[] { .2f, 1f };
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override//from w  w  w  .  j a  v a2 s.c  o  m
        public void onAnimationEnd(Animator animation) {
            fabToAnimate.setVisibility(dismiss ? View.GONE : View.VISIBLE);
        }
    });
    ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(fabToAnimate, "alpha", toFrom);
    alphaAnimator.setDuration(200);
    alphaAnimator.setInterpolator(new AccelerateDecelerateInterpolator());

    // Create a scale + fade animation
    ObjectAnimator scaleDown = ObjectAnimator.ofPropertyValuesHolder(fabToAnimate,
            PropertyValuesHolder.ofFloat("scaleX", toFrom), PropertyValuesHolder.ofFloat("scaleY", toFrom));
    scaleDown.setDuration(200);
    scaleDown.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.playTogether(scaleDown, alphaAnimator);
    return animatorSet;
}

From source file:com.stanleyidesis.quotograph.ui.activity.LWQSettingsActivity.java

Animator animateFABActions(final boolean dismiss) {
    fabBackground.setVisibility(View.VISIBLE);
    Animator backgroundAnimator;// w  w  w.  j  a  v a 2  s  .c o  m

    if (Build.VERSION.SDK_INT >= 21) {
        Rect fabRect = new Rect();
        fabAdd.getGlobalVisibleRect(fabRect);
        final Point realScreenSize = UIUtils.getRealScreenSize();
        int radius = Math.max(realScreenSize.x, realScreenSize.y);
        backgroundAnimator = ViewAnimationUtils.createCircularReveal(fabBackground, fabRect.centerX(),
                fabRect.centerY(), dismiss ? radius : 0, dismiss ? 0 : radius);
    } else {
        backgroundAnimator = ObjectAnimator.ofFloat(fabBackground, "alpha", dismiss ? 1f : 0f,
                dismiss ? 0f : 1f);
    }
    backgroundAnimator.setDuration(300).setInterpolator(new AccelerateDecelerateInterpolator());
    backgroundAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (dismiss) {
                fabBackground.setVisibility(View.GONE);
                // Tell them to swipe again for settings!
                showTutorialTip(TutorialTooltips.SWIPE_AGAIN);
            } else {
                // Tell them about search!
                showTutorialTip(TutorialTooltips.SEARCH);
            }
        }
    });
    final long shortDelay = 50;
    final long longDelay = 100;
    final Animator createAnimator = animateFAB(fabCreate, dismiss);
    final Animator searchAnimator = animateFAB(fabSearch, dismiss);
    createAnimator.setStartDelay(dismiss ? longDelay : shortDelay);
    searchAnimator.setStartDelay(dismiss ? shortDelay : longDelay);
    AnimatorSet allAnimations = new AnimatorSet();
    allAnimations.playTogether(backgroundAnimator, createAnimator, searchAnimator);
    return allAnimations;
}

From source file:de.mrapp.android.sidebar.Sidebar.java

/**
 * Shows the sidebar, if it is currently hidden.
 *//*from  w  w w .  j  av  a 2  s .  c o m*/
public final void showSidebar() {
    if (contentView == null) {
        throw new IllegalStateException("The content view is not set");
    } else if (sidebarView == null) {
        throw new IllegalStateException("The sidebar view is not set");
    } else if (!isSidebarShown()) {
        animateShowSidebar(calculateAnimationDistance(true), new AccelerateDecelerateInterpolator());
    }
}

From source file:de.mrapp.android.sidebar.Sidebar.java

/**
 * Hides the sidebar, if it is currently shown.
 *///  ww  w.  ja v a 2  s.co  m
public final void hideSidebar() {
    if (contentView == null) {
        throw new IllegalStateException("The content view is not set");
    } else if (sidebarView == null) {
        throw new IllegalStateException("The sidebar view is not set");
    } else if (isSidebarShown()) {
        animateHideSidebar(calculateAnimationDistance(false), new AccelerateDecelerateInterpolator());
    }
}

From source file:de.mrapp.android.bottomsheet.BottomSheet.java

/**
 * Maximizes the bottom sheet./*from   w w  w  .jav a2 s  .  c  o m*/
 */
@TargetApi(Build.VERSION_CODES.FROYO)
public final void maximize() {
    if (!isMaximized()) {
        if (!isShowing()) {
            maximize = true;
            show();
        } else {
            rootView.maximize(new AccelerateDecelerateInterpolator());
        }
    }
}

From source file:com.ichi2.anki2.Reviewer.java

public void fillFlashcard(boolean flip) {
    if (!flip) {//from  w  w  w  .j a  v a  2  s  .c  o m
        Log.i(AnkiDroidApp.TAG, "base url = " + mBaseUrl);
        if (mCurrentSimpleInterface && mSimpleCard != null) {
            mSimpleCard.setText(mCardContent);
        } else if (mRefreshWebview && mCard != null && mNextCard != null) {
            mNextCard.setBackgroundColor(mCurrentBackgroundColor);
            mNextCard.loadDataWithBaseURL(mBaseUrl, mCardContent.toString(), "text/html", "utf-8", null);
            mNextCard.setVisibility(View.VISIBLE);
            mCardFrame.removeView(mCard);
            mCard.destroy();
            mCard = mNextCard;
            mNextCard = createWebView();
            mNextCard.setVisibility(View.GONE);
            mCardFrame.addView(mNextCard, 0);
            // hunt for input issue 720, like android issue 3341
            if (AnkiDroidApp.SDK_VERSION <= 7) {
                mCard.setFocusableInTouchMode(true);
            }
        } else if (mCard != null) {
            mCard.loadDataWithBaseURL(mBaseUrl, mCardContent.toString(), "text/html", "utf-8", null);
            mCard.setBackgroundColor(mCurrentBackgroundColor);
        }
        if (mChangeBorderStyle) {
            switch (mCurrentBackgroundColor) {
            case Color.WHITE:
                if (mInvertedColors) {
                    mInvertedColors = false;
                    invertColors(false);
                }
                break;
            case Color.BLACK:
                if (!mInvertedColors) {
                    mInvertedColors = true;
                    invertColors(true);
                }
                break;
            default:
                if (Themes.getTheme() != Themes.THEME_BLUE) {
                    mMainLayout.setBackgroundColor(mCurrentBackgroundColor);
                }
                if (mInvertedColors != mNightMode) {
                    mInvertedColors = mNightMode;
                    invertColors(mNightMode);
                }
            }
        }
        if (!mShowAnimations && mCardTimer.getVisibility() == View.INVISIBLE) {
            switchTopBarVisibility(View.VISIBLE);
        }
        if (!sDisplayAnswer) {
            updateForNewCard();
            if (mShowWhiteboard) {
                mWhiteboard.clear();
            }
            setNextCardAnimation(false);
        }
    } else {
        Animation3D rotation;
        boolean directionToLeft = true;
        switch (mNextAnimation) {
        case ANIMATION_TURN:
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 9,
                    Animation3D.ANIMATION_TURN, true, true, this);
            rotation.setDuration(mAnimationDurationTurn);
            rotation.setInterpolator(new AccelerateDecelerateInterpolator());
            break;
        case ANIMATION_NEXT_CARD_FROM_LEFT:
            directionToLeft = false;
        case ANIMATION_NEXT_CARD_FROM_RIGHT:
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0,
                    Animation3D.ANIMATION_EXCHANGE_CARD, directionToLeft, true, this);
            rotation.setDuration(mAnimationDurationMove);
            rotation.setInterpolator(new AccelerateDecelerateInterpolator());
            break;
        case ANIMATION_SLIDE_OUT_TO_RIGHT:
            directionToLeft = false;
        case ANIMATION_SLIDE_OUT_TO_LEFT:
            fillFlashcard(false);
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0,
                    Animation3D.ANIMATION_SLIDE_OUT_CARD, directionToLeft, true, this);
            rotation.setDuration(mAnimationDurationMove);
            rotation.setInterpolator(new AccelerateInterpolator());
            switchTopBarVisibility(View.INVISIBLE);
            break;
        case ANIMATION_SLIDE_IN_FROM_LEFT:
            directionToLeft = false;
        case ANIMATION_SLIDE_IN_FROM_RIGHT:
            fillFlashcard(false);
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0,
                    Animation3D.ANIMATION_SLIDE_IN_CARD, directionToLeft, true, this);
            rotation.setDuration(mAnimationDurationMove);
            rotation.setInterpolator(new DecelerateInterpolator());
            switchTopBarVisibility(View.VISIBLE);
            break;
        case ANIMATION_NO_ANIMATION:
        default:
            return;
        }

        rotation.reset();
        mCardContainer.setDrawingCacheEnabled(true);
        mCardContainer.setDrawingCacheBackgroundColor(Themes.getBackgroundColor());
        mCardContainer.clearAnimation();
        mCardContainer.startAnimation(rotation);
    }
}

From source file:com.hichinaschool.flashcards.anki.Reviewer.java

public void fillFlashcard(boolean flip) {
    if (!flip) {//from   ww w.  j a  va 2  s.com
        // Log.i(AnkiDroidApp.TAG, "base url = " + mBaseUrl);
        if (mCurrentSimpleInterface && mSimpleCard != null) {
            mSimpleCard.setText(mCardContent);
        } else if (!mUseQuickUpdate && mCard != null && mNextCard != null) {
            mNextCard.setBackgroundColor(mCurrentBackgroundColor);
            mNextCard.loadDataWithBaseURL(mBaseUrl, mCardContent.toString(), "text/html", "utf-8", null);
            mNextCard.setVisibility(View.VISIBLE);
            mCardFrame.removeView(mCard);
            mCard.destroy();
            mCard = mNextCard;
            mNextCard = createWebView();
            mNextCard.setVisibility(View.GONE);
            mCardFrame.addView(mNextCard, 0);
            // hunt for input issue 720, like android issue 3341
            if (AnkiDroidApp.SDK_VERSION <= 7) {
                mCard.setFocusableInTouchMode(true);
            }
        } else if (mCard != null) {
            mCard.loadDataWithBaseURL(mBaseUrl, mCardContent.toString(), "text/html", "utf-8", null);
            mCard.setBackgroundColor(mCurrentBackgroundColor);
        }
        if (mChangeBorderStyle) {
            switch (mCurrentBackgroundColor) {
            case Color.WHITE:
                if (mInvertedColors) {
                    mInvertedColors = false;
                    invertColors(false);
                }
                break;
            case Color.BLACK:
                if (!mInvertedColors) {
                    mInvertedColors = true;
                    invertColors(true);
                }
                break;
            default:
                if (Themes.getTheme() != Themes.THEME_BLUE) {
                    mMainLayout.setBackgroundColor(mCurrentBackgroundColor);
                }
                if (mInvertedColors != mNightMode) {
                    mInvertedColors = mNightMode;
                    invertColors(mNightMode);
                }
            }
        }
        if (!mShowAnimations && mShowTimer && mCardTimer.getVisibility() == View.INVISIBLE) {
            switchTopBarVisibility(View.VISIBLE);
        }
        if (!sDisplayAnswer) {
            updateForNewCard();
            if (mShowWhiteboard) {
                mWhiteboard.clear();
            }
            setNextCardAnimation(false);
        }
    } else {
        Animation3D rotation;
        boolean directionToLeft = true;
        switch (mNextAnimation) {
        case ANIMATION_TURN:
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 9,
                    Animation3D.ANIMATION_TURN, true, true, this);
            rotation.setDuration(mAnimationDurationTurn);
            rotation.setInterpolator(new AccelerateDecelerateInterpolator());
            break;
        case ANIMATION_NEXT_CARD_FROM_LEFT:
            directionToLeft = false;
        case ANIMATION_NEXT_CARD_FROM_RIGHT:
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0,
                    Animation3D.ANIMATION_EXCHANGE_CARD, directionToLeft, true, this);
            rotation.setDuration(mAnimationDurationMove);
            rotation.setInterpolator(new AccelerateDecelerateInterpolator());
            break;
        case ANIMATION_SLIDE_OUT_TO_RIGHT:
            directionToLeft = false;
        case ANIMATION_SLIDE_OUT_TO_LEFT:
            fillFlashcard(false);
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0,
                    Animation3D.ANIMATION_SLIDE_OUT_CARD, directionToLeft, true, this);
            rotation.setDuration(mAnimationDurationMove);
            rotation.setInterpolator(new AccelerateInterpolator());
            switchTopBarVisibility(View.INVISIBLE);
            break;
        case ANIMATION_SLIDE_IN_FROM_LEFT:
            directionToLeft = false;
        case ANIMATION_SLIDE_IN_FROM_RIGHT:
            fillFlashcard(false);
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0,
                    Animation3D.ANIMATION_SLIDE_IN_CARD, directionToLeft, true, this);
            rotation.setDuration(mAnimationDurationMove);
            rotation.setInterpolator(new DecelerateInterpolator());
            switchTopBarVisibility(View.VISIBLE);
            break;
        case ANIMATION_NO_ANIMATION:
        default:
            return;
        }

        rotation.reset();
        mCardContainer.setDrawingCacheEnabled(true);
        mCardContainer.setDrawingCacheBackgroundColor(Themes.getBackgroundColor());
        mCardContainer.clearAnimation();
        mCardContainer.startAnimation(rotation);
    }
}

From source file:com.android.launcher2.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.
 */// w w w. ja  v a2 s . co  m
private void hideAppsCustomizeHelper(State toState, final boolean animated, final boolean springLoaded,
        final Runnable onCompleteRunnable) {

    if (mStateAnimation != null) {
        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 == State.WORKSPACE) {
        int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger);
        workspaceAnim = mWorkspace.getChangeStateAnimation(Workspace.State.NORMAL, animated, stagger);
    } else if (toState == State.APPS_CUSTOMIZE_SPRING_LOADED) {
        workspaceAnim = mWorkspace.getChangeStateAnimation(Workspace.State.SPRING_LOADED, animated);
    }

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

        final ObjectAnimator alphaAnim = ObjectAnimator.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) {
                updateWallpaperVisibility(true);
                fromView.setVisibility(View.GONE);
                dispatchOnLauncherTransitionEnd(fromView, animated, true);
                dispatchOnLauncherTransitionEnd(toView, animated, true);
                if (mWorkspace != null) {
                    mWorkspace.hideScrollingIndicator(false);
                }
                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);
        final Animator stateAnimation = mStateAnimation;
        mWorkspace.post(new Runnable() {
            public void run() {
                if (stateAnimation != mStateAnimation)
                    return;
                mStateAnimation.start();
            }
        });
    } 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);
        mWorkspace.hideScrollingIndicator(false);
    }
}