XUtils framework Usage Details, xutils Usage Details

Source: Internet
Author: User

XUtils framework Usage Details, xutils Usage Details

1. Introduction to xUtils

XUtils was originally originated from the Afinal framework and has undergone a large number of reconstruction, enabling xUtils to support large file uploads, more comprehensive http request protocol support (10 predicates), and more flexible ORM, more event annotations are supported and are not affected by obfuscation...

XUtils is least compatible with android 2.2 (api level 8 ). Currently, xUtils has four main modules:

  DbUtils Module

The orm framework in android allows you to add, delete, modify, and query a line of code;

Supports transactions, which are disabled by default;

You can use annotations to customize table names, column names, foreign keys, uniqueness constraints, not null constraints, and CHECK constraints. (note the table names and column names when obfuscation is required );

Supports binding foreign keys. when an object is saved, the foreign key associated with the object is automatically saved or updated;

  ViewUtils Module

The ioc framework in android can be fully annotated for UI, resource and event binding;

The new event binding method can still work normally after obfuscation using obfuscation tools;

HttpUtils Module

Supports synchronous and asynchronous requests;

Supports uploading large files, so uploading large files does not involve oom;

Supports GET, POST, PUT, MOVE, COPY, DELETE, HEAD, OPTIONS, TRACE, and CONNECT requests;

BitmapUtils Module

When loading bitmap, you do not need to consider the oom and android container image dislocation during the bitmap loading process;

Supports loading network images and local images;

Memory Management uses the lru algorithm to better manage bitmap memory;

Ii. DbUtils usage
DbUtils db = DbUtils. create (this); User user = new User (); // note that the User object must have the id attribute or the attribute user with the @ ID annotation. setEmail ("jerehedu@qq.com"); user. setName ("jerehedu"); db. save (user); // when saveBindingId is used to save an object, it will assign a value to the Object id... // search for Parent entity = db. findById (Parent. class, parent. getId (); List <Parent> list = db. findAll (Parent. class); // search for Parent = db by type. findFirst (Selector. from (Parent. class ). where ("name", "=", "test ")); // IS NULLParent Parent = db. findFirst (Selector. from (Parent. class ). where ("name", "=", null); // is not NULLParent Parent = db. findFirst (Selector. from (Parent. class ). where ("name ","! = ", Null); // WHERE id <54 AND (age> 20 OR age <30) order by id LIMIT pageSize OFFSET pageOffsetList <Parent> list = db. findAll (Selector. from (Parent. class ). where ("id", "<", 54 ). and (WhereBuilder. B ("age", ">", 20 ). or ("age", "<", 30 )). orderBy ("id "). limit (pageSize ). offset (pageSize * pageIndex); // when op is "in", the last parameter must be an array or Iterable implementation class (such as List) Parent test = db. findFirst (Selector. from (Parent. class ). where ("id", "in", new int [] {1, 2, 3}); // when op is ", the last parameter must be an array or Iterable implementation class (such as List) Parent test = db. findFirst (Selector. from (Parent. class ). where ("id", "between", new String [] {"1", "5"}); DbModel dbModel = db. findDbModelAll (Selector. from (Parent. class ). select ("name"); // select ("name") Only retrieves the List of name columns <DbModel> dbModels = db. findDbModelAll (Selector. from (Parent. class ). groupBy ("name "). select ("name", "count (name )"));... list <DbModel> dbModels = db. findDbModelAll (SQL); // customize sqlquery db.exe cNonQuery (SQL) // execute custom SQL
Iii. HttpUtils usage
HttpUtils http = new HttpUtils();http.send(HttpRequest.HttpMethod.GET,    "http://www.jerehedu.com",    new RequestCallBack<String>(){        @Override        public void onLoading(long total, long current, boolean isUploading) {            testTextView.setText(current + "/" + total);        }        @Override        public void onSuccess(ResponseInfo<String> responseInfo) {            textView.setText(responseInfo.result);        }        @Override        public void onStart() {        }        @Override        public void onFailure(HttpException error, String msg) {        }});

This time first introduce the usage of these two utils, other methods see https://github.com/wyouflf/xUtils, next blog I will also introduce.

 

Author: Jerry Education
Source: http://www.cnblogs.com/jerehedu/
The copyright of this article belongs to Yantai Jerry Education Technology Co., Ltd. and the blog Park. You are welcome to repost it. However, you must keep this statement without the author's consent and provide the original article connection on the article page, otherwise, you are entitled to pursue legal liability.

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.