sparrow007 / CarouselRecyclerview

Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.
Apache License 2.0
640 stars 79 forks source link

java.lang.ArithmeticException: divide by zero #45

Open snailmail123 opened 1 year ago

snailmail123 commented 1 year ago

Always getting this error when have 1 item in recycler, remove that item, and call adapter.notifyDataSetChanged()

java.lang.ArithmeticException: divide by zero
        at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.onSelectedCallback(CarouselLayoutManager.kt:641)
        at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.access$onSelectedCallback(CarouselLayoutManager.kt:17)
        at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager$startScroll$2.onAnimationEnd(CarouselLayoutManager.kt:473)
        at android.animation.Animator$AnimatorListener.onAnimationEnd(Animator.java:554)
        at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1253)
        at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1495)
        at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
        at android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
        at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:970)
        at android.view.Choreographer.doCallbacks(Choreographer.java:796)
        at android.view.Choreographer.doFrame(Choreographer.java:727)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7651)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)