MVP: The Life-Changing Magic of Tidying Up Your Android Presentation Layer
summary
Claim: converting a messy Android activity to MVP makes presentation logic testable and smaller. Steps: split into Model View Presenter and a lifecycle class, inject dependencies via a factory, keep the presenter a POJO with no Android classes, mock collaborators and run JUnit + Mockito unit tests on the JVM. Real result at RunKeeper: a trip list activity shrinks 747 to 132 lines and methods drop 27 to 12. Examples include a delete-trip flow and pull-to-refresh where presenter commands the view and mocked web client avoids real network calls.
AI-written summary · about
chapters (26)
- 0:00Start
- 5:07Overview
- 8:23Normal Java Code
- 8:48Normal Unit Testing
- 9:02Android Unit Testing
- 10:56Trip List Activity (BEFORE)
- 11:19Separation of Concerns
- 12:17Model View Presenter
- 19:35Runkeeper Architecture
- 20:45Split up the Activity
- 21:47Activity-Presenter Relationship
- 22:09Presenter-View Relationship
- 22:41Trip List Activity (AFTER)
- 23:36Key Takeaway
- 24:27Lifecycle to Presenter
- 24:52View to Presenter
- 27:09Dependency Injection
- 28:34Presenter Factory
- 30:00Unit Testing Tools
- 30:15Mock Dependencies
- 30:39Inject Dependencies
- 31:14Example: Delete a Trip
- 32:52Example: Swipe to Refresh
- 34:23Write Tests
- 35:10How to Refactor to MVP
- 36:17Pros and cons
related talks
35mBuilding better Android apps with MVP
42mTestable Android Architecture
30mArchitecting an app with MVP and ViewModels
56mMVP — Common Tasks and Ways to Solve Them in Moxy
39mClean app design with Architecture Components
34mMVWTF: Demystifying Architecture Patterns
27mHalf Way to clean architecture
28mHands-on Android Architecture & Architecture Components
