在onAnimationEnd中重复时,AnimatorSet堆栈溢出

时间:2018-06-28 07:54:31

标签: android animation

对于循环动画,此代码在我的机器上效果很好:

    final AnimatorSet bounce = new AnimatorSet();
    final Animator animation1 = ObjectAnimator.ofFloat(im, View.SCALE_X, 1, 1.3f).setDuration(1000);
    final Animator animation2 = ObjectAnimator.ofFloat(im, View.SCALE_X, 1.3f, 1).setDuration(1000);
    final Animator animation3 = ObjectAnimator.ofFloat(im, View.SCALE_X, 1, 1).setDuration(300);   

    bounce.playSequentially( animation1, animation2,animation3);
    bounce.start();
    bounce.addListener(new AnimatorListenerAdapter() {
        @Override public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (appvisible) { bounce.start(); }
        }
    });

但是,在Google Developer Console上,我反复遇到一个堆栈溢出错误,我不明白,因为每个人都建议在动画循环中调用“ start”是为了动画循环,它在我的手机上正常工作。我唯一的想法是,整个问题可能是某些极端情况,即某些人想要取消动画,并与结束动画发生冲突!?

java.lang.StackOverflowError:
at android.util.ArrayMap.indexOf (ArrayMap.java:97)
at android.util.ArrayMap.indexOfKey (ArrayMap.java:343)
at android.util.ArrayMap.get (ArrayMap.java:385)
at android.animation.AnimatorSet.onChildAnimatorEnded (A imatorSet.java:798)
at android.animation.AnimatorSet.-wrap1 (AnimatorSet.java)
at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd (AnimatorSet.java:784)
at android.animation.ValueAnimator.endAnimation (ValueAnimator.java:1153)
at android.animation.ValueAnimator.cancel (ValueAnimator.java:1043)
at android.animation.ObjectAnimator.animateValue (ObjectAnimator.java:983)
at android.animation.ValueAnimator.setCurrentFraction (ValueAnimator.java:615)
at android.animation.ValueAnimator.start (ValueAnimator.java:1007)
at android.animation.ValueAnimator.start (ValueAnimator.java:1014)
at android.animation.ObjectAnimator.start (ObjectAnimator.java:852)
at android.animation.AnimatorSet.start (AnimatorSet.java:678)
at android.animation.AnimatorSet.onChildAnimatorEnded (AnimatorSet.java:807)
at android.animation.AnimatorSet.start (AnimatorSet.java:640)
at my.package.name.Shop$1.onAnimationEnd (Shop.java:93)
at android.animation.AnimatorSet.onChildAnimatorEnded (AnimatorSet.java:830)
at android.animation.AnimatorSet.-wrap1 (AnimatorSet.java)
at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd (AnimatorSet.java:784)
at android.animation.ValueAnimator.endAnimation (ValueAnimator.java:1153)
at android.animation.ValueAnimator.cancel (ValueAnimator.java:1043)
at android.animation.ObjectAnimator.animateValue (ObjectAnimator.java:983)
at android.animation.ValueAnimator.setCurrentFraction (ValueAnimator.java:615)

at android.animation.ValueAnimator.start (ValueAnimator.java:1007)
at android.animation.ValueAnimator.start (ValueAnimator.java:1014)
at android.animation.ObjectAnimator.start (ObjectAnimator.java:852)
at android.animation.AnimatorSet.start (AnimatorSet.java:678)
at android.animation.AnimatorSet.onChildAnimatorEnded (AnimatorSet.java:807)
at android.animation.AnimatorSet.-wrap1 (AnimatorSet.java)
at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd (AnimatorSet.java:784)
at android.animation.ValueAnimator.endAnimation (ValueAnimator.java:1153)
at android.animation.ValueAnimator.cancel (ValueAnimator.java:1043)
at android.animation.ObjectAnimator.animateValue (ObjectAnimator.java:983)
at android.animation.ValueAnimator.setCurrentFraction (ValueAnimator.java:615)
at android.animation.ValueAnimator.start (ValueAnimator.java:1007)
at android.animation.ValueAnimator.start (ValueAnimator.java:1014)
at android.animation.ObjectAnimator.start (ObjectAnimator.java:852)
at android.animation.AnimatorSet.start (AnimatorSet.java:678)
at android.animation.AnimatorSet.onChildAnimatorEnded (AnimatorSet.java:807)
at android.animation.AnimatorSet.-wrap1 (AnimatorSet.java)
at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd (AnimatorSet.java:784)
at android.animation.ValueAnimator.endAnimation (ValueAnimator.java:1153)
at android.animation.ValueAnimator.cancel (ValueAnimator.java:1043)
at android.animation.ObjectAnimator.animateValue (ObjectAnimator.java:983)
at android.animation.ValueAnimator.setCurrentFraction (ValueAnimator.java:615)
at android.animation.ValueAnimator.start 
(...)

0 个答案:

没有答案