Current location - Health Preservation Learning Network - Healthy weight loss - How to realize the MVP framework of Android step by step
How to realize the MVP framework of Android step by step
Implement Android MVP framework

Code structure of a classic Android MVC framework project

MVP lightens the burden of activities and undertakes the work of view layer and controller layer.

ActivityActivity of view layer includes: main view, external interface of view layer and Presenter of P layer.

Main view file of external interface

P-layer code

document

DataManager.java

TaskDataSource.java

TaskDataSourceImpl.java?

TaskDataSourceTestImpl.java?

Android version scheme

IO reads and writes data through the newly created child thread.

Return the result to the main thread and render the display with the Looper of the main thread.