Example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator

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

Introduction

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

Prototype

public DecelerateInterpolator() 

Source Link

Usage

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

private void hideActionBar() {
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(backButton, "alpha", 0.0f),
            ObjectAnimator.ofFloat(shareContainer, "alpha", 0.0f));
    animatorSet.setDuration(250);//from   w  w  w.  j ava2 s .co  m
    animatorSet.setInterpolator(new DecelerateInterpolator());
    animatorSet.start();
}

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

public void collapse() {
    if (parentActivity == null || !isVisible || checkAnimation()) {
        return;//from  w  w  w  . j  a v a  2  s.  co  m
    }
    if (fullscreenVideoContainer.getVisibility() == View.VISIBLE) {
        if (customView != null) {
            fullscreenVideoContainer.setVisibility(View.INVISIBLE);
            customViewCallback.onCustomViewHidden();
            fullscreenVideoContainer.removeView(customView);
            customView = null;
        } else if (fullscreenedVideo != null) {
            fullscreenedVideo.exitFullscreen();
        }
    }
    if (isPhotoVisible) {
        closePhoto(false);
    }
    try {
        if (visibleDialog != null) {
            visibleDialog.dismiss();
            visibleDialog = null;
        }
    } catch (Exception e) {
        FileLog.e(e);
    }

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(containerView, "translationX",
                    containerView.getMeasuredWidth() - AndroidUtilities.dp(56)),
            ObjectAnimator.ofFloat(containerView, "translationY",
                    ActionBar.getCurrentActionBarHeight()
                            + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)),
            ObjectAnimator.ofFloat(windowView, "alpha", 0.0f), ObjectAnimator.ofFloat(listView, "alpha", 0.0f),
            ObjectAnimator.ofFloat(listView, "translationY", -AndroidUtilities.dp(56)),
            ObjectAnimator.ofFloat(headerView, "translationY", 0),

            ObjectAnimator.ofFloat(backButton, "scaleX", 1.0f),
            ObjectAnimator.ofFloat(backButton, "scaleY", 1.0f),
            ObjectAnimator.ofFloat(backButton, "translationY", 0),
            ObjectAnimator.ofFloat(shareContainer, "scaleX", 1.0f),
            ObjectAnimator.ofFloat(shareContainer, "translationY", 0),
            ObjectAnimator.ofFloat(shareContainer, "scaleY", 1.0f));
    collapsed = true;
    animationInProgress = 2;
    animationEndRunnable = new Runnable() {
        @Override
        public void run() {
            if (containerView == null) {
                return;
            }
            if (Build.VERSION.SDK_INT >= 18) {
                containerView.setLayerType(View.LAYER_TYPE_NONE, null);
            }
            animationInProgress = 0;

            //windowLayoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
            WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
            wm.updateViewLayout(windowView, windowLayoutParams);

            //onClosed();
            //containerView.setScaleX(1.0f);
            //containerView.setScaleY(1.0f);
        }
    };
    animatorSet.setInterpolator(new DecelerateInterpolator());
    animatorSet.setDuration(250);
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (animationEndRunnable != null) {
                animationEndRunnable.run();
                animationEndRunnable = null;
            }
        }
    });
    transitionAnimationStartTime = System.currentTimeMillis();
    if (Build.VERSION.SDK_INT >= 18) {
        containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }
    backDrawable.setRotation(1, true);
    animatorSet.start();
}

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

public void fillFlashcard(boolean flip) {
    if (!flip) {/*from ww  w. j  ava  2s.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:org.telegram.ui.ArticleViewer.java

public void uncollapse() {
    if (parentActivity == null || !isVisible || checkAnimation()) {
        return;//from  www  .  ja  v  a2 s.c  o m
    }

    /*windowLayoutParams.flags &= ~WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
    WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
    wm.updateViewLayout(windowView, windowLayoutParams);*/

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, "translationX", 0),
            ObjectAnimator.ofFloat(containerView, "translationY", 0),
            ObjectAnimator.ofFloat(windowView, "alpha", 1.0f), ObjectAnimator.ofFloat(listView, "alpha", 1.0f),
            ObjectAnimator.ofFloat(listView, "translationY", 0),
            ObjectAnimator.ofFloat(headerView, "translationY", 0),

            ObjectAnimator.ofFloat(backButton, "scaleX", 1.0f),
            ObjectAnimator.ofFloat(backButton, "scaleY", 1.0f),
            ObjectAnimator.ofFloat(backButton, "translationY", 0),
            ObjectAnimator.ofFloat(shareContainer, "scaleX", 1.0f),
            ObjectAnimator.ofFloat(shareContainer, "translationY", 0),
            ObjectAnimator.ofFloat(shareContainer, "scaleY", 1.0f));
    collapsed = false;
    animationInProgress = 2;
    animationEndRunnable = new Runnable() {
        @Override
        public void run() {
            if (containerView == null) {
                return;
            }
            if (Build.VERSION.SDK_INT >= 18) {
                containerView.setLayerType(View.LAYER_TYPE_NONE, null);
            }
            animationInProgress = 0;
            //onClosed();
        }
    };
    animatorSet.setDuration(250);
    animatorSet.setInterpolator(new DecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (animationEndRunnable != null) {
                animationEndRunnable.run();
                animationEndRunnable = null;
            }
        }
    });
    transitionAnimationStartTime = System.currentTimeMillis();
    if (Build.VERSION.SDK_INT >= 18) {
        containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }
    backDrawable.setRotation(0, true);
    animatorSet.start();
}

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

public void fillFlashcard(boolean flip) {
    if (!flip) {/*  w ww  . 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);
    }
}