Search in sources :

Example 41 with AccelerateDecelerateInterpolator

use of android.view.animation.AccelerateDecelerateInterpolator in project CompactCalendarView by SundeepK.

the class AnimationHandler method getExposeCollapsingAnimation.

@NonNull
private Animation getExposeCollapsingAnimation(final boolean isCollapsing) {
    Animation heightAnim = getCollapsingAnimation(isCollapsing);
    heightAnim.setDuration(HEIGHT_ANIM_DURATION_MILLIS);
    heightAnim.setInterpolator(new AccelerateDecelerateInterpolator());
    return heightAnim;
}
Also used : Animation(android.view.animation.Animation) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) NonNull(android.support.annotation.NonNull)

Example 42 with AccelerateDecelerateInterpolator

use of android.view.animation.AccelerateDecelerateInterpolator in project CompactCalendarView by SundeepK.

the class AnimationHandler method closeCalendar.

void closeCalendar() {
    if (isAnimating) {
        return;
    }
    isAnimating = true;
    Animation heightAnim = getCollapsingAnimation(false);
    heightAnim.setDuration(HEIGHT_ANIM_DURATION_MILLIS);
    heightAnim.setInterpolator(new AccelerateDecelerateInterpolator());
    setUpAnimationLisForClose(heightAnim);
    compactCalendarController.setAnimationStatus(CompactCalendarController.EXPAND_COLLAPSE_CALENDAR);
    compactCalendarView.getLayoutParams().height = compactCalendarView.getHeight();
    compactCalendarView.requestLayout();
    compactCalendarView.startAnimation(heightAnim);
}
Also used : Animation(android.view.animation.Animation) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator)

Example 43 with AccelerateDecelerateInterpolator

use of android.view.animation.AccelerateDecelerateInterpolator in project Bitocle by mthli.

the class SmoothProgressBar method applyStyle.

public void applyStyle(int styleResId) {
    TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SmoothProgressBar, 0, styleResId);
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_color)) {
        setSmoothProgressDrawableColor(a.getColor(R.styleable.SmoothProgressBar_spb_color, 0));
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_colors)) {
        int colorsId = a.getResourceId(R.styleable.SmoothProgressBar_spb_colors, 0);
        if (colorsId != 0) {
            int[] colors = getResources().getIntArray(colorsId);
            if (colors != null && colors.length > 0)
                setSmoothProgressDrawableColors(colors);
        }
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_sections_count)) {
        setSmoothProgressDrawableSectionsCount(a.getInteger(R.styleable.SmoothProgressBar_spb_sections_count, 0));
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_stroke_separator_length)) {
        setSmoothProgressDrawableSeparatorLength(a.getDimensionPixelSize(R.styleable.SmoothProgressBar_spb_stroke_separator_length, 0));
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_stroke_width)) {
        setSmoothProgressDrawableStrokeWidth(a.getDimension(R.styleable.SmoothProgressBar_spb_stroke_width, 0));
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_speed)) {
        setSmoothProgressDrawableSpeed(a.getFloat(R.styleable.SmoothProgressBar_spb_speed, 0));
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_progressiveStart_speed)) {
        setSmoothProgressDrawableProgressiveStartSpeed(a.getFloat(R.styleable.SmoothProgressBar_spb_progressiveStart_speed, 0));
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_progressiveStop_speed)) {
        setSmoothProgressDrawableProgressiveStopSpeed(a.getFloat(R.styleable.SmoothProgressBar_spb_progressiveStop_speed, 0));
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_reversed)) {
        setSmoothProgressDrawableReversed(a.getBoolean(R.styleable.SmoothProgressBar_spb_reversed, false));
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_mirror_mode)) {
        setSmoothProgressDrawableMirrorMode(a.getBoolean(R.styleable.SmoothProgressBar_spb_mirror_mode, false));
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_progressiveStart_activated)) {
        setProgressiveStartActivated(a.getBoolean(R.styleable.SmoothProgressBar_spb_progressiveStart_activated, false));
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_progressiveStart_activated)) {
        setProgressiveStartActivated(a.getBoolean(R.styleable.SmoothProgressBar_spb_progressiveStart_activated, false));
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_gradients)) {
        setSmoothProgressDrawableUseGradients(a.getBoolean(R.styleable.SmoothProgressBar_spb_gradients, false));
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_generate_background_with_colors)) {
        if (a.getBoolean(R.styleable.SmoothProgressBar_spb_generate_background_with_colors, false)) {
            setSmoothProgressDrawableBackgroundDrawable(SmoothProgressBarUtils.generateDrawableWithColors(checkIndeterminateDrawable().getColors(), checkIndeterminateDrawable().getStrokeWidth()));
        }
    }
    if (a.hasValue(R.styleable.SmoothProgressBar_spb_interpolator)) {
        int iInterpolator = a.getInteger(R.styleable.SmoothProgressBar_spb_interpolator, -1);
        Interpolator interpolator;
        switch(iInterpolator) {
            case INTERPOLATOR_ACCELERATEDECELERATE:
                interpolator = new AccelerateDecelerateInterpolator();
                break;
            case INTERPOLATOR_DECELERATE:
                interpolator = new DecelerateInterpolator();
                break;
            case INTERPOLATOR_LINEAR:
                interpolator = new LinearInterpolator();
                break;
            case INTERPOLATOR_ACCELERATE:
                interpolator = new AccelerateInterpolator();
                break;
            default:
                interpolator = null;
        }
        if (interpolator != null) {
            setInterpolator(interpolator);
        }
    }
    a.recycle();
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) LinearInterpolator(android.view.animation.LinearInterpolator) TypedArray(android.content.res.TypedArray) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) Interpolator(android.view.animation.Interpolator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) LinearInterpolator(android.view.animation.LinearInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator)

Example 44 with AccelerateDecelerateInterpolator

use of android.view.animation.AccelerateDecelerateInterpolator in project UltimateAndroid by cymcsg.

the class DynamicGridModification method animateReorder.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void animateReorder(final int oldPosition, final int newPosition) {
    boolean isForward = newPosition > oldPosition;
    List<Animator> resultList = new LinkedList<Animator>();
    if (isForward) {
        for (int pos = Math.min(oldPosition, newPosition); pos < Math.max(oldPosition, newPosition); pos++) {
            View view = getViewForId(getId(pos));
            if ((pos + 1) % getColumnCount() == 0) {
                resultList.add(createTranslationAnimations(view, -view.getWidth() * (getColumnCount() - 1), 0, view.getHeight(), 0));
            } else {
                resultList.add(createTranslationAnimations(view, view.getWidth(), 0, 0, 0));
            }
        }
    } else {
        for (int pos = Math.max(oldPosition, newPosition); pos > Math.min(oldPosition, newPosition); pos--) {
            View view = getViewForId(getId(pos));
            if ((pos + getColumnCount()) % getColumnCount() == 0) {
                resultList.add(createTranslationAnimations(view, view.getWidth() * (getColumnCount() - 1), 0, -view.getHeight(), 0));
            } else {
                resultList.add(createTranslationAnimations(view, -view.getWidth(), 0, 0, 0));
            }
        }
    }
    AnimatorSet resultSet = new AnimatorSet();
    resultSet.playTogether(resultList);
    resultSet.setDuration(MOVE_DURATION);
    resultSet.setInterpolator(new AccelerateDecelerateInterpolator());
    resultSet.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            mReorderAnimation = true;
            updateEnableState();
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mReorderAnimation = false;
            updateEnableState();
        }
    });
    resultSet.start();
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) GridView(android.widget.GridView) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) Point(android.graphics.Point) TargetApi(android.annotation.TargetApi)

Example 45 with AccelerateDecelerateInterpolator

use of android.view.animation.AccelerateDecelerateInterpolator in project android_packages_apps_Launcher2 by CyanogenMod.

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);
    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);
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) AppWidgetHostView(android.appwidget.AppWidgetHostView) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) Resources(android.content.res.Resources)

Aggregations

AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)165 ValueAnimator (android.animation.ValueAnimator)38 ObjectAnimator (android.animation.ObjectAnimator)31 Animator (android.animation.Animator)30 View (android.view.View)30 AnimatorSet (android.animation.AnimatorSet)22 Animation (android.view.animation.Animation)19 Handler (android.os.Handler)15 NonNull (android.support.annotation.NonNull)12 TranslateAnimation (android.view.animation.TranslateAnimation)12 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)11 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)10 AlphaAnimation (android.view.animation.AlphaAnimation)10 ImageView (android.widget.ImageView)10 TextView (android.widget.TextView)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