Search in sources :

Example 11 with AccelerateDecelerateInterpolator

use of android.view.animation.AccelerateDecelerateInterpolator 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 12 with AccelerateDecelerateInterpolator

use of android.view.animation.AccelerateDecelerateInterpolator in project Fairphone by Kwamecorp.

the class LauncherTransitionable method hideAppsCustomizeHelper.

/**
	 * Zoom the camera back into the workspace, hiding 'fromView'. This is the
	 * opposite of showAppsCustomizeHelper.
	 * 
	 * @param animated
	 *            If true, the transition will be animated.
	 */
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);
    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);
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) ImageView(android.widget.ImageView) AppWidgetHostView(android.appwidget.AppWidgetHostView) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) Resources(android.content.res.Resources)

Example 13 with AccelerateDecelerateInterpolator

use of android.view.animation.AccelerateDecelerateInterpolator in project CoCoin by Nightonke.

the class SplashActivity method startCircularReveal.

private void startCircularReveal() {
    // get the center for the clipping circle
    int[] location = new int[2];
    image.getLocationOnScreen(location);
    int cx = location[0] + CoCoinUtil.dpToPx(24);
    int cy = location[1] + CoCoinUtil.dpToPx(24);
    // get the final radius for the clipping circle
    int dx = Math.max(cx, ly.getWidth() - cx);
    int dy = Math.max(cy, ly.getHeight() - cy);
    float finalRadius = (float) Math.hypot(dx, dy);
    SupportAnimator animator = ViewAnimationUtils.createCircularReveal(ly, cx, cy, 0, finalRadius);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(3000);
    animator.start();
    animator.addListener(new SupportAnimator.AnimatorListener() {

        @Override
        public void onAnimationStart() {
        }

        @Override
        public void onAnimationEnd() {
            Log.d("CoCoin", "Showing animation completed");
            showAnimationCompleted = true;
            if (loadDataCompleted && showAnimationCompleted && !activityStarted) {
                activityStarted = true;
                startActivity(new Intent(mContext, MainActivity.class));
                finish();
            }
        }

        @Override
        public void onAnimationCancel() {
        }

        @Override
        public void onAnimationRepeat() {
        }
    });
    hasAnimationStarted = true;
}
Also used : SupportAnimator(io.codetail.animation.SupportAnimator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) Intent(android.content.Intent)

Example 14 with AccelerateDecelerateInterpolator

use of android.view.animation.AccelerateDecelerateInterpolator in project CoCoin by Nightonke.

the class RippleView method onTouchEvent.

@Override
public boolean onTouchEvent(final MotionEvent event) {
    Log.d("TouchEvent", String.valueOf(event.getActionMasked()));
    Log.d("mIsAnimating", String.valueOf(mIsAnimating));
    Log.d("mAnimationIsCancel", String.valueOf(mAnimationIsCancel));
    boolean superResult = super.onTouchEvent(event);
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN && this.isEnabled() && mHover) {
        mRect = new Rect(getLeft(), getTop(), getRight(), getBottom());
        mAnimationIsCancel = false;
        mDownX = event.getX();
        mDownY = event.getY();
        mRadiusAnimator = ObjectAnimator.ofFloat(this, "radius", 0, dp(50)).setDuration(400);
        mRadiusAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
        mRadiusAnimator.addListener(new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animator) {
                mIsAnimating = true;
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                setRadius(0);
                ViewHelper.setAlpha(RippleView.this, 1);
                mIsAnimating = false;
            }

            @Override
            public void onAnimationCancel(Animator animator) {
            }

            @Override
            public void onAnimationRepeat(Animator animator) {
            }
        });
        mRadiusAnimator.start();
        if (!superResult) {
            return true;
        }
    } else if (event.getActionMasked() == MotionEvent.ACTION_MOVE && this.isEnabled() && mHover) {
        mDownX = event.getX();
        mDownY = event.getY();
        // Cancel the ripple animation when moved outside
        if (mAnimationIsCancel = !mRect.contains(getLeft() + (int) event.getX(), getTop() + (int) event.getY())) {
            setRadius(0);
        } else {
            setRadius(dp(50));
        }
        if (!superResult) {
            return true;
        }
    } else if (event.getActionMasked() == MotionEvent.ACTION_UP && !mAnimationIsCancel && this.isEnabled()) {
        mDownX = event.getX();
        mDownY = event.getY();
        final float tempRadius = (float) Math.sqrt(mDownX * mDownX + mDownY * mDownY);
        float targetRadius = Math.max(tempRadius, mMaxRadius);
        if (mIsAnimating) {
            mRadiusAnimator.cancel();
        }
        mRadiusAnimator = ObjectAnimator.ofFloat(this, "radius", dp(50), targetRadius);
        mRadiusAnimator.setDuration(500);
        mRadiusAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
        mRadiusAnimator.addListener(new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animator) {
                mIsAnimating = true;
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                setRadius(0);
                ViewHelper.setAlpha(RippleView.this, 1);
                mIsAnimating = false;
            }

            @Override
            public void onAnimationCancel(Animator animator) {
            }

            @Override
            public void onAnimationRepeat(Animator animator) {
            }
        });
        mRadiusAnimator.start();
        if (!superResult) {
            return true;
        }
    }
    return superResult;
}
Also used : Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator)

Example 15 with AccelerateDecelerateInterpolator

use of android.view.animation.AccelerateDecelerateInterpolator in project StarWars.Android by Yalantis.

the class StarWarsRenderer method startAnimation.

public void startAnimation() {
    new Handler(Looper.getMainLooper()).post(new Runnable() {

        @Override
        public void run() {
            // plane height
            animator = ValueAnimator.ofFloat(0, -Const.PLANE_HEIGHT * 2);
            animator.setDuration(mAnimationDuration);
            animator.setInterpolator(new AccelerateDecelerateInterpolator());
            animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    float value = (float) animation.getAnimatedValue();
                    deltaPosX = value;
                    mGlSurfaceView.requestRender();
                }
            });
            animator.addListener(new Animator.AnimatorListener() {

                @Override
                public void onAnimationStart(Animator animation) {
                    mGlSurfaceView.requestRender();
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    mListener.onAnimationFinished();
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                }

                @Override
                public void onAnimationRepeat(Animator animation) {
                }
            });
            animator.start();
        }
    });
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) Handler(android.os.Handler) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) ValueAnimator(android.animation.ValueAnimator)

Aggregations

AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)152 ObjectAnimator (android.animation.ObjectAnimator)30 ValueAnimator (android.animation.ValueAnimator)30 Animator (android.animation.Animator)28 View (android.view.View)28 AnimatorSet (android.animation.AnimatorSet)19 Animation (android.view.animation.Animation)19 Handler (android.os.Handler)14 TranslateAnimation (android.view.animation.TranslateAnimation)12 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)10 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)10 AlphaAnimation (android.view.animation.AlphaAnimation)10 ImageView (android.widget.ImageView)10 Paint (android.graphics.Paint)9 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)9 LinearInterpolator (android.view.animation.LinearInterpolator)9 ScaleAnimation (android.view.animation.ScaleAnimation)9 PropertyValuesHolder (android.animation.PropertyValuesHolder)8 TextView (android.widget.TextView)8 Point (android.graphics.Point)7