I am facing below issue randomly with this indicator :
Implementation :
Fragment 1 contains viewpager and dots indicator
Used timer to move next on viewpager page so the dots indicator as well
on click of button -> App navigates to Fragment 2
When click backpress from fragment 2, app crashes with below exception -
App crash exception:
java.lang.ArrayIndexOutOfBoundsException: length=10; index=-3
at java.util.ArrayList.get(ArrayList.java:439)
at com.tbuonomo.viewpagerdotsindicator.WormDotsIndicator$buildOnPageChangedListener$1.onPageScrolled$viewpagerdotsindicator_release(WormDotsIndicator.kt:164)
at com.tbuonomo.viewpagerdotsindicator.OnPageChangeListenerHelper.onPageScrolled(OnPageChangeListenerHelper.kt:22)
at com.tbuonomo.viewpagerdotsindicator.BaseDotsIndicator$setViewPager$2$addOnPageChangeListener$1.onPageScrolled(BaseDotsIndicator.kt:218)
at androidx.viewpager.widget.ViewPager.dispatchOnPageScrolled(ViewPager.java:1930)
at androidx.viewpager.widget.ViewPager.onPageScrolled(ViewPager.java:1904)
at androidx.viewpager.widget.ViewPager.pageScrolled(ViewPager.java:1842)
at androidx.viewpager.widget.ViewPager.completeScroll(ViewPager.java:1988)
at androidx.viewpager.widget.ViewPager.scrollToItem(ViewPager.java:692)
at androidx.viewpager.widget.ViewPager.onLayout(ViewPager.java:1786)
at android.view.View.layout(View.java:20865)
at android.view.ViewGroup.layout(ViewGroup.java:6215)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1873)
at android.view.View.layout(View.java:20865)
at android.view.ViewGroup.layout(ViewGroup.java:6215)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20865)
at android.view.ViewGroup.layout(ViewGroup.java:6215)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
at android.view.View.layout(View.java:20865)
at android.view.ViewGroup.layout(ViewGroup.java:6215)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20865)
at android.view.ViewGroup.layout(ViewGroup.java:6215)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
at android.view.View.layout(View.java:20865)
at android.view.ViewGroup.layout(ViewGroup.java:6215)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20865)
at android.view.ViewGroup.layout(ViewGroup.java:6215)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
at android.view.View.layout(View.java:20865)
at android.view.ViewGroup.layout(ViewGroup.java:6215)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:754)
at android.view.View.layout(View.java:20865)
at android.view.ViewGroup.layout(ViewGroup.java:6215)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3179)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2678)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1810)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8084)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1312)
at android.view.Choreographer.doCallbacks(Choreographer.java:1123)
at android.view.Choreographer.doFrame(Choreographer.java:941)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1298)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
I am facing below issue randomly with this indicator :
Implementation : Fragment 1 contains viewpager and dots indicator Used timer to move next on viewpager page so the dots indicator as well on click of button -> App navigates to Fragment 2 When click backpress from fragment 2, app crashes with below exception -
App crash exception: java.lang.ArrayIndexOutOfBoundsException: length=10; index=-3 at java.util.ArrayList.get(ArrayList.java:439) at com.tbuonomo.viewpagerdotsindicator.WormDotsIndicator$buildOnPageChangedListener$1.onPageScrolled$viewpagerdotsindicator_release(WormDotsIndicator.kt:164) at com.tbuonomo.viewpagerdotsindicator.OnPageChangeListenerHelper.onPageScrolled(OnPageChangeListenerHelper.kt:22) at com.tbuonomo.viewpagerdotsindicator.BaseDotsIndicator$setViewPager$2$addOnPageChangeListener$1.onPageScrolled(BaseDotsIndicator.kt:218) at androidx.viewpager.widget.ViewPager.dispatchOnPageScrolled(ViewPager.java:1930) at androidx.viewpager.widget.ViewPager.onPageScrolled(ViewPager.java:1904) at androidx.viewpager.widget.ViewPager.pageScrolled(ViewPager.java:1842) at androidx.viewpager.widget.ViewPager.completeScroll(ViewPager.java:1988) at androidx.viewpager.widget.ViewPager.scrollToItem(ViewPager.java:692) at androidx.viewpager.widget.ViewPager.onLayout(ViewPager.java:1786) at android.view.View.layout(View.java:20865) at android.view.ViewGroup.layout(ViewGroup.java:6215) at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1873) at android.view.View.layout(View.java:20865) at android.view.ViewGroup.layout(ViewGroup.java:6215) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:20865) at android.view.ViewGroup.layout(ViewGroup.java:6215) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083) at android.view.View.layout(View.java:20865) at android.view.ViewGroup.layout(ViewGroup.java:6215) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:20865) at android.view.ViewGroup.layout(ViewGroup.java:6215) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:20865) at android.view.ViewGroup.layout(ViewGroup.java:6215) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:20865) at android.view.ViewGroup.layout(ViewGroup.java:6215) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) at android.widget.LinearLayout.onLayout(LinearLayout.java:1565) at android.view.View.layout(View.java:20865) at android.view.ViewGroup.layout(ViewGroup.java:6215) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at com.android.internal.policy.DecorView.onLayout(DecorView.java:754) at android.view.View.layout(View.java:20865) at android.view.ViewGroup.layout(ViewGroup.java:6215) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3179) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2678) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1810) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8084) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1312) at android.view.Choreographer.doCallbacks(Choreographer.java:1123) at android.view.Choreographer.doFrame(Choreographer.java:941) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1298) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193)