-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace ViewPager with RecyclerView + SnapHandler #150
Comments
Another option would be to migrate to viewpager2 from androidx. That would replace the current viewpager and a bunch of extra code supporting RTL. It wouldn't replace fragments though. |
@ErikHellman @aferditamuriqi I started a very basic replacement of the custom ViewPager (R2RTLViewPager and R2ViewPager) with ViewPager2. https://github.com/stevenzeck/r2-navigator-kotlin/tree/viewpager2 and https://github.com/stevenzeck/r2-testapp-kotlin/tree/viewpager2. I'm still trying to understand the architecture here with submodules, but it "works", as in pages load and I can go from page to page. I'm not sure if RTL works however, as I don't know how to test that. And a couple of parts I'm unsure of that I just commented out. Something worth pursuing or go with another approach? |
@stevenzeck This is great, thank you, I will definitely take a look into your solution with the viewpager2 as I have planned to replace the current custom implementation with it as well. I will test your solution and give you some feedback. I am sure we can tweak what we need to replace the custom implementation. |
Things to note/do:
|
@aferditamuriqi was there something special you had to do so that viewpager goes to the next page instead of the next chapter/fragment? With viewpager2 the way it is now, swiping goes between each fragment instead of pages and can't figure out why the original viewpager doesn't do the same. Edit: So R2WebView onTouchEvent is receiving ACTION_DOWN, ACTION_MOVE and ACTION_CANCEL. ACTION_UP isn't registering. Is there a better way to break down the chapters into pages so that the ViewPager changes pages and doesn't rely on scrolling via onTouchEvent? |
We can follow-up in this thread: #51 (reply in thread) |
The ViewPager solution currently used relies on fragments, which makes the navigator component a bit heavy on fragment use. A better approach would be to use a RecyclerView with a SnapHandler. This would also make the nested scrolling happening today much simpler, as RecyclerView supports this in a better way.
The text was updated successfully, but these errors were encountered: