An Alternative To Fragments - Say Hello To Mortar + Flow

Architecture
Talk
Intermediate
English
06/05/2015 - 11:30 to 12:10
Stage 1

Session abstract: 

The introduction of fragments made it possible to split activities into smaller, more manageable components and allowed to build responsive UIs. Further taking advantage of the FragmentManager allowed hosting all fragments within a single activity. However fragments also caused headaches; ensuring that a transition is safe, magic fragment re-creation and ensuring the correct fragment is shown after an activity is re-created to name a few.

In this talk, we will take a close look at two libraries: Mortar (with Dagger) and Flow. Leveraging these libraries allows creating well structured and cleanly separated components yielding reusable and testable user interfaces. Built as a layer on top of Dagger, Mortar provides scoped injection of components and provides lifecycle callbacks. These scoped subgraphs are only around while a screen that requires them is in scope thus keeping the memory footprint small. The separation of views and presenters fosters code that is easily testable. Flow provides the means to navigate between screens and manages the backstack. Flow can be freely extended to provide custom animations between screens since it is handling plain old views.

The takeaways from this talk are that Mortar and Flow provide an excellent alternative to Fragments and utilizing them can help you build well architected applications with responsive UIs as well as being able to easily add unit tests for the business logic in the presenters.

Event: