We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

An alternative to fragments: Say Hello to Mortar & Flow

Formal Metadata

Title
An alternative to fragments: Say Hello to Mortar & Flow
Title of Series
Number of Parts
46
Author
License
CC Attribution 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
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.