Android MVP - Tuong-Nguyen/PreparationEduLog GitHub Wiki

MVP pattern

MVP is Model - View - Presenter.

MVP

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

MVP in Android

MVP pattern is applied for Presentation layer in Android app

View

It is a View Surface (interface) that abstracts away the implementation of the UI logic, and is typically implemented by a View, Activity or Fragment

Responsibilities

  • Screen layout
  • Animations/transition
  • Propagate UI event to Presenter
  • Navigation

Presenter

Implements presentation logic by directing UI changes and handling user input

Responsibilities

  • Direct UI changes
  • Handle user triggered UI events
  • Create and trigger Use Case objects (interactors in Domain layer)
  • Define a View Surface

Whatever

Whatever

Read more: