Search in sources :

Example 96 with Interpolator

use of android.view.animation.Interpolator in project sbt-android by scala-android.

the class FabDialogMorphSetup method setupSharedEelementTransitions.

/**
 * Configure the shared element transitions for morphin from a fab <-> dialog. We need to do
 * this in code rather than declaratively as we need to supply the color to transition from/to
 * and the dialog corner radius which is dynamically supplied depending upon where this screen
 * is launched from.
 */
public static void setupSharedEelementTransitions(@NonNull Activity activity, @Nullable View target, int dialogCornerRadius) {
    if (!activity.getIntent().hasExtra(EXTRA_SHARED_ELEMENT_START_COLOR))
        return;
    int startCornerRadius = activity.getIntent().getIntExtra(EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS, -1);
    ArcMotion arcMotion = new ArcMotion();
    arcMotion.setMinimumHorizontalAngle(50f);
    arcMotion.setMinimumVerticalAngle(50f);
    int color = activity.getIntent().getIntExtra(EXTRA_SHARED_ELEMENT_START_COLOR, Color.TRANSPARENT);
    Interpolator easeInOut = AnimationUtils.loadInterpolator(activity, android.R.interpolator.fast_out_slow_in);
    MorphFabToDialog sharedEnter = new MorphFabToDialog(color, dialogCornerRadius, startCornerRadius);
    sharedEnter.setPathMotion(arcMotion);
    sharedEnter.setInterpolator(easeInOut);
    MorphDialogToFab sharedReturn = new MorphDialogToFab(color, startCornerRadius);
    sharedReturn.setPathMotion(arcMotion);
    sharedReturn.setInterpolator(easeInOut);
    if (target != null) {
        sharedEnter.addTarget(target);
        sharedReturn.addTarget(target);
    }
    activity.getWindow().setSharedElementEnterTransition(sharedEnter);
    activity.getWindow().setSharedElementReturnTransition(sharedReturn);
}
Also used : Interpolator(android.view.animation.Interpolator) ArcMotion(android.transition.ArcMotion)

Example 97 with Interpolator

use of android.view.animation.Interpolator in project iosched by google.

the class AppBarLayout method onLayout.

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    invalidateScrollRanges();
    mHaveChildWithInterpolator = false;
    for (int i = 0, z = getChildCount(); i < z; i++) {
        final View child = getChildAt(i);
        final LayoutParams childLp = (LayoutParams) child.getLayoutParams();
        final Interpolator interpolator = childLp.getScrollInterpolator();
        if (interpolator != null) {
            mHaveChildWithInterpolator = true;
            break;
        }
    }
    updateCollapsible();
}
Also used : Interpolator(android.view.animation.Interpolator) View(android.view.View)

Example 98 with Interpolator

use of android.view.animation.Interpolator in project platform_packages_apps_Settings by BlissRoms.

the class PreviewPagerAdapter method setVisibility.

private void setVisibility(final View view, final int visibility, boolean animate) {
    final float alpha = (visibility == View.VISIBLE ? 1.0f : 0.0f);
    if (!animate) {
        view.setAlpha(alpha);
        view.setVisibility(visibility);
    } else {
        final Interpolator interpolator = (visibility == View.VISIBLE ? FADE_IN_INTERPOLATOR : FADE_OUT_INTERPOLATOR);
        if (visibility == View.VISIBLE) {
            // Fade in animation.
            view.animate().alpha(alpha).setInterpolator(FADE_IN_INTERPOLATOR).setDuration(CROSS_FADE_DURATION_MS).setListener(new PreviewFrameAnimatorListener()).withStartAction(new Runnable() {

                @Override
                public void run() {
                    view.setVisibility(visibility);
                }
            });
        } else {
            // Fade out animation.
            view.animate().alpha(alpha).setInterpolator(FADE_OUT_INTERPOLATOR).setDuration(CROSS_FADE_DURATION_MS).setListener(new PreviewFrameAnimatorListener()).withEndAction(new Runnable() {

                @Override
                public void run() {
                    view.setVisibility(visibility);
                }
            });
        }
    }
}
Also used : Interpolator(android.view.animation.Interpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator)

Example 99 with Interpolator

use of android.view.animation.Interpolator in project Osmand by osmandapp.

the class BusyIndicator method updateStatus.

/**
 * @param status - 0 invisible
 * 1
 */
