Extended Androidannotations Programming with MVP mode

Source: Internet
Author: User

On the Code
Activity implements a set of interfaces to manipulate the view

 Public  class mainactivity extends Activity implements TestView{ p in//MVP, a view can have multiple p, implementing multiple sets of business logic, such as the main interface also needs to read conversation content@Bean(Testactions.class) Itestactions testactions;@ViewById(R.id.btn_back) Button Btnback;@ViewById(R.id.btn_noback) Button Btnnoback;//testview interface for interface display, due to actions may be called inside the thread, need Uithread security@UiThread@Override Public void ShowName(String name) {Toast.maketext ( This, name, Toast.length_short). Show (); Btnback.settext ("clicked");}//Event 1@Click(R.id.btn_back) Public void Doinback() {Testactions.doinbackground ();}//Event 2@Click(R.id.btn_noback) Public void Donoback() {testactions.donoback ();}}

The view interface can implement multiple
Testactions implements the business logic and injects a TestView interface for the callback display

@EBean Public  class testactions implements itestactions {**//Auto-inject UI view,fragment or activity,p view can have multiple, different view corresponding to different modules, this tag is extended to inject the view interface * *@ViewInterfaceTestView view;//Method 1, running through threads, background tasks@Override@Background Public void Doinbackground() {//Do some business here, call the view's showname display to the UIView.showname ("show in the back Ground2");}//Method 2, run in UI main thread@Override Public void Donoback() {View.showname ("Show in No");}}

TestView interface

publicvoidshowName(String name);

Extended Androidannotations Programming with MVP mode

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.