Practices of using MVP Mode Programming on Android and androidmvp Mode Programming
First, who is V? Who is P? (M I think it is not a problem)
View should be the display logic. In Android development, we think that Fragment and Activity can all be used as views. Their main task is to control the display logic, which is not frequently used. View implements the business by calling the business logic of P. Businesses include synchronous businesses (which can be operated in the UI thread) and asynchronous tasks (such as network and disk IO time-consuming operations), and change the UI in response according to the results returned by P businesses.
For the implementation of Presenter, we use the EBean implementation of the AndroidAnnotations framework (if you are not familiar with this framework, please Google ). For Asynchronous tasks, the @ Background tag of AA is used to schedule tasks through a thread pool. For the returned result of an asynchronous task, we have customized a View tag and called back through the interface (View can even be left empty without implementing the interface ). In this way, no matter whether the View calls the Presenter or the Presenter callback View, it is implemented through the interface, completely separating the coupling between the two, and the P-layer business can be highly reused.
In order to achieve this goal, we made a little extension to AndroidAnnotations, Github address in: https://github.com/ChatGame/androidannotations