java类android.view.animation.CycleInterpolator的实例源码

SquareKey.java 文件源码 项目:PasscodeView 阅读 31 收藏 0 点赞 0 评论 0
/**
 * Public constructor.
 *
 * @param pinView {@link PinView}
 * @param digit   title of the key. (-1 for the backspace key)
 * @param bounds  {@link Rect} bound.
 */
private SquareKey(@NonNull PinView pinView,
                  @NonNull String digit,
                  @NonNull Rect bounds,
                  @NonNull SquareKey.Builder builder) {
    super(pinView, digit, bounds, builder);

    mBounds = bounds;
    mBuilder = builder;

    //Error animator
    mErrorAnimator = ValueAnimator.ofInt(0, 10);
    mErrorAnimator.setInterpolator(new CycleInterpolator(2));
    mErrorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mBounds.left += (int) animation.getAnimatedValue();
            mBounds.right += (int) animation.getAnimatedValue();
            getPinView().invalidate();
        }
    });
}
RectKey.java 文件源码 项目:PasscodeView 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Public constructor.
 *
 * @param pinView {@link PinView}
 * @param digit   title of the key. (-1 for the backspace key)
 * @param bounds  {@link Rect} bound.
 */
private RectKey(@NonNull PinView pinView,
                @NonNull String digit,
                @NonNull Rect bounds,
                @NonNull RectKey.Builder builder) {
    super(pinView, digit, bounds, builder);

    mBounds = bounds;
    mBuilder = builder;

    //Error animator
    mErrorAnimator = ValueAnimator.ofInt(0, 10);
    mErrorAnimator.setInterpolator(new CycleInterpolator(2));
    mErrorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mBounds.left += (int) animation.getAnimatedValue();
            mBounds.right += (int) animation.getAnimatedValue();
            getPinView().invalidate();
        }
    });
}
SegmentedButtonGroup.java 文件源码 项目:SegmentedButton 阅读 39 收藏 0 点赞 0 评论 0
private void initInterpolations() {
    ArrayList<Class> interpolatorList = new ArrayList<Class>() {{
        add(FastOutSlowInInterpolator.class);
        add(BounceInterpolator.class);
        add(LinearInterpolator.class);
        add(DecelerateInterpolator.class);
        add(CycleInterpolator.class);
        add(AnticipateInterpolator.class);
        add(AccelerateDecelerateInterpolator.class);
        add(AccelerateInterpolator.class);
        add(AnticipateOvershootInterpolator.class);
        add(FastOutLinearInInterpolator.class);
        add(LinearOutSlowInInterpolator.class);
        add(OvershootInterpolator.class);
    }};

    try {
        interpolatorSelector = (Interpolator) interpolatorList.get(animateSelector).newInstance();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
FrameFragment.java 文件源码 项目:AndroidAnimationDemo 阅读 26 收藏 0 点赞 0 评论 0
@OnClick(R.id.btn_start)
    public void onAction() {

//        float start = mView.getY();
//        if (start > 680f) {
//            start = 0f;
//            mView.setY(0f);
//        }

//        Keyframe kf0 = Keyframe.ofFloat(0f, 0f);
//        Keyframe kf1 = Keyframe.ofFloat(.5f, 360f);
//        Keyframe kf2 = Keyframe.ofFloat(1f, 0f);
//        PropertyValuesHolder pvh = PropertyValuesHolder.ofKeyframe("X", kf0, kf1, kf2);
//        ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(mView, pvh);
//
//        anim.setDuration(5000);
//        anim.setInterpolator(new AccelerateDecelerateInterpolator());
//        anim.start();

        ObjectAnimator animX = ObjectAnimator.ofFloat(mView, "x", 0, 50f);
        ObjectAnimator animY = ObjectAnimator.ofFloat(mView, "y", 0, 100f);
        AnimatorSet animSetXY = new AnimatorSet();
        animSetXY.playTogether(animX, animY);
        animSetXY.setInterpolator(new CycleInterpolator(0.5f));
        animSetXY.start();
    }
Password.java 文件源码 项目:DiaryMemo 阅读 34 收藏 0 点赞 0 评论 0
private void initAnimation(){
    pushLeftIn = new TranslateAnimation(
            TranslateAnimation.RELATIVE_TO_SELF, 1.0f,   
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
    pushLeftIn.setDuration(200);
    pushLeftIn.setFillAfter(true);

    pushLeftOut = new TranslateAnimation(
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f,   
            TranslateAnimation.RELATIVE_TO_SELF, -1.0f,
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
    pushLeftOut.setDuration(200);
    pushLeftOut.setFillAfter(true);

    shakeAni = new TranslateAnimation(
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f,   
            TranslateAnimation.RELATIVE_TO_SELF, 0.05f,
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
    shakeAni.setDuration(300);
    shakeAni.setInterpolator(new CycleInterpolator(2.0f));
}
ViewBouncer.java 文件源码 项目:CmoaQuiz 阅读 31 收藏 0 点赞 0 评论 0
@Override
public void run() {

    if (mView != null && mView.getWidth() != 0 && mView.getHeight() != 0) {

        if (bounceViewAnimation != null && !bounceViewAnimation.hasEnded()) {
            return;
        }

        bounceViewAnimation = new ScaleAnimation(1f, mRatio, 1f, mRatio, mView.getWidth() / 2, mView.getHeight() / 2);

        // Define the parameters of the animation
        bounceViewAnimation.setDuration(mTime);
        bounceViewAnimation.setInterpolator(new CycleInterpolator(0.5f));
        mView.setVisibility(View.VISIBLE);
        mView.startAnimation(bounceViewAnimation);
    }

    if (mInfiniteBounce) {
        bounceViewHandler.postDelayed(bounceViewRunnable, 2000);
    }
}
BaseFragmentActivity.java 文件源码 项目:MaterialAppBase 阅读 37 收藏 0 点赞 0 评论 0
/**
    * To shake a view
    * @param view
    */
protected void shakeView(View view){
    float delta = 10.0f;
    CycleInterpolator cycle = new CycleInterpolator(6);
    AnimationSet animSet = new AnimationSet(false);

    Animation anim = new TranslateAnimation(0, delta, 0, 0);
    anim.setDuration(500);
    anim.setInterpolator(cycle);
    animSet.addAnimation(anim);
    view.startAnimation(animSet);

    try{
        Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.vibrate(300);
    }catch(Exception e){}

}
WindowShaker.java 文件源码 项目:WindowShaker 阅读 32 收藏 0 点赞 0 评论 0
public static void shake(View view, Option option) {

        if (option == null) {
            option = getOption(view.getContext());
        }

        TranslateAnimation ta = new TranslateAnimation(-option.mOffsetX,
                option.mOffsetX, -option.mOffsetY, option.mOffsetY);
        ta.setDuration(option.mDuration);
        ta.setInterpolator(new CycleInterpolator(option.mRepeatCount));

        view.startAnimation(ta);

        if (option.mVibrate) {
            Vibrator v = (Vibrator) view.getContext().getSystemService(
                    Context.VIBRATOR_SERVICE);
            v.vibrate(getVibratePattern(option), -1);
        }
    }
MainActivity.java 文件源码 项目:CircularProgressDrawable 阅读 29 收藏 0 点赞 0 评论 0
/**
 * This animation will make a pulse effect to the inner circle
 *
 * @return Animation
 */
private Animator preparePulseAnimation() {
    AnimatorSet animation = new AnimatorSet();

    Animator firstBounce = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY,
            drawable.getCircleScale(), 0.88f);
    firstBounce.setDuration(300);
    firstBounce.setInterpolator(new CycleInterpolator(1));
    Animator secondBounce = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY,
            0.75f, 0.83f);
    secondBounce.setDuration(300);
    secondBounce.setInterpolator(new CycleInterpolator(1));
    Animator thirdBounce = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY,
            0.75f, 0.80f);
    thirdBounce.setDuration(300);
    thirdBounce.setInterpolator(new CycleInterpolator(1));

    animation.playSequentially(firstBounce, secondBounce, thirdBounce);
    return animation;
}
CardDrawable.java 文件源码 项目:triples 阅读 30 收藏 0 点赞 0 评论 0
void setHinted(boolean hinted) {
  if (mHinted != hinted) {
    mHinted = hinted;
    regenerateCachedDrawable();
    if (hinted) {
      // Throb animation
      Animation throbAnimation =
          new ScaleAnimation(1.0f, 1.15f, 1.0f, 1.15f, mBounds.centerX(), mBounds.centerY());
      throbAnimation.setInterpolator(new CycleInterpolator(0.5f));
      throbAnimation.setDuration(HINT_ANIMATION_DURATION_MS);
      throbAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
      throbAnimation.setAnimationListener(new BaseAnimationListener());
      updateAnimation(throbAnimation);
    }
  }
}
CardDrawable.java 文件源码 项目:triples 阅读 30 收藏 0 点赞 0 评论 0
void onIncorrectTriple() {
  mSelected = false;
  mShakeAnimating = true;
  // Shake animation
  Animation shakeAnimation = new RotateAnimation(0, 5, mBounds.centerX(), mBounds.centerY());
  shakeAnimation.setInterpolator(new CycleInterpolator(4));
  shakeAnimation.setDuration(INCORRECT_ANIMATION_DURATION_MS);
  shakeAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
  shakeAnimation.setAnimationListener(
      new BaseAnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
          super.onAnimationEnd(animation);
          mShakeAnimating = false;
          regenerateCachedDrawable();
        }
      });
  updateAnimation(shakeAnimation);
}
AnimUtils.java 文件源码 项目:PaymentKit-Droid 阅读 38 收藏 0 点赞 0 评论 0
/**
 * @param shouldResetTextColor if true make sure you end the previous animation before starting this one.
 */
