android - ViewPager (cwac-pager) pages with non-unique tags not initialized properly -
I have encountered a problem with cwac-pager, and I can reproduce the problems in the Pasadamo demo project I am
Steps to reproduce this problem:
- Run the pajadasmo project (it starts 10
EditorFragment pages) < / li>
- Delete pages 2-8 (press NAV on editorial and editor # 9 and delete until deleted)
- You now have 3 pieces: Editor # 1, Editor # Swipe left to navigate back to 9 and editor # 10 editor # 1
- Press + + to add pages, it starts by adding editor # 4 (obviously because we had 3 pages after the removal). Add pages until you add Editor # 10 (visible on the left side of the current page).
- Swipe to the right for editor # 9 does not load the view (there is no text to edit) Editor # 10 (on the right) is the same on the left side of editor # 1 New Editor # 9 or Editor # 10, swipe to the left, and those views are loaded properly.
If you type in the arrayappler adapter in
entries , you will see that the correct code in it is
PageDescriptor s, but
PageDiscriptor s has the same tag, like "edit 9" and "edit 10" appear twice, it seems that these do not load the
PageDescriptor s.
The code in the demo project (and so on in my project) just adds a string to create the tag and the position of the piece is going up:
private string Build tag (return status) {return ("editor" + string.whouf (status)); }
As an alternative solution, I have modified the
buildTag to create a random tag:
private string build tag (Int position) {return ("page" + UUID.randomUUID (.) ToString ()); }
I'm not sure if this solution can have unexpected negative consequences?
You are right that this is a bug in the demo app, and
ArrayPagerAdapter Here, some defenders can recognize this case using the programming and can increase the exception. I will work on both fixing.
PageDescriptor requires a unique tag, and my current demo app algorithm will not guarantee that, as you found I have filed for it.
From the upper part of my head, a UUID should be fine, although perhaps I will only use a mononautically increasing integer counter.
Thanks for the pointing out this!
Comments
Post a Comment