ANDROID MVP
Jeff Potter
@jpotts18
github.com/jpotts18
MOTIVATION
• Activities with millions of callbacks. God objects.
• Single Responsibility Principle
• https://github.com/antoniolg/androidmvp
• http://en.wikipedia.org/wiki/
Single_responsibility_principle
MVP RESPONSIBILITIES
• The model defines the data to be displayed or
acted upon.
• The view is a passive interface that displays data
and routes user events.
• The presenter retrieves data from the model,
and notifies the view to display it.
MVP
ModelPresenterView
User Events
MVP
ModelPresenterView
User Events Update Model
MVP
ModelPresenterView
User Events Update Model
State Changed Event
MVP
ModelPresenterView
User Events Update Model
UpdateViews State Changed Event
LOGIN MVP
Network

Interactor
PresenterActivity
loginTapped
LOGIN MVP
Network

Interactor
PresenterActivity
loginTapped attemptLogin()
LOGIN MVP
Network

Interactor
PresenterActivity
loginTapped attemptLogin()
networkFailure()
networkSuccess()
LOGIN MVP
Network

Interactor
PresenterActivity
loginTapped attemptLogin()
networkFailure()
networkSuccess()
loginFailure()
loginSuccess()
LET’STRY IT!
$ git clone git@github.com:jpotts18/android-mvp.git
GOAL
• Demonstrate MVP
• Switch out Model without affecting theView
• Switch out theView without affecting the Model

Android Architecture MVP Pattern