Function
Optimized design: Join the base API to reduce API redundancy
Powerful cache mode: Support offline cache, no network smart load cache, configurable if cache is required
Cookie management: Bring your own cookie management mechanism
Omni-Directional Request mode: Supports multiple ways to access the network (Get,put, post, delete)
Light Send call: Support form, text together, JSON upload.
File transfer: Support file download and upload, support progress
Dynamic add: Support the request header and Parameters unified Add, respectively.
Result processing: Supports uniform processing of returned results and automatically helps you serialize complex data.
Strong extensibility: Supports custom retrofit APIs that can be customized when the default API is not met
Easy to use: Support Unified request access to the network Process Control, in order to help you perfect to join the Processbar progress.
Rxjava combination: Combining Rxjava, thread intelligence control
Integration
Gradle:
Rxapi
The main processing request API, including Rxget, Rxpost, Rxdelete,rxput, Rxbody,rxfrom, rxupload,rxdownload. Please read the introduction to Rxcallback before using the basic API.
Rxget
Make call to get method, a variety of ways to return the results for you to choose, return different data type reference please see the original link rxcallback introduction.
Basic use:
Returns a string
new Novate.Builder(this) .baseUrl(“www.xxx.com/”) .build() .rxGet("service/path", parameters, new RxStringCallback() { });
return Bean
novate.rxGet("path or url", parameters, new RxResultCallback<JavaBean>() { });
Back to List
new Novate.Builder(this) .baseUrl("http://xxx.com/") .build() .rxGet("service/getList", parameters, new RxListCallback<List<JavaBean>>() { ... });
Returns the file
novate.rxGet("path or url", null, new RxFileCallBack(filePath, "name.jpg") {
..... });
Rxpost:
Call to make a POST method request
Returns a string
novate.rxPost("path or url", parameters, new RxStringCallback() { ..... });
return Bean
novate.rxPost("path or url", parameters, new RxResultCallback<ResultModel>() {
});
Back to List
novate.rxPost("path or url", parameters, new RxListCallback<List<ResultModel>>() { .... });
Returns the file
novate.rxPost("path or url", null, new RxFileCallBack(filePath, "name.jpg") { .... });
Uploading files
Here's how to upload files using novate:
Novate provides 2 ways to upload files. Body and part mode, body does not contain a key value, part contains a key value.
Rxuploadwithbody
The body mode post data, you can report files, pictures and so on.
String mPath = uploadPath; //"you File path "; String url = "http:/xxx.com"; novate.rxUploadWithBody(url, new File(mPath), new RxStringCallback() { .... });}
Rxuploadwithpart
Upload the file, the default key is the image
String mPath = uploadPath; //"you File path "; String url = "http:/xxx.com"; File file = new File(mPath); novate.rxUploadWithPart(url, file, new RxStringCallback() { .... });
Upload Multiple files:
Rxuploadwithpartlistbyfile:
List<File> fileList = new ArrayList<>(); fileList.add(file); fileList.add(file); fileList.add(file); novate.rxUploadWithPartListByFile(url, fileList, new RxStringCallback() { });
Graphic together
RequestBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM) .addFormDataPart("key1", V1) .addFormDataPart("key2", v2) .addFormDataPart("file", file.getName(), RequestBody.create(MediaType.parse("image/*"), file)) .build(); novate.rxBody(url , requestBody, callback);
Rxbody
RequestBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM) .addFormDataPart("key1", V1) .addFormDataPart("key2", v2) .addFormDataPart("file", file.getName(), RequestBody.create(MediaType.parse("image/*"), file)) .build(); novate.rxBody(url , requestBody, callback);
Download file
Use Rxget () to implement the download:
String downUrl = "http://wap.dl.pinyin.sogou.com/wapdl/hole/201512/03/SogouInput_android_v7.11_sweb.apk"; novate.rxGet(downUrl, parameters, new RxFileCallBack(FileUtil.getBasePath(this), "test.apk") { });
Rxdown () Download
String downUrl = "http://wap.dl.pinyin.sogou.com/wapdl/hole/201512/03/SogouInput_android_v7.11_sweb.apk"; new Novate.Builder(this) .rxDownload(downUrl, new RxFileCallBack(FileUtil.getBasePath(this), "test.apk") { });
OkHTTP Posture
Friends who like OKHTP pose can continue to use posture:
Request request = new Request.Builder() .get() .url("you url") .build(); novate.execute(request, new RxStringCallback() { });
Retrofit Api Posture
Novate the default to API
make you uncomfortable, Novate also support your own retrofit ApiService
.
API to define API with retrofit
New MyApi
public interface MyApi { @GET("url") Observable<MyBean> getdata(@QueryMap Map<String, String> maps); }
Execute
CallCall()
MyApi myApi = novate.create(MyApi.class); novate.call(myApi.getdata(parameters), new BaseSubscriber<MyBean>{ ‘‘‘‘‘‘‘ });}
Novate a web framework for Android Rxstyle