Name Explain Sample
MVP Using the MVP
MVP+Dagger MVP + Dagger MVP+Dagger: Implement a data source return

MVP+Dagger: Return two data sources using the base class list page

List page List page usage
The network status Network Status Notification

V layer handles UI view operations; The P layer implements business logic operations (the core business can even be written into a core P when design needs to be done); M layer is data warehouse, background management data source and data control, data is from the network, database, SP, cache, example: You might need such an implementation, a list of data that does not need to be real time, but you need to have a problem to the network situation of users to improve the user experience, you need to use the network data + local cache mechanism, then, can be unified in the data warehouse as processing, code logic level is very clear, you should be like this design.

The call method between V-P adopts the principle of dependency inversion, as the saying is to use abstract interface (callback); P and V, write too much code, in fact, you will find that V can normally call P, P should be called as little as possible V, or use DataBinding, data changes using binding mode; P communicates with M, and M only communicates with P. The data generally comes from background delayed operation, which is where RxJava is commonly used. Network requests can try ReTrofit. Under normal circumstances, a V corresponds to a P, while P and M will have a P corresponding to multiple M (M may be created as a module if there are many interfaces in M).

Dagger+MVP, which realizes that P and M objects are created using Dagger injection mode in MVP structure code.

Gradle

allprojects { repositories { jcenter() maven { url "https://jitpack.io" } } } android { dataBinding { enabled = true } }  dependencies { compile 'com.better.android:appbase:x.y.z' }Copy the code

gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zipCopy the code

The attached

Thank you