public static ObjectAnimator getShakeAnimation(final TextView textView, final boolean shouldResetTextColor) {
    final int textColor = textView.getCurrentTextColor();
    textView.setTextColor(Color.RED);

    ObjectAnimator shakeAnim = ObjectAnimator.ofFloat(textView, "translationX", -16);
    shakeAnim.setDuration(SHAKE_DURATION);
    shakeAnim.setInterpolator(new CycleInterpolator(2.0f));
    shakeAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator anim) {
            if (shouldResetTextColor) {
                textView.setTextColor(textColor);
            }
        }
    });
    return shakeAnim;
}
DialogPopup.java 文件源码 项目:GitHub 阅读 35 收藏 0 点赞 0 评论 0
@Override
protected Animation initShowAnimation() {
    AnimationSet set=new AnimationSet(false);
    Animation shakeAnima=new RotateAnimation(0,15,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
    shakeAnima.setInterpolator(new CycleInterpolator(5));
    shakeAnima.setDuration(400);
    set.addAnimation(getDefaultAlphaAnimation());
    set.addAnimation(shakeAnima);
    return set;
}
UDInterpolator.java 文件源码 项目:LuaViewPlayground 阅读 42 收藏 0 点赞 0 评论 0
public static Interpolator parse(Integer type, Float cycles) {
        if (type != null) {
            switch (type) {
                case 0:
                    return new AccelerateDecelerateInterpolator();
                case 1:
                    return new AccelerateInterpolator();
                case 2:
                    return new AnticipateInterpolator();
                case 3:
                    return new AnticipateOvershootInterpolator();
                case 4:
                    return new BounceInterpolator();
                case 5:
                    return new CycleInterpolator((cycles != null && cycles > 0) ? cycles : 1f);
                case 6:
                    return new DecelerateInterpolator();
                case 7:
                    return new LinearInterpolator();
                case 8:
                    return new OvershootInterpolator();
                //暂时不支持的
//            case 7: return new FastOutLinearInterplator();
//            case 8: return new FastOutSlowInInterplator();
//            case 10: return new LinearOutSlowInInterplator();
//            case 12: return new PathInterplator();
                default:
                    return new LinearInterpolator();
            }
        } else {
            return new LinearInterpolator();
        }
    }
MultiFuncEditText.java 文件源码 项目:MultiFuncViewLibrary 阅读 34 收藏 0 点赞 0 评论 0
/**
 * 晃动动画
 *
 * @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;
}
ClearEditText.java 文件源码 项目:UnversityFinance 阅读 30 收藏 0 点赞 0 评论 0
/**
 * 晃动动画
 * @param counts 0.5秒钟晃动多少下
 * @return
 */
private Animation shakeAnimation(int counts){
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(500);
    return translateAnimation;
}
PowerfulEditText.java 文件源码 项目:PowerfulEditText 阅读 33 收藏 0 点赞 0 评论 0
/**
 * 晃动动画
 * @param counts 0.5秒钟晃动多少下
 * @return
 */
private Animation shakeAnimation(int counts){
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(500);
    return translateAnimation;
}
ClearEditText.java 文件源码 项目:ShangHanLun 阅读 33 收藏 0 点赞 0 评论 0
/**
 * 晃动动画
 *
 * @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;
}
ClearWriteEditText.java 文件源码 项目:sealtalk-android-master 阅读 28 收藏 0 点赞 0 评论 0
/**
 * 晃动动画
 * @param counts 半秒钟晃动多少下
 * @return
 */
public static Animation shakeAnimation(int counts) {
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(500);
    return translateAnimation;
}
ViewAnimCreator.java 文件源码 项目:android-project-gallery 阅读 32 收藏 0 点赞 0 评论 0
/**
 * 抖动动画
 * 
 * @param count 次数
 * @return
 */
public static Animation shakeAnimation(int count)
{
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(count));
    translateAnimation.setDuration(600);

    return translateAnimation;
}
ClearEditText.java 文件源码 项目:GCSApp 阅读 32 收藏 0 点赞 0 评论 0
/**
 * 晃动动画
 *
 * @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;
}
ClearWriteEditText.java 文件源码 项目:rongyunDemo 阅读 33 收藏 0 点赞 0 评论 0
/**
 * 晃动动画
 * @param counts 半秒钟晃动多少下
 * @return
 */
