Search in sources :

Example 61 with LinearInterpolator

use of android.view.animation.LinearInterpolator 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 62 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project wechat by motianhuo.

the class FlippingImageView method setRotateAnimation.

private void setRotateAnimation() {
    if (mIsHasAnimation == false && getWidth() > 0 && getVisibility() == View.VISIBLE) {
        mIsHasAnimation = true;
        mAnimation = new RotateAnimation(getWidth() / 2.0F, getHeight() / 2.0F, Mode.Y);
        mAnimation.setDuration(1000L);
        mAnimation.setInterpolator(new LinearInterpolator());
        mAnimation.setRepeatCount(-1);
        mAnimation.setRepeatMode(Animation.RESTART);
        setAnimation(mAnimation);
    }
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator)

Example 63 with LinearInterpolator

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

the class Titanic method start.

public void start(final TitanicTextView textView) {
    final Runnable animate = new Runnable() {

        @Override
        public void run() {
            textView.setSinking(true);
            // horizontal animation. 200 = wave.png width
            ObjectAnimator maskXAnimator = ObjectAnimator.ofFloat(textView, "maskX", 0, 200);
            maskXAnimator.setRepeatCount(ValueAnimator.INFINITE);
            maskXAnimator.setDuration(1000);
            maskXAnimator.setStartDelay(0);
            int h = textView.getHeight();
            // vertical animation
            // maskY = 0 -> wave vertically centered
            // repeat mode REVERSE to go back and forth
            ObjectAnimator maskYAnimator = ObjectAnimator.ofFloat(textView, "maskY", h / 2, -h / 2);
            maskYAnimator.setRepeatCount(ValueAnimator.INFINITE);
            maskYAnimator.setRepeatMode(ValueAnimator.REVERSE);
            maskYAnimator.setDuration(10000);
            maskYAnimator.setStartDelay(0);
            // now play both animations together
            animatorSet = new AnimatorSet();
            animatorSet.playTogether(maskXAnimator, maskYAnimator);
            animatorSet.setInterpolator(new LinearInterpolator());
            animatorSet.addListener(new Animator.AnimatorListener() {

                @Override
                public void onAnimationStart(Animator animation) {
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    textView.setSinking(false);
                    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                        textView.postInvalidate();
                    } else {
                        textView.postInvalidateOnAnimation();
                    }
                    animatorSet = null;
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                }

                @Override
                public void onAnimationRepeat(Animator animation) {
                }
            });
            if (animatorListener != null) {
                animatorSet.addListener(animatorListener);
            }
            animatorSet.start();
        }
    };
    if (!textView.isSetUp()) {
        textView.setAnimationSetupCallback(new TitanicTextView.AnimationSetupCallback() {

            @Override
            public void onSetupAnimation(final TitanicTextView target) {
                animate.run();
            }
        });
    } else {
        animate.run();
    }
}
Also used : ValueAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ValueAnimator) ObjectAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ObjectAnimator) Animator(com.marshalchen.common.uimodule.nineoldandroids.animation.Animator) LinearInterpolator(android.view.animation.LinearInterpolator) ObjectAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.marshalchen.common.uimodule.nineoldandroids.animation.AnimatorSet)

Example 64 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project ETSMobile-Android2 by ApplETS.

the class CustomProgressDialog method show.

@Override
public void show() {
    super.show();
    RotateAnimation anim = new RotateAnimation(0.0f, 359.0f, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
    anim.setInterpolator(new LinearInterpolator());
    anim.setRepeatCount(Animation.INFINITE);
    anim.setDuration(3000);
    rotatingImageView.setAnimation(anim);
    rotatingImageView.startAnimation(anim);
}
Also used : RotateAnimation(android.view.animation.RotateAnimation) LinearInterpolator(android.view.animation.LinearInterpolator)

Example 65 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project ChipsLayoutManager by BelooS.

the class HorizontalScrollingController method createSmoothScroller.

@Override
public RecyclerView.SmoothScroller createSmoothScroller(@NonNull Context context, final int position, final int timeMs, final AnchorViewState anchor) {
    return new LinearSmoothScroller(context) {

        /*
             * LinearSmoothScroller, at a minimum, just need to know the vector
             * (x/y distance) to travel in order to get from the current positioning
             * to the target.
             */
        @Override
        public PointF computeScrollVectorForPosition(int targetPosition) {
            int visiblePosition = anchor.getPosition();
            //determine scroll up or scroll down needed
            return new PointF(position > visiblePosition ? 1 : -1, 0);
        }

        @Override
        protected void onTargetFound(View targetView, RecyclerView.State state, Action action) {
            super.onTargetFound(targetView, state, action);
            int currentLeft = layoutManager.getPaddingLeft();
            int desiredLeft = layoutManager.getDecoratedLeft(targetView);
            int dx = desiredLeft - currentLeft;
            //perform fit animation to move target view at top of layoutX
            action.update(dx, 0, timeMs, new LinearInterpolator());
        }
    };
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) AnchorViewState(com.beloo.widget.chipslayoutmanager.anchor.AnchorViewState) PointF(android.graphics.PointF) LinearSmoothScroller(android.support.v7.widget.LinearSmoothScroller) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

LinearInterpolator (android.view.animation.LinearInterpolator)217 ValueAnimator (android.animation.ValueAnimator)65 Animator (android.animation.Animator)42 ObjectAnimator (android.animation.ObjectAnimator)39 Paint (android.graphics.Paint)30 ArrayList (java.util.ArrayList)28 AlphaAnimation (android.view.animation.AlphaAnimation)27 RotateAnimation (android.view.animation.RotateAnimation)24 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)22 PropertyValuesHolder (android.animation.PropertyValuesHolder)18 Animatable (android.graphics.drawable.Animatable)17 View (android.view.View)17 Animation (android.view.animation.Animation)17 Transformation (android.view.animation.Transformation)17 AnimatorSet (android.animation.AnimatorSet)14 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)14 TranslateAnimation (android.view.animation.TranslateAnimation)12 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)11 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)9 AnimationListener (android.view.animation.Animation.AnimationListener)8