Practices of using MVP Mode Programming on Android and androidmvp Mode Programming

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.