Android Development Considerations

Source: Internet
Author: User

Where to put it, how do I develop it from the new project.

1. Create a new project and build your own application

Initialize XUTILS3 and your own Uncaughtexceptionhandler in application, unified Management app exit Add, remove activity stack

Each activity inherits its own activity_base (convenient post-unification processing), each activity adds to the stack (does not inherit, manually adds the stack mainly for the application to exit)

2. Naming method (greatly improve development efficiency) eg:

Activity------>activity_base

Fragment---->fragment_base (type _ function)

Adapter----->adapter_fragment_order (which class of adapter)

Layout------->activity_base (class name lowercase)

3. Annotations Eg:

Layout annotations

@ContentView (R.layout.activity_md_using_surface_view)  Public class extends Activity_base

View annotations

// Add plugin

(Tap, hold, etc) event annotations
@Event (r.id.button_add_plugin)  privatevoid Add (view view) {l.i ("Click to add");} //Button Add plugin event, click (type can be saved)
@Event (type = View.onlongclicklistener.  Class, value=r.id.vr_down)privateboolean vr_down_long (view view) {l.i ("option long Press Down");   Long Press

4. High cohesion, low coupling

4.1. In-app communications can be eventbus instead of handler or broadcast

4.2 Decoupling of logic eg: network requests, requests and parsing, presentation separation (core, code executed sequentially, logical steps implemented)

 Public voidGetData () {x.task (). Run (NewRunnable () {@Override Public voidrun () {requestparams params=NewRequestparams ("http://www.baidu.com/login.php");//Interface AddressParams.addbodyparameter ("username", "123"); Params.addbodyparameter ("Password", "123"); Try {                  FinalString Result=x.http (). Postsync (params, String.class);//Synchronize request in asynchronous task, GET request result str//get JSON, parse it, I encapsulated the FastjsonList<userinfo> list =jsonutil.paraslist (result,userinfo.class); //binding beans to adapter or other ways to update Ui,runonuithread can alsoX.task (). Autopost (NewRunnable () {@Override Public voidrun () {//Text.settext ("Update UI");                         }                     }); }Catch(Throwable e) {e.printstacktrace ();}    }         }); }

5. The problem of multilayer callback nesting, and the decoupling of asynchronous tasks can be referred to the implementation here

Https://github.com/Aiushtha/Android-LessCallBack

6.

Android Development Considerations

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.