$ show airbnb/epoxy
Epoxy is an Android library for building complex RecyclerView adapters through a model-driven approach. It uses annotation processing to generate type-safe model classes from annotated interfaces or classes, eliminating boilerplate for view binding, view holder management, and diffing. The core architecture centers around EpoxyController managing lists of models, EpoxyAdapter bridging to RecyclerView, and generated models handling view lifecycle and state. Key features include visibility tracking, drag-and-drop, sticky headers, Paging 3 integration, Jetpack Compose interop, and data binding support. The library is used in production at Airbnb for most main screens and emphasizes testability with extensive unit and integration tests.
The LLM identified 5 files worth highlighting for reuse:
Main annotation processor supporting both KAPT and KSP backends. Generates model classes, builder interfaces, and related code from @ModelView and @EpoxyModelClass annotations. Demonstrates non-obvious skill in handling dual processing environments, memoization, inheritance, and complex code generation logic while maintaining backward compatibility.
Central component managing model lists, building views, and handling binding lifecycle. Implements efficient diffing with payload support to minimize RecyclerView updates. Demonstrates clean abstraction of model-view separation, view state restoration, and asynchronous model building. Highly reusable as a drop-in replacement for RecyclerView.Adapter with minimal coupling to Android framework internals.
Enables binding Epoxy models to standalone views outside RecyclerView with lifecycle awareness. Uses EpoxyStub for placeholder views and handles view recycling. Demonstrates reusable pattern for decoupling model binding from RecyclerView, useful for dialogs, headers, or complex views. Self-contained with minimal dependencies on epoxy-adapter core.
Integrates Epoxy with Paging 3 by caching models to avoid rebuilding during paging updates. Solves the complex problem of efficient model management in paged lists through thread-safe caching, diffutil integration, and proper main thread execution. Demonstrates non-obvious skill in bridging two complex libraries while maintaining performance and correctness.
Defines the annotation for model attributes with options for nullability, default values, code generation, and listener handling. Cornerstone of annotation-driven model generation showing careful design for flexibility, type safety, and extensibility. Demonstrates non-obvious skill in balancing usability with powerful code generation capabilities.