Comments (4)
@samardzija I am also facing this issue please share the resolution if you find one
from scrollingpagerindicator.
@nikhilwynk The problem is that viewpager current position has been remembered. That's why a crash occurs.
I've added a listener to the adapter, to notify me when adapter data is changed and in that case, I set viewPager current position to 0.
So, first extend constructor for adapter and add listener:
ViewPagerAdapter(val onDataChange: Runnable)
Then, when listener triggers, set:
yourViewPager.currentItem = 0
from scrollingpagerindicator.
@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.
from scrollingpagerindicator.
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:
- adapter size is bigger than one, swipe to the second position, or third position, whatever
- trigger adapter change so that it will have only one element
- view pager remembers that it should be in the second position and when data is changed, it crashes.
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.
Maybe is something happening with the data, try to set don't keep activity in Settings.
Anyway, I don't think library should crash at this moment, anyway. It should just ignore.
if (position != 0 && (position < 0 || position >= itemCount)) {
throw new IndexOutOfBoundsException("Position must be [0, adapter.getItemCount()]");
}
if (itemCount == 0) {
return;
}
adjustFramePosition(0, position);
updateScaleInIdleState(position);
}
this is the method that crash. Maybe, if (itemCount == 0) should be before throwing exception.
from scrollingpagerindicator.
Related Issues (20)
- Indicator Dot moving animation
- Stopping dot moving animation when recycler reverse is true HOT 1
- how to indicator dot is vertical HOT 2
- dot indicator is not selected in first time HOT 1
- Attach to ViewPager2 HOT 3
- Set faded dots count? HOT 1
- dataSetObserver in ViewPager2Attacher.java is not properly refreshing
- how rtl scrollinindicator? HOT 3
- the last dot in indicator not getting selected when last item of recyclerview is reached by scrolling
- How to create Circle indicator with different stroke and fill color.
- Incorrect direction with recyclerview with reverseLayout
- ViewPager2.registerOnPageChangeCallback()
- Usage in project with embedded RecyclerView HOT 1
- How to use it inside the layout of recycler view item or viewpager?
- Not working with androidX.recyclerView?
- First dot was truncated on some devices HOT 2
- First dot is not selected on some devices.
- Attach Indicator on bottom of ViewPager2
- Import error while attaching to ViewPager2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scrollingpagerindicator.