public void updateStatus(int status) {
    if (this.status != status) {
        this.status = status;
        final Drawable drawable;
        if (this.status == STATUS_BLACK) {
            drawable = ctx.getResources().getDrawable(R.drawable.progress_grey);
        } else if (this.status == STATUS_ORANGE) {
            drawable = ctx.getResources().getDrawable(R.drawable.progress_orange);
        } else if (this.status == STATUS_GREEN) {
            drawable = ctx.getResources().getDrawable(R.drawable.progress_green);
        } else {
            drawable = null;
        }
        final RotateAnimation animation;
        if (drawable != null) {
            animation = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
            animation.setRepeatCount(Animation.INFINITE);
            final int cycles = 12;
            animation.setInterpolator(new Interpolator() {

                @Override
                public float getInterpolation(float input) {
                    return ((int) (input * cycles)) / (float) cycles;
                }
            });
            animation.setDuration(1200);
            animation.setStartTime(RotateAnimation.START_ON_FIRST_FRAME);
            animation.setStartOffset(0);
        } else {
            animation = null;
        }
        uiHandler.post(new Runnable() {

            @Override
            public void run() {
                bar.setVisibility(drawable != null ? View.VISIBLE : View.INVISIBLE);
                if (bar.getAnimation() != null) {
                    bar.clearAnimation();
                }
                if (drawable != null) {
                    bar.setBackgroundDrawable(drawable);
                    bar.startAnimation(animation);
                }
            }
        });
    }
}
Also used : RotateAnimation(android.view.animation.RotateAnimation) Drawable(android.graphics.drawable.Drawable) Interpolator(android.view.animation.Interpolator)

Example 100 with Interpolator

use of android.view.animation.Interpolator in project butter-android by butterproject.

the class BurtterCollapsingToolbarLayout method setScrimsShown.

@Override
public void setScrimsShown(final boolean shown, final boolean animate) {
    super.setScrimsShown(shown, animate);
    if (scrimsAreShown != shown) {
        findToolbar();
        if (toolbar != null) {
            if (animator != null) {
                animator.cancel();
            }
            if (animate) {
                animator = ValueAnimator.ofFloat(0, 1);
                animator.setDuration(getScrimAnimationDuration());
                Interpolator interpolator = shown ? new FastOutLinearInInterpolator() : new LinearOutSlowInInterpolator();
                animator.setInterpolator(interpolator);
                final ArgbEvaluator evaluator = new ArgbEvaluator();
                animator.addUpdateListener(new AnimatorUpdateListener() {

                    @Override
                    public void onAnimationUpdate(ValueAnimator animation) {
                        float fraction = animation.getAnimatedFraction();
                        int color;
                        if (shown) {
                            color = (int) evaluator.evaluate(fraction, TEXT_COLOR_TRANSPARENT, TEXT_COLOR);
                        } else {
                            color = (int) evaluator.evaluate(fraction, TEXT_COLOR, TEXT_COLOR_TRANSPARENT);
                        }
                        toolbar.setTitleTextColor(color);
                    }
                });
                animator.start();
            } else {
                toolbar.setTitleTextColor(shown ? TEXT_COLOR : TEXT_COLOR_TRANSPARENT);
            }
        }
        scrimsAreShown = shown;
    }
}
Also used : LinearOutSlowInInterpolator(android.support.v4.view.animation.LinearOutSlowInInterpolator) ArgbEvaluator(android.animation.ArgbEvaluator) FastOutLinearInInterpolator(android.support.v4.view.animation.FastOutLinearInInterpolator) Interpolator(android.view.animation.Interpolator) LinearOutSlowInInterpolator(android.support.v4.view.animation.LinearOutSlowInInterpolator) FastOutLinearInInterpolator(android.support.v4.view.animation.FastOutLinearInInterpolator) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Aggregations

Interpolator (android.view.animation.Interpolator)229 Animator (android.animation.Animator)60 ValueAnimator (android.animation.ValueAnimator)49 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)46 ObjectAnimator (android.animation.ObjectAnimator)39 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)25 PathInterpolator (android.view.animation.PathInterpolator)25 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)23 LinearInterpolator (android.view.animation.LinearInterpolator)18 Paint (android.graphics.Paint)17 View (android.view.View)17 PropertyValuesHolder (android.animation.PropertyValuesHolder)16 FloatKeyframe (com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.FloatKeyframe)16 IntKeyframe (com.actionbarsherlock.internal.nineoldandroids.animation.Keyframe.IntKeyframe)16 TimeAnimator (android.animation.TimeAnimator)15 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)14 TypedArray (android.content.res.TypedArray)14 Animation (android.view.animation.Animation)13 AnimatorSet (android.animation.AnimatorSet)12 TimeInterpolator (android.animation.TimeInterpolator)11