I'm in the process of writing an app using Flow and Mortar. I'm having trouble figuring out how to use this when it comes to a view pager with tabs.
Only way I can think of is to treat the ViewPager screen as a single screen, and end up using Fragments to build it. But the whole point of using Flow & Mortar is to get rid of Fragments and simplify the lifecycle.
Any help is appreciated. Thanks.
I made a view pager example, up to date with Mortar and Flow versions (based on adapter from Kirill Boyarshinov).
I don't copy past the code in the answer, because it's too big and it would be less readable (if it breaks the SO rules, let me know and I'll edit the answer).
View pager adapter : https://github.com/lukaspili/Mortar-Flow-Dagger2-demo/blob/master/app/src/main/java/com/lukaspili/mortardemo/app/adapter/SlidePagerAdapter.java
Screen containing the viewpager : https://github.com/lukaspili/Mortar-Flow-Dagger2-demo/blob/master/app/src/main/java/com/lukaspili/mortardemo/ui/screen/SlidesScreen.java
Screen as page of the viewpager : https://github.com/lukaspili/Mortar-Flow-Dagger2-demo/blob/master/app/src/main/java/com/lukaspili/mortardemo/ui/screen/SlidePageScreen.java
I think PagerAdapter is what you looking for. It used to bind View directly to the ViewPager with out using fragments by overriding
instantiateItem(ViewGroup, int)
. and ViewGroup is an instance of ViewPager where you can use add method to add View to it directly.I did a code snippet with custom PagerAdapter that operates Mortar screens. You can find it here. But it is outdated with the current version of Mortar. Hope it helps :)
Have you found anything so far? I faced the same case, what I did when implementing this is that I consider every section of the viewpager as a view, not as a "screen" like used in Mortar.
I basically implemented my custom views for every section and their own presenters (custom made). That did the trick but I wish I could have used more concept from Mortar in the viewpager.