Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Effective Android Architecture - MWDC

Effective Android Architecture - MWDC

Yet another talk on Android architecture at MWDC 2015

Richa

July 16, 2015
Tweet

More Decks by Richa

Other Decks in Programming

Transcript

  1. MVC

  2. MODEL VIEW CONTROLLER Interact with DB Render Model Handle view

    events Update model Invoke next UI Table of Responsibilities
  3. MODEL VIEW CONTROLLER Interact with DB Render Model Handle view

    events Interact with network Manage view state Update model Navigation Interact with system components Handle system events Update view on system events
  4. Model public class CourseModel { Course getFromDatabase() { // fetch

    from db, or local cache } Course getFromNetwork() { // fetch from apis, cache when possible } }
  5. Controller void onClick() {} void onModelUpdated() {} void onNewNotification() {}

    void onLocationUpdated(Location loc) {} void takePhoto(Activity context) {} void launchView(Activity context ) {}
  6. MODEL VIEW CONTROLLER Interact with DB Render Model Handle view

    events Interact with network Manage view state Update model Navigation Interact with system components Handle system events Update view on system events
  7. MODEL VIEW CONTROLLER INTERACTOR Retrieve data from DB Render Model

    Handle view events Interact with external entities Retrieve data from network Manage view state Navigation Forward system events to view Forward model updates to view
  8. MODEL VIEW CONTROLLER INTERACTOR VIEW MODEL Retrieve data from Network

    Render View Model Handle view events Interact with external entities View state / behavior Retrieve data from network Navigation Update view state
  9. MODEL VIEW PRESENTER INTERACTOR VIEW MODEL Retrieve data from DB

    Render View Model Handle view events Interact with external entities View state / behavior Retrieve data from network Navigation Update view state
  10. ENTITIES VIEW PRESENTER INTERACTOR VIEW MODEL Get data from Data

    Sources Render View Model Handle view events Interact with external entities View state / behavior Navigation Update view state
  11. ENTITIES VIEW PRESENTER INTERACTOR VIEW MODEL FLOW CONTROLLER Get data

    from Data Sources Render View Model Handle view events Update view state Interact with external entities View state / behavior Navigation
  12. S ingle Responsibility Principle O pen/Closed Principle L iskov Substitution

    Principle I nterface Segregation Principle D ependency Inversion Principle
  13. Activity Video Module Activity Quiz Module Navigation Main Activity Shell

    App Catalog Activity Catalog Module url Intent Intent Register with url Modules
  14. Deep links Shell App Video Activity Video Module Catalog Activity

    Catalog Module register register url Intent Intent
  15. Dealing with context Presenter(Context context) Interactor(Context context) NetworkClient(Context context) PersistenceClient(Context

    context) context.getSystemService(“SERVICE”) context.startActivity(intent) context.startActivityForResult(intent)
  16. CatalogViewModel public final BehaviorSubject<Catalog> catalog = BehaviorSubject.create(); public void subscribeToCatalog(Action1

    action) { catalog.subscribe(action); } public void unsubscribeToCatalog() { catalog.unsubscribe(); }
  17. CatalogInteractor Context mContext; public CatalogInteractor(Context context) { mContext = context;

    } public Observable loadCatalog() { return catalogDataSource.loadCatalog(); }