Example usage for android.view.animation CycleInterpolator CycleInterpolator

List of usage examples for android.view.animation CycleInterpolator CycleInterpolator

Introduction

In this page you can find the example usage for android.view.animation CycleInterpolator CycleInterpolator.

Prototype

public CycleInterpolator(float cycles) 

Source Link

Usage

From source file:Main.java

public static void translate(final View view, float fromXDelta, float toXDelta, float fromYDelta,
        float toYDelta, float cycles, long durationMillis, final boolean isBanClick) {
    TranslateAnimation translateAnimation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);
    translateAnimation.setDuration(durationMillis);
    if (cycles > 0.0) {
        translateAnimation.setInterpolator(new CycleInterpolator(cycles));
    }//from   ww w . j a  v  a  2s  .  c  om
    translateAnimation.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            if (isBanClick) {
                view.setClickable(false);
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (isBanClick) {
                view.setClickable(true);
            }
        }
    });
    view.startAnimation(translateAnimation);
}

From source file:com.h6ah4i.android.example.materialshadowninepatch.ZPositionAnimationDemoFragment.java

@Override
public void onClick(View v) {
    if (v == mCompatShadowItem) {
        ObjectAnimator animator = ObjectAnimator.ofFloat(mCompatShadowItemContainer,
                MaterialShadowContainerViewProperties.SHADOW_TRANSLATION_Z, mDisplayDensity * 0.0f,
                mDisplayDensity * 8.0f);
        animator.setDuration(500);/*from  w w  w  .j ava  2  s .  co  m*/
        animator.setInterpolator(new CycleInterpolator(0.5f));
        animator.start();
    }
}

From source file:com.savvasdalkitsis.betwixt.Interpolators.java

/**
 * <strong>ANDROID INTERPOLATOR</strong><br/><br/>
 * Repeats the animation for a specified number of cycles. The rate of change follows a sinusoidal pattern.
 *//*from w ww .  java2s. c  o m*/
@NonNull
public static Interpolator cycle(int cycles) {
    return new CycleInterpolator(cycles);
}

From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticLayout.java

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_UP) {
        if (listener != null) {
            if (view.getScaleX() == 1) {
                for (int i = 0; i < this.getChildCount(); i++) {
                    ViewCompat.animate(this.getChildAt(i)).setDuration(duration).scaleX(scale).scaleY(scale)
                            .setInterpolator(new CycleInterpolator(0.5f))
                            .setListener(new ViewPropertyAnimatorListener() {

                                @Override
                                public void onAnimationStart(final View view) {
                                }//from w  ww .jav a 2  s . c o m

                                @Override
                                public void onAnimationEnd(final View v) {
                                    onClick();
                                }

                                @Override
                                public void onAnimationCancel(final View view) {
                                }
                            }).withLayer().start();
                }

                ViewCompat.animate(view).setDuration(duration).scaleX(scale).scaleY(scale)
                        .setInterpolator(new CycleInterpolator(0.5f))
                        .setListener(new ViewPropertyAnimatorListener() {

                            @Override
                            public void onAnimationStart(final View view) {
                            }

                            @Override
                            public void onAnimationEnd(final View v) {
                                onClick();
                            }

                            @Override
                            public void onAnimationCancel(final View view) {
                            }
                        }).withLayer().start();
            }
        }
    }
    return super.dispatchTouchEvent(event);
}

From source file:com.geekandroid.sdk.ClearEditText.java

/**
 * // www. ja  va 2 s .co m
 * @param counts 1
 * @return
 */
public static Animation shakeAnimation(int counts) {
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(1000);
    return translateAnimation;
}

From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticButton.java

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_UP) {
        if (listener != null) {
            if (view.getScaleX() == 1) {
                ViewCompat.animate(view).setDuration(duration).scaleX(scale).scaleY(scale)
                        .setInterpolator(new CycleInterpolator(0.5f))
                        .setListener(new ViewPropertyAnimatorListener() {

                            @Override
                            public void onAnimationStart(final View view) {
                            }/*from ww  w  .  j  a  v a2 s.  c o  m*/

                            @Override
                            public void onAnimationEnd(final View v) {
                                onClick();
                            }

                            @Override
                            public void onAnimationCancel(final View view) {
                            }
                        }).withLayer().start();
            }
        }
    }
    return super.dispatchTouchEvent(event);
}

From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticCheckButton.java

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_UP) {
        if (listener != null) {
            if (view.getScaleX() == 1) {
                ViewCompat.animate(view).setDuration(duration).scaleX(scale).scaleY(scale)
                        .setInterpolator(new CycleInterpolator(0.5f))
                        .setListener(new ViewPropertyAnimatorListener() {

                            @Override
                            public void onAnimationStart(final View view) {
                            }//w  ww  . jav a 2 s  .co m

                            @Override
                            public void onAnimationEnd(final View v) {
                                checked = !checked;
                                onClick();
                            }

                            @Override
                            public void onAnimationCancel(final View view) {
                            }
                        }).withLayer().start();
            }
        }
    }
    return super.dispatchTouchEvent(event);
}

From source file:pl.mg6.android.maps.extensions.demo.AnimateMarkersActivity.java

private Interpolator randomInterpolator() {
    int val = random.nextInt(14);
    switch (val) {
    case 0:/*from ww w  .j ava 2 s.c  o m*/
        return new LinearInterpolator();
    case 1:
        return new AccelerateDecelerateInterpolator();
    case 2:
        return new AccelerateInterpolator();
    case 3:
        return new AccelerateInterpolator(6.0f);
    case 4:
        return new DecelerateInterpolator();
    case 5:
        return new DecelerateInterpolator(6.0f);
    case 6:
        return new BounceInterpolator();
    case 7:
        return new AnticipateOvershootInterpolator();
    case 8:
        return new AnticipateOvershootInterpolator(6.0f);
    case 9:
        return new AnticipateInterpolator();
    case 10:
        return new AnticipateInterpolator(6.0f);
    case 11:
        return new OvershootInterpolator();
    case 12:
        return new OvershootInterpolator(6.0f);
    case 13:
        return new CycleInterpolator(1.25f);
    }
    throw new RuntimeException();
}

From source file:com.github.shareme.gwsmaterialuikit.library.viewanimator.AnimationBuilder.java

public AnimationBuilder shake() {
    translationX(0, 25, -25, 25, -25, 15, -15, 6, -6, 0);
    interpolator(new CycleInterpolator(5));
    return this;
}

From source file:org.protocoderrunner.apprunner.api.PUI.java

@ProtocoderScript
@APIMethod(description = "Makes the view blink", example = "")
@APIParam(params = { "View", "num" })
public void blink(View v, int num) {
    ObjectAnimator anim = ObjectAnimator.ofFloat(v, "alpha", 1f, 0f, 1f);
    anim.setDuration(AppSettings.animGeneralSpeed);
    anim.setInterpolator(new CycleInterpolator(1));
    anim.setRepeatCount(num);/*from w  w  w  .  j  a v a 2s.c om*/
    anim.start();
}