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

Android Architecture

Richa
August 13, 2016

Android Architecture

Android Architecture talk presented at 360Andev

Richa

August 13, 2016
Tweet

More Decks by Richa

Other Decks in Technology

Transcript

  1. ▪ Challenges ▪ Finding the right architecture fit ▪ Validation

    ▪ Practice makes perfect! ▪ Demo and Samples ▪ Cons ▪ Key Takeaways Structure of the talk
  2. Available on Google Play Store Place your screenshot here Android

    App 1,825+ COURSES 18M+ LEARNERS 141+ PARTNERS
  3. 109% increase in mobile usage since last year 24 %

    use mobile only 40 % use mobile and desktop
  4. MVC

  5. MODEL VIEW CONTROLLER Manage application data Render model Handle view

    events Interact with model Invoke next UI Table of Responsibilities
  6. MODEL VIEW CONTROLLER Manage data from network Render model Handle

    view events Manage data from local storage Manage view state Interact with model Manage model consistency Navigation Interact with system components Interact with system events Update view on model changes or system events
  7. Model public class CourseModel { Course getFromDatabase() { // fetch

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

    void onLocationUpdated(Location loc) {} void takePhoto(Activity context) {} void launchView(Activity context ) {}
  9. MODEL VIEW CONTROLLER Manage data from local storage Render model

    Handle view events Manage data from network Manage view state Interact with model Manage model consistency Navigation Interact with system components Interact with system events Update view on model changes or system events
  10. MODEL VIEW CONTROLLER INTERACTOR Manage data from local storage Render

    view data Handle view events Interact with external entities Manage data from network Manage view data/ updates Navigation Manage model consistency Forward view data updates to view
  11. MODEL VIEW CONTROLLER INTERACTOR VIEW MODEL Manage data from local

    storage Render view model Handle view events Interact with external entities Manage view data Manage data from network Navigation Manage model consistency Manage view model
  12. MODEL VIEW PRESENTER INTERACTOR VIEW MODEL Manage data from local

    storage Render view model Handle view events Interact with external entities Manage view data Manage data from network Navigation Manage model consistency Manage view model
  13. ENTITIES VIEW PRESENTER INTERACTOR VIEW MODEL Represent model objects Render

    view model Handle view events Interact with external entities Manage view data Navigation Manage view model
  14. ENTITIES VIEW PRESENTER INTERACTOR VIEW MODEL FLOW CONTROLLER Represent model

    objects Render view model Manage view events and view model Interact with external entities Manage view data Navigation
  15. @AutoValue @AutoParcel https://github.com/google/auto V2 - and beyond ▪ Good developers

    write code, great developers generate! ▪ When code is generated, why write tests? ▪ Use code generation and annotation processing heavily. ▹ Custom annotation processors - Data source policies, Routing, Model, Event Tracking generation. https://github.com/rharter/auto-value-gson
  16. V2 - and beyond ▪ Data Source layer can evolve

    separately from the rest of the application. ▪ Load all data on critical path. ▪ Leverage common interfaces like `onLoad` in the Presenters to prefetch data on critical path of user experience.
  17. CatalogInteractor Context mContext; public CatalogInteractor(Context context) { mContext = context;

    } public Observable loadCatalog() { return catalogDataSource.loadCatalog(mContext.getApplication( )); }
  18. Dealing with context Presenter(Context context) Interactor(Context context) NetworkClient(Context context) PersistenceClient(Context

    context) context.getSystemService(“SERVICE”) context.startActivity(intent) context.startActivityForResult(intent)
  19. References ▪ Android dialogs - https://www.youtube.com/watch?v=VTaguVtvuYI ▪ https://github.com/square/okhttp ▪ https://github.com/square/retrofit

    ▪ http://google.github.io/dagger/ ▪ https://github.com/ReactiveX/RxAndroid ▪ http://360andev.com/sessions/100-libraries-i-wish-i-knew-about-when-i- started/ ▪http://360andev.com/sessions/100-eliminateboilerplate/ ▪ https://github.com/googlesamples/android-architecture ▪ http://360andev.com/sessions/100-intro-to-rxjava/