-
Notifications
You must be signed in to change notification settings - Fork 102
Fatal Exception: java.lang.IndexOutOfBoundsException Position must be [0, adapter.getItemCount()] #35
Comments
@samardzija I am also facing this issue please share the resolution if you find one |
@nikhilwynk The problem is that viewpager current position has been remembered. That's why a crash occurs. Then, when listener triggers, set: |
@samardzija Thanks for the inputs but I don't think this is actually what causes the crash as adapter data does not change in my case and it always remains the same. Moreover how often do you get the crash ? I am getting like 15 crashes a day out of 5.5M Daily Active users . Also can you reproduce this issue manually ? I am not able to reproduce this manually. |
Wow, that's nasty. Yes, I can reproduce it. My use case is that I have view pager with adapter attached. Adapter data is changed, based on some things that happen behind. I can reproduce it by:
It is strange that adapter data is not changing in your case, I can't think of the way how you could reproduce the issue. Anyway, I don't think library should crash at this moment, anyway. It should just ignore.
this is the method that crash. Maybe, if (itemCount == 0) should be before throwing exception. |
Hi,
I'm using ViewPager2 with ListAdapter in RecycleView. Every time data is updated, view is attached to viewPager, again. When changing adapter data, setting a new list, a crash from the title occurs.
Do you know the reason why?
Full log:
ru.tinkoff.scrollingpagerindicator.ScrollingPagerIndicator.setCurrentPosition (ScrollingPagerIndicator.java:390)
ru.tinkoff.scrollingpagerindicator.ViewPager2Attacher.updateIndicatorDotsAndPosition (ViewPager2Attacher.java:66)
ru.tinkoff.scrollingpagerindicator.ViewPager2Attacher.attachToPager (ViewPager2Attacher.java:23)
ru.tinkoff.scrollingpagerindicator.ViewPager2Attacher.attachToPager (ViewPager2Attacher.java:7)
ru.tinkoff.scrollingpagerindicator.ScrollingPagerIndicator.attachToPager (ScrollingPagerIndicator.java:297)
ru.tinkoff.scrollingpagerindicator.ScrollingPagerIndicator.attachToPager (ScrollingPagerIndicator.java:247)
The text was updated successfully, but these errors were encountered: