Image for post
Image for post

One of the projects I was working on recently, which was among the first activity recording apps, had a very complex screen with a lot of user interaction and data (referred to as Workout Summary Screen from now on). Naturally, as you’d expect, it had legacy code and tech, which was a blocker for extending it with new features. A decision was made to rewrite this screen so that it can be easily extended with new features and also get rid of weird bugs.

In this article, I’ll go through how I rewrote it, the technology and architecture I picked for the task and why. …


Image for post
Image for post
Photo by Adam Śmigielski on Unsplash

Epoxy, an Android library developed by Airbnb, is a widely known and used library for building complex screens in a RecyclerView.

It has built-in support for async diffing (using DiffUtil) and promotes immutability while enforcing best practices when working with RecyclerView.

In this article, I’m going to show you how you could build a list with expandable items, a.k.a. accordion, using Epoxy — assuming you’re already familiar with the library.

We’re going to build a list of video game titles grouped into genres.

Preparing the Models

Epoxy provides various ways to generate the Epoxy models. The code in this article is written in Kotlin and since I’m fond of Data Binding, I will use Epoxy with Data Binding model generation from XML layouts. Each layout is prefixed with viewholder_ and I have the following configuration in package-info.java: …


Image for post
Image for post

Updated Dagger integration to recommend using Dagger Hilt: Dependency Injection, which greatly simplifies dependency injection in ViewModels.

Updated to Lifecycle ViewModel SavedState version 2.2.0.
Check out my sample Github repository for a complete working example of everything I discuss here.

Saved State module for ViewModel is a new library from Google that builds on top of ViewModel architecture component. It let's you restore the UI state after a process stop.

In this article, I'm going to walk you through the basic usage of this library and continue deeper into a more advanced use case of integrating it with Dagger:

About

Nimrod Dayan

Software Engineer specialized in Android (https://bit.ly/nimroddayan)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store