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

Basics of Android MVP

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

Basics of Android MVP

Avatar for Dinkar Kumar

Dinkar Kumar

May 29, 2018

Other Decks in Technology

Transcript

  1. Copyright ©2016 Talentica Software (I) Pvt Ltd. All rights reserved.

    C2M - Mobile App Architecture Android & iOS - Dinkar Kumar - Suyash Gupta
  2. Copyright © 2016 Talentica Software (I) Pvt Ltd. All rights

    reserved. Copyright ©2016 Talentica Software (I) Pvt Ltd. All rights reserved. 2 Agenda • Basics of MVP • Responsibilities of each layer • Implementing MVP in android apps • Demo • How it addresses separation of concerns and testability
  3. Copyright © 2016 Talentica Software (I) Pvt Ltd. All rights

    reserved. Copyright ©2016 Talentica Software (I) Pvt Ltd. All rights reserved. 3 Why any architectural pattern • Modular • Testable • Maintainable • Separation of concern • Documentable
  4. Copyright © 2016 Talentica Software (I) Pvt Ltd. All rights

    reserved. Copyright ©2016 Talentica Software (I) Pvt Ltd. All rights reserved. 4 MVP • Model: It is responsible for handling the data part of the application. • View: It is responsible for laying out the views with specific data on the screen. • Presenter: It is a bridge that connects a Model and a View. It also acts as an instructor to the View.
  5. Copyright © 2016 Talentica Software (I) Pvt Ltd. All rights

    reserved. Copyright ©2016 Talentica Software (I) Pvt Ltd. All rights reserved. 5
  6. Copyright © 2016 Talentica Software (I) Pvt Ltd. All rights

    reserved. Copyright ©2016 Talentica Software (I) Pvt Ltd. All rights reserved. 6 MVP - Model • Data provider • Network call • DB fetch • Shared Preferences
  7. Copyright © 2016 Talentica Software (I) Pvt Ltd. All rights

    reserved. Copyright ©2016 Talentica Software (I) Pvt Ltd. All rights reserved. 7 MVP - View • Activity • Fragment • Custom View
  8. Copyright © 2016 Talentica Software (I) Pvt Ltd. All rights

    reserved. Copyright ©2016 Talentica Software (I) Pvt Ltd. All rights reserved. 8 MVP – View Responsibility • Permissions • Event listeners • Showing dialogs, Toasts, Snackbars • Working with Android View and Widget • Starting activities • All functionality which is related to the Android Context
  9. Copyright © 2016 Talentica Software (I) Pvt Ltd. All rights

    reserved. Copyright ©2016 Talentica Software (I) Pvt Ltd. All rights reserved. 9 MVP - Presenter • Act as instructor • Retrieves data from the Model • Returns Formatted data to View • Should not have Android SDK dependency
  10. Copyright © 2016 Talentica Software (I) Pvt Ltd. All rights

    reserved. Copyright ©2016 Talentica Software (I) Pvt Ltd. All rights reserved. 10 Demo
  11. Copyright © 2016 Talentica Software (I) Pvt Ltd. All rights

    reserved. Copyright ©2016 Talentica Software (I) Pvt Ltd. All rights reserved. 11 MVP : Testability • MVP make the code more testable by making it more decoupled • We can easily mock model to validate UI rendering for different response
  12. Copyright © 2016 Talentica Software (I) Pvt Ltd. All rights

    reserved. Copyright ©2016 Talentica Software (I) Pvt Ltd. All rights reserved. 12