Airbnb Eli Hart Dec 1, 2016

Epoxy: Airbnb's View Architecture on Android

Article Summary

Eli Hart from Airbnb reveals how they eliminated RecyclerView boilerplate while building complex screens with 8+ view types. Their solution handles diffing, animations, and state management automatically.

Airbnb open-sourced Epoxy, their Android view architecture library that simplifies building complex RecyclerView-based UIs. The library takes a React-inspired compositional approach where developers describe what to show, and Epoxy handles the rendering details including automatic diffing and animations.

Key Takeaways

Critical Insight

Epoxy reduces RecyclerView complexity by letting developers declare what to show while the library handles diffing, animations, and state management automatically.

The article reveals how Airbnb uses Epoxy to make their listing details page load faster than a ScrollView implementation would allow.

About This Article

Problem

Airbnb's search results page needed to display eight different view types in a single scrollable RecyclerView. Headers, carousels, loaders, error messages, and disclaimers all had to coexist, which made the adapter code complex and required manual change tracking.

Solution

Eli Hart's team used Epoxy's annotation processor to automatically generate hashCode methods from @EpoxyAttribute fields. This enabled a diffing algorithm that could detect model changes without requiring manual notify calls.

Impact

The listing details page loaded faster and had smoother shared element transitions. RecyclerView virtualization meant only visible portions of the view hierarchy were rendered, which reduced layout passes and memory usage when the page first loaded.