public static Animation shakeAnimation(int counts) {
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(500);
    return translateAnimation;
}
SearchEditText.java 文件源码 项目:sctalk 阅读 28 收藏 0 点赞 0 评论 0
/**
 * 晃动动画
 * @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;
}
ClearEditText.java 文件源码 项目:CloudPan 阅读 37 收藏 0 点赞 0 评论 0
/**
 * �����
 * @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;
}
ClearWriteEditText.java 文件源码 项目:RongCloudJcenter 阅读 27 收藏 0 点赞 0 评论 0
/**
 * 晃动动画
 * @param counts 半秒钟晃动多少下
 * @return
 */
public static Animation shakeAnimation(int counts) {
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(500);
    return translateAnimation;
}
SplashActivity.java 文件源码 项目:LittleFreshWeather 阅读 36 收藏 0 点赞 0 评论 0
private void startAnimation() {
    ObjectAnimator animator = ObjectAnimator.ofFloat(ivSplashIcon, "translationY", 0, -(ivSplashIcon.getHeight() >> 1));
    animator.setDuration(800);
    animator.setRepeatCount(ObjectAnimator.INFINITE);
    animator.setRepeatMode(ObjectAnimator.RESTART);
    animator.setInterpolator(new CycleInterpolator(0.5f));
    animator.start();
}
ClearEditText.java 文件源码 项目:Android-Application-ZJB 阅读 36 收藏 0 点赞 0 评论 0
/**
 * 晃动动画
 *
 * @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;
}
DialogPopup.java 文件源码 项目:BasePopup 阅读 29 收藏 0 点赞 0 评论 0
@Override
protected Animation initShowAnimation() {
    AnimationSet set=new AnimationSet(false);
    Animation shakeAnima=new RotateAnimation(0,15,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
    shakeAnima.setInterpolator(new CycleInterpolator(5));
    shakeAnima.setDuration(400);
    set.addAnimation(getDefaultAlphaAnimation());
    set.addAnimation(shakeAnima);
    return set;
}
ClearEditText.java 文件源码 项目:yun2win-sdk-android 阅读 29 收藏 0 点赞 0 评论 0
/**
 * 晃动动画
 * @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;
}
AlipayFailureView.java 文件源码 项目:AndroidAnimationExercise 阅读 35 收藏 0 点赞 0 评论 0
private void failureAnim() {
    float currentX = this.getTranslationX();
    ObjectAnimator tansXAnim = ObjectAnimator.ofFloat(this, "translationX",currentX+20);
    tansXAnim.setDuration(1000);
    tansXAnim.setInterpolator(new CycleInterpolator(3));
    tansXAnim.start();
}


问题


面经


文章

微信
公众号

扫码关注公众号