Android MVP


Source link: https://github.com/jpotts18/android-mvp

Android MVP

This repository demonstrates the Model View Presenter architecture and was inspired by Antonio Leiva's Android MVP. You can find an example with updated libraries in the master-2 branch from RajuSe.

Videos

Android MVP Playlist - Youtube

Getting Started

  1. Clone the Repo - git clone [email protected]:jpotts18/android-mvp.git
  2. Look at all of the branches - git branch -a
  3. Read about the branches
  4. Don't forget to checkout the master-2 it has updated libraries like RxJava, Butterknife, etc.

This repository contains a chain of branches that shows the logical progression of the Android MVP.

  • git checkout 1-login-view - demonstates a simple View which is a LoginActivity
  • git checkout 2-synchronous-login-mvp - demonstrates Login MVP implementation with a synchronous Model (or interactor).
  • git checkout 3-async-login-mvp - demonstrates Login MVP with an asynchronous Model which does not change any code in the LoginActivity
  • git checkout 4-list-activity-view - demonstates a more complex View (RepoListActivity) and an Asynchronous Networked Model which shows a users Github repositories sorted by stars.
  • git checkout 5-list-fragment - substitutes the RepoListActivity for a Fragment without changing any code in the Model.
  • The master branch contains the completed project.

What is MVP?

Model-View-Presenter is a user interface architectural pattern engineered to facilitate automated unit testing and improve the separation of concerns in presentation logic:

  • The Model is an interface defining the data to be displayed or otherwise acted upon in the user interface.
  • The View is a passive interface that displays data (the Model) and routes user commands (events) to the presenter to act upon that data.
  • The Presenter acts upon the model and the view. It retrieves data from repositories (the model), and formats it for display in the view.

Benefits

  • Loose Coupling - The Presenter is an intermediary between the View code and the Model. This allows the View and the Model to evolve independently of each other.
  • Separation of Concerns - Individual sections can be reused, as well as developed and updated independently.
  • More Testable – By isolating each major component (UI, Presenter, and Model) it is easier to write unit tests. This is especially true when using the MVP pattern which only interacts with the view using an interface.
  • Code Reuse – By using a separation of concerns/responsible design approach you will increase code reuse.
  • Flexibility - By isolating most of your code into the Presenter and Model components your code base is more flexible to change in the View.

Key differences between MVC and MVP

MVP Pattern

  • View is more loosely coupled to the model. The presenter is responsible for binding the model to the view.
  • Easier to unit test because interaction with the view is through an interface
  • Usually view to presenter map one to one. Complex views may have multi presenters.

MVC Pattern

  • Controller are based on behaviors and can be shared across views
  • Can be responsible for determining which view to display (Front Controller Pattern)

References

MVC or MVP Pattern – Whats the difference?

Model-View-Presenter - Wikipedia

Separation of Concerns - Wikipedia

Resources

Android calendar view inspired by Sunrise calendar and iOS7 stock calendar.

A customizable view that provisions picking of a date, time & recurrence option, all from a single user-interface.

Caesar is a tiny Java library that allows to create an asynchronous proxy-version of some synchronous bean. It means that you can still think in terms of your service/bean/object and use its methods instead of writing concurrency code.

This library allows you to easily create a socket bluetooth connection for multiple android devices with one server and 7 clients max.

Solid is an Android library for data handling.

It provides:

  • SolidList - an immutable, parcelable collection.
  • Lightweight and composable data streams.
  • Primitive array / wrapped array converters.
  • Data analysis algorithms.

A velocimeter View for Android.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes