Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Flow & Mortar with ViewPager

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.

like image 779
yasith Avatar asked Jan 17 '15 03:01

yasith


People also ask

What is flow used for?

The most common use of Flow is to trigger notifications. When a new lead is added to Microsoft Dynamics CRM, for example, an automated workflow can send sales representatives an email or text message with details about the lead. Flow can also be used to copy files.

What is flow and do I need it?

Microsoft itself defines Flow as a tool to create automated workflows between your favourite apps and services to get notifications, synchronise files, collect data and more. Microsoft Flow is available bundled in some Office 365 licenses but also on a separate subscription-basis.


2 Answers

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

like image 179
lukas Avatar answered Oct 27 '22 04:10

lukas


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.

like image 41
Muthu Avatar answered Oct 27 '22 04:10

Muthu