Search in sources :

Example 86 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project Carbon by ZieIony.

the class Snackbar method dismiss.

public void dismiss() {
    synchronized (Snackbar.class) {
        handler.removeCallbacks(hideRunnable);
        if (onDismissListener != null)
            onDismissListener.onDismiss();
        AnimUtils.flyOut(content, new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animator) {
                hideInternal();
            }
        });
        for (final View pushedView : pushedViews) {
            ValueAnimator animator = ValueAnimator.ofFloat(-1, 0);
            animator.setDuration(200);
            animator.setInterpolator(new DecelerateInterpolator());
            animator.addUpdateListener(valueAnimator -> {
                MarginLayoutParams lp = (MarginLayoutParams) content.getLayoutParams();
                ViewHelper.setTranslationY(pushedView, (content.getHeight() + lp.bottomMargin) * (Float) valueAnimator.getAnimatedValue());
                if (pushedView.getParent() != null)
                    ((View) pushedView.getParent()).postInvalidate();
            });
            animator.start();
        }
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) View(android.view.View)

Example 87 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project ElasticDownload by Tibolte.

the class ProgressDownloadView method setPercentage.

public void setPercentage(float newProgress) {
    if (newProgress < 0 || newProgress > 100) {
        throw new IllegalArgumentException("setPercentage not between 0 and 100");
    }
    mState = State.STATE_WORKING;
    mTarget = newProgress;
    ObjectAnimator anim = ObjectAnimator.ofFloat(this, "progress", getProgress(), mTarget);
    anim.setInterpolator(new DecelerateInterpolator());
    anim.setDuration((long) (ANIMATION_DURATION_BASE + Math.abs(mTarget * 10 - getProgress() * 10) / 2));
    anim.start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator)

Example 88 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project android_frameworks_base by ParanoidAndroid.

the class HaloProperties method setHaloOverlay.

public void setHaloOverlay(Overlay overlay, float overlayAlpha) {
    Drawable d = null;
    switch(overlay) {
        case BLACK_X:
            d = mHaloBlackX;
            break;
        case BACK_LEFT:
            d = mHaloBackL;
            break;
        case BACK_RIGHT:
            d = mHaloBackR;
            break;
        case DISMISS:
            d = mHaloDismiss;
            break;
        case SILENCE_LEFT:
            d = mHaloSilenceL;
            break;
        case SILENCE_RIGHT:
            d = mHaloSilenceR;
            break;
        case CLEAR_ALL:
            d = mHaloClearAll;
            break;
        case MESSAGE:
            d = mHaloMessage;
            break;
    }
    if (d != mHaloCurrentOverlay) {
        mHaloOverlay.setImageDrawable(d);
        mHaloCurrentOverlay = d;
        // Fade out number batch
        if (overlay != Overlay.NONE) {
            msgNumberAlphaAnimator.animate(ObjectAnimator.ofFloat(mHaloNumberContainer, "alpha", 0f).setDuration(100), new DecelerateInterpolator(), null);
        }
    }
    mHaloOverlay.setAlpha(overlayAlpha);
    updateResources(mLastContentStateLeft);
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Drawable(android.graphics.drawable.Drawable)

Example 89 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project Anki-Android by Ramblurr.

the class Reviewer method fillFlashcard.

public void fillFlashcard(boolean flip) {
    if (!flip) {
        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);
    }
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) Animation3D(com.ichi2.anim.Animation3D)

Example 90 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project folding-cell-android by Ramotion.

the class FoldingCell method startFoldAnimation.

/**
     * Start fold animation
     *
     * @param foldingCellElements           ordered list with animation parts from top to bottom
     * @param foldingLayout                 prepared layout for animation parts
     * @param part90degreeAnimationDuration animation duration for 90 degree rotation
     * @param animationEndListener          animation end callback
     */
protected void startFoldAnimation(ArrayList<FoldingCellView> foldingCellElements, ViewGroup foldingLayout, int part90degreeAnimationDuration, AnimationEndListener animationEndListener) {
    for (FoldingCellView foldingCellElement : foldingCellElements) foldingLayout.addView(foldingCellElement);
    Collections.reverse(foldingCellElements);
    int nextDelay = 0;
    for (int i = 0; i < foldingCellElements.size(); i++) {
        FoldingCellView cell = foldingCellElements.get(i);
        cell.setVisibility(VISIBLE);
        // not FIRST(BOTTOM) element - animate front view
        if (i != 0) {
            FoldAnimation foldAnimation = new FoldAnimation(FoldAnimation.FoldAnimationMode.UNFOLD_UP, mCameraHeight, part90degreeAnimationDuration).withStartOffset(nextDelay).withInterpolator(new DecelerateInterpolator());
            // if last(top) element - add end listener
            if (i == foldingCellElements.size() - 1) {
                foldAnimation.setAnimationListener(animationEndListener);
            }
            cell.animateFrontView(foldAnimation);
            nextDelay = nextDelay + part90degreeAnimationDuration;
        }
        // if not last(top) element - animate whole view
        if (i != foldingCellElements.size() - 1) {
            cell.startAnimation(new FoldAnimation(FoldAnimation.FoldAnimationMode.FOLD_UP, mCameraHeight, part90degreeAnimationDuration).withStartOffset(nextDelay).withInterpolator(new DecelerateInterpolator()));
            nextDelay = nextDelay + part90degreeAnimationDuration;
        }
    }
}
Also used : FoldAnimation(com.ramotion.foldingcell.animations.FoldAnimation) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) FoldingCellView(com.ramotion.foldingcell.views.FoldingCellView)

Aggregations

DecelerateInterpolator (android.view.animation.DecelerateInterpolator)312 ObjectAnimator (android.animation.ObjectAnimator)80 Animator (android.animation.Animator)66 ValueAnimator (android.animation.ValueAnimator)59 View (android.view.View)58 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)55 AnimatorSet (android.animation.AnimatorSet)52 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)36 ImageView (android.widget.ImageView)32 AlphaAnimation (android.view.animation.AlphaAnimation)30 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)29 Animation (android.view.animation.Animation)21 TextView (android.widget.TextView)20 Point (android.graphics.Point)18 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)18 Paint (android.graphics.Paint)14 LinearInterpolator (android.view.animation.LinearInterpolator)14 ScaleAnimation (android.view.animation.ScaleAnimation)14 AnimatorSet (com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet)14 ObjectAnimator (com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator)14