BBC Rob Pridham

How BBC Modernises a Legacy Android App Architecture: Part Three - Applying the Refactor

Original post Modernising a Legacy Android App Architecture: Part Three - Applying the Refactor

Article Summary

Rob Pridham from BBC Sport reveals how his team tackled a massive Android refactor—migrating from multiple activities to a single-activity architecture while keeping the app running in production.

This is the final installment of a three-part series documenting BBC Sport's Android app modernization. The team applied MVVM+C architecture across their legacy codebase while consolidating dozens of activities into a unified fragment hierarchy. The work spanned August to December 2020 alongside ongoing feature development.

Key Takeaways

Critical Insight

BBC Sport successfully refactored their legacy Android app to single-activity MVVM+C architecture, unlocking faster feature development despite significant WebView and navigation challenges.

Continue reading

What This Article Covers

Problem

Rob Pridham's team found that using fragment add instead of replace left hidden fragments in memory that couldn't be garbage collected. This created a cluttered view hierarchy and caused unpredictable issues when fragments stacked on top of each other.

Solution

The team switched to using fragment replace, even though it meant fragments would be recreated. They used Android ViewModel scoping to keep state alive across recreations and relied on RecyclerView's built-in scroll position restoration through the architecture components framework.

Impact

Native fragment navigation automatically restored users to their previous scroll position and ViewModel state. WebView restoration was different though. It needed manual UUID-based state caching and custom scroll position logic to avoid multi-second loading delays and visual flicker.

The team's biggest regret about the refactor wasn't technical—it was about how they communicated progress to non-engineers.

This page summarizes “Modernising a Legacy Android App Architecture: Part Three - Applying the Refactor” by BBC, published Dec 7, 2020. All credit for the original work goes to the authors.

Read the original on medium.com (opens in new tab)

AI tools for Android

Browse all AI tools →