├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── checkstyle-idea.xml ├── codeStyles │ └── Project.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── LICENSE ├── README.md ├── Requestor ├── .gitignore ├── build.gradle ├── requestor_dependencies.gradle └── src │ └── main │ └── java │ └── com │ └── artshell │ └── requestor │ ├── ApiService.java │ ├── Converter.java │ ├── JsonConverter.java │ ├── MapperProvider.java │ ├── Protocol.java │ ├── RxRequestor.java │ ├── XmlConverter.java │ ├── package-info.java │ └── utils │ ├── ClassExclude.java │ ├── Numbers.java │ ├── Objects.java │ ├── Provider.java │ └── Validates.java ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── artshell │ │ └── examples │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── artshell │ │ │ └── examples │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── artshell │ └── examples │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artshell/RxRequestor/e3cc3722f4f259441247841b46bd879e3e091923/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 36 | 37 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 86 | 96 | 97 | 98 | 99 | 100 | 101 | 103 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Introduction 2 | General http request encapsulate base on Retrofit, OkHttp and RxJava, support for [`java`](https://docs.oracle.com/javase/tutorial/index.html) and [`Android`](https://developer.android.com/index.html). Support result types:`coutom type`, [`ResponseBody`](http://square.github.io/okhttp/3.x/okhttp/okhttp3/RequestBody.html), [`Byte arrays`](https://docs.oracle.com/javase/8/docs/api/java/lang/Byte.html), [`Reader`](https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html), [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html), [`String`](https://docs.oracle.com/javase/8/docs/api/java/lang/String.html), [`Void`](https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html). Data protocol includes `json` and `xml` 3 | 4 | ### Getting started 5 | ##### Add dependencies 6 | ```java 7 | implementation 'com.artshell:RxRequestor:1.0.6' 8 | ``` 9 | 10 | ##### Simple Usage 11 | ```java 12 | import com.artshell.requestor.Protocol; 13 | import com.artshell.requestor.RxRequestor; 14 | 15 | import java.io.InputStream; 16 | import java.io.Reader; 17 | import java.util.concurrent.TimeUnit; 18 | 19 | import io.reactivex.Flowable; 20 | import okhttp3.OkHttpClient; 21 | import okhttp3.ResponseBody; 22 | import retrofit2.Retrofit; 23 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; 24 | 25 | public class Test { 26 | 27 | public static void main(String[] args) { 28 | 29 | OkHttpClient client = new OkHttpClient.Builder() 30 | .connectTimeout(5 * 1000, TimeUnit.MILLISECONDS) 31 | .readTimeout(30 * 1000, TimeUnit.MILLISECONDS) 32 | .writeTimeout(30 * 1000, TimeUnit.MILLISECONDS) 33 | .retryOnConnectionFailure(true) 34 | /* more settings */ 35 | .build(); 36 | 37 | Retrofit retrofit = new Retrofit.Builder() 38 | .baseUrl("http://www.github.com") /* Your server address */ 39 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) 40 | .validateEagerly(true) 41 | .client(client) 42 | /* more settings */ 43 | .build(); 44 | 45 | RxRequestor requestor = new RxRequestor.Builder() 46 | .setRetrofit(retrofit) 47 | .supportBy(Protocol.JSON) 48 | .build(); 49 | 50 | 51 | // Example A 52 | // login whith user_id and password 53 | Map pairs = new HashMap<>(); 54 | pairs.put("user_id", "artshell"); 55 | pairs.put("password", "123456"); 56 | /* 57 | * { 58 | * "code": "1000", 59 | * "msg" : "success", 60 | * "data" : "welcome artshell" 61 | * } 62 | */ 63 | Flowable loginSource = requestor.postFields(LoginEntity.class, "user/login", pairs); 64 | 65 | 66 | // Example B 67 | /* 68 | * { 69 | * "code": "1000", 70 | * "msg" : "success", 71 | * "data" : "hello world" 72 | * } 73 | */ 74 | // Custom type (JSON entity), eg. 75 | Flowable helloSource = requestor.get(HelloEntity.class, "index/welcome"); 76 | 77 | // ResponseBody 78 | Flowable bodySource = requestor.get(ResponseBody.class, "index/welcome"); 79 | 80 | // Byte arrays 81 | Flowable byteSource = requestor.get(Byte[].class, "index/welcome"); 82 | 83 | // Reader 84 | Flowable readerSource = requestor.get(Reader.class, "index/welcome"); 85 | 86 | // InputStream 87 | Flowable streamSource = requestor.get(InputStream.class, "index/welcome"); 88 | 89 | // String 90 | Flowable stringSource = requestor.get(String.class, "index/welcome"); 91 | 92 | // Void 93 | Flowable ignoreSource = requestor.get(Void.class, "index/welcome"); 94 | 95 | } 96 | } 97 | ``` 98 | Other methods details see [`RxRquestor`](https://github.com/artshell/RxRequestor/blob/master/Requestor/src/main/java/com/artshell/requestor/RxRequestor.java) 99 | 100 | ##### Especially Usage 101 | Custom converter, for more detail see [`JsonConverter`](https://github.com/artshell/RxRequestor/blob/master/Requestor/src/main/java/com/artshell/requestor/JsonConverter.java) and [`XmlConverter`](https://github.com/artshell/RxRequestor/blob/master/Requestor/src/main/java/com/artshell/requestor/XmlConverter.java) 102 | ```java 103 | RxRequestor requestor = new RxRequestor.Builder() 104 | .setRetrofit(retrofit) 105 | .supportBy(Protocol.JSON) 106 | .customConverter(xxxJsonConverter) /* your custom converter */ 107 | .build(); 108 | ``` 109 | -------------------------------------------------------------------------------- /Requestor/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Requestor/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java-library' 2 | apply plugin: 'com.novoda.bintray-release' 3 | apply plugin: 'net.ltgt.errorprone' 4 | apply plugin: 'net.ltgt.apt' 5 | 6 | apply from: 'requestor_dependencies.gradle' 7 | 8 | dependencies { 9 | implementation fileTree(dir: 'libs', include: ['*.jar']) 10 | implementation "com.squareup.okhttp3:okhttp:${versions.okhttp}" 11 | implementation "com.squareup.okio:okio:${versions.okio}" 12 | implementation "com.squareup.retrofit2:retrofit:${versions.retrofit}" 13 | implementation "com.squareup.retrofit2:adapter-rxjava2:${versions.retrofit}" 14 | implementation "io.reactivex.rxjava2:rxjava:${versions.rxjava}" 15 | implementation "com.google.code.gson:gson:${versions.gson}" 16 | implementation "org.simpleframework:simple-xml:${versions.simple_xml}" 17 | errorprone "com.google.errorprone:error_prone_core:${versions.errorprone}" 18 | compileOnly "com.google.errorprone:error_prone_annotations:${versions.errorprone}" 19 | compileOnly "com.uber.javaxextras:javax-extras:${versions.uber_javax_extras}" 20 | api "com.google.code.findbugs:jsr305:${versions.findbugs_jsr305}" 21 | } 22 | 23 | sourceCompatibility = versions.compatVersion 24 | targetCompatibility = versions.compatVersion 25 | 26 | tasks.withType(Javadoc) { 27 | options { 28 | encoding "UTF-8" 29 | charSet "UTF-8" 30 | links "http://docs.oracle.com/javase/8/docs/api" 31 | } 32 | } 33 | 34 | publish { 35 | userOrg = 'artshell' 36 | groupId = push.groupId 37 | artifactId = push.artifactId 38 | publishVersion = push.publishName 39 | desc = 'General http request encapsulate base Retrofit, OkHttp and RxJava' 40 | website = push.url 41 | } 42 | -------------------------------------------------------------------------------- /Requestor/requestor_dependencies.gradle: -------------------------------------------------------------------------------- 1 | ext.versions = [ 2 | compatVersion : '1.7', 3 | okhttp : '3.9.1', 4 | okio : '1.13.0', 5 | retrofit : '2.3.0', 6 | rxjava : '2.1.16', 7 | gson : '2.8.2', 8 | simple_xml : '2.7.1', 9 | errorprone : '2.1.2', 10 | errorprone_plugin : '0.0.13', 11 | apt_plugin : '0.13', 12 | uber_javax_extras : '0.1.0', 13 | findbugs_jsr305 : '3.0.2', 14 | ] 15 | 16 | ext.push = [ 17 | groupId : 'com.artshell', 18 | artifactId : 'RxRequestor', 19 | publishCode : 106, 20 | publishName : '1.0.6', 21 | url : 'https://github.com/artshell/RxRequestor' 22 | ] -------------------------------------------------------------------------------- /Requestor/src/main/java/com/artshell/requestor/ApiService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 artshell. https://github.com/artshell 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.artshell.requestor; 18 | 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | import io.reactivex.Flowable; 23 | import okhttp3.MultipartBody; 24 | import okhttp3.RequestBody; 25 | import okhttp3.ResponseBody; 26 | import retrofit2.http.Body; 27 | import retrofit2.http.FieldMap; 28 | import retrofit2.http.FormUrlEncoded; 29 | import retrofit2.http.GET; 30 | import retrofit2.http.HeaderMap; 31 | import retrofit2.http.Multipart; 32 | import retrofit2.http.POST; 33 | import retrofit2.http.Part; 34 | import retrofit2.http.PartMap; 35 | import retrofit2.http.QueryMap; 36 | import retrofit2.http.QueryName; 37 | import retrofit2.http.Url; 38 | 39 | /** 40 | * @author artshell on 25/11/2017 41 | */ 42 | 43 | public interface ApiService { 44 | 45 | /** 46 | * @param url an instance of {@link String} 47 | * @return an instance of {@link Flowable} 48 | */ 49 | @GET 50 | Flowable get(@Url String url); 51 | 52 | /** 53 | * @param url an instance of {@link String} 54 | * @param headers {@link Map}, defer to {@link HeaderMap} 55 | * @return an instance of {@link Flowable} 56 | */ 57 | @GET 58 | Flowable getWithHeaders( 59 | @Url String url, 60 | @HeaderMap Map headers 61 | ); 62 | 63 | /** 64 | * @param url an instance of {@link String} 65 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 66 | * @return an instance of {@link Flowable} 67 | */ 68 | @GET 69 | Flowable getWithParameters( 70 | @Url String url, 71 | @QueryMap Map queryPairs 72 | ); 73 | 74 | /** 75 | * @param url an instance of {@link String} 76 | * @param headers {@link Map}, defer to {@link HeaderMap} 77 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 78 | * @return an instance of {@link Flowable} 79 | */ 80 | @GET 81 | Flowable getWithEntirety( 82 | @Url String url, 83 | @QueryMap Map queryPairs, 84 | @HeaderMap Map headers 85 | ); 86 | 87 | /** 88 | * @param url an instance of {@link String} 89 | * @param queryNames eg. String[] queryNames = {"price=12", "count=56"}; 90 | * @return an instance of {@link Flowable} 91 | */ 92 | @GET 93 | Flowable getWithQueryNames( 94 | @Url String url, 95 | @QueryName String[] queryNames 96 | ); 97 | 98 | /** 99 | * @param url an instance of {@link String} 100 | * @param queryNames eg. String[] queryNames = {"price=12", "count=56"} 101 | * @param headers {@link Map}, defer to {@link HeaderMap} 102 | * @return an instance of {@link Flowable} 103 | */ 104 | @GET 105 | Flowable getWithEntirety( 106 | @Url String url, 107 | @QueryName String[] queryNames, 108 | @HeaderMap Map headers 109 | ); 110 | 111 | /** 112 | * @param url an instance of {@link String} 113 | * @param queryNames eg. List queryNames = new ArrayList<>(); queryNames.add("price=12") 114 | * @return an instance of {@link Flowable} 115 | */ 116 | @GET 117 | Flowable getWithQueryNames( 118 | @Url String url, 119 | @QueryName List queryNames 120 | ); 121 | 122 | /** 123 | * @param url an instance of {@link String} 124 | * @param queryNames eg. List queryNames = new ArrayList<>(); queryNames.add("price=12") 125 | * @param headers {@link Map}, defer to {@link HeaderMap} 126 | * @return an instance of {@link Flowable} 127 | */ 128 | @GET 129 | Flowable getWithEntirety( 130 | @Url String url, 131 | @QueryName List queryNames, 132 | @HeaderMap Map headers 133 | ); 134 | 135 | /** 136 | * @param url an instance of {@link String} 137 | * @return an instance of {@link Flowable} 138 | */ 139 | @POST 140 | Flowable post(@Url String url); 141 | 142 | /** 143 | * @param url an instance of {@link String} 144 | * @param headers {@link Map}, defer to {@link HeaderMap} 145 | * @return an instance of {@link Flowable} 146 | */ 147 | @POST 148 | Flowable postWithHeaders( 149 | @Url String url, 150 | @HeaderMap Map headers 151 | ); 152 | 153 | /** 154 | * @param url an instance of {@link String} 155 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 156 | * @return an instance of {@link Flowable} 157 | */ 158 | @POST 159 | Flowable postWithParameters( 160 | @Url String url, 161 | @QueryMap Map queryPairs 162 | ); 163 | 164 | /** 165 | * @param url an instance of {@link String} 166 | * @param couples {@link Map}, defer to {@link FieldMap} 167 | * @return an instance of {@link Flowable} 168 | */ 169 | @FormUrlEncoded 170 | @POST 171 | Flowable postCouples( 172 | @Url String url, 173 | @FieldMap Map couples 174 | ); 175 | 176 | /** 177 | * @param url an instance of {@link String} 178 | * @param headers {@link Map}, defer to {@link HeaderMap} 179 | * @param fields {@link Map}, defer to {@link FieldMap} 180 | * @return an instance of {@link Flowable} 181 | */ 182 | @FormUrlEncoded 183 | @POST 184 | Flowable postWithHeaders( 185 | @Url String url, 186 | @HeaderMap Map headers, 187 | @FieldMap Map fields 188 | ); 189 | 190 | /** 191 | * @param url an instance of {@link String} 192 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 193 | * @param fields {@link Map}, defer to {@link FieldMap} 194 | * @return an instance of {@link Flowable} 195 | */ 196 | @FormUrlEncoded 197 | @POST 198 | Flowable postWithParameters( 199 | @Url String url, 200 | @QueryMap Map queryPairs, 201 | @FieldMap Map fields 202 | ); 203 | 204 | /** 205 | * @param url an instance of {@link String} 206 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 207 | * @param headers {@link Map}, defer to {@link HeaderMap} 208 | * @param fields {@link Map}, defer to {@link FieldMap} 209 | * @return an instance of {@link Flowable} 210 | */ 211 | @FormUrlEncoded 212 | @POST 213 | Flowable postWithEntirety( 214 | @Url String url, 215 | @QueryMap Map queryPairs, 216 | @HeaderMap Map headers, 217 | @FieldMap Map fields 218 | ); 219 | 220 | /** 221 | * @param url an instance of {@link String} 222 | * @param part an instance of {@link MultipartBody.Part}, defer to {@link Part} 223 | * @return an instance of {@link Flowable} 224 | */ 225 | @Multipart 226 | @POST 227 | Flowable postPart( 228 | @Url String url, 229 | @Part MultipartBody.Part part 230 | ); 231 | 232 | /** 233 | * @param url an instance of {@link String} 234 | * @param headers {@link Map}, defer to {@link HeaderMap} 235 | * @param part an instance of {@link MultipartBody.Part}, defer to {@link Part} 236 | * @return an instance of {@link Flowable} 237 | */ 238 | @Multipart 239 | @POST 240 | Flowable postPartWithHeaders( 241 | @Url String url, 242 | @HeaderMap Map headers, 243 | @Part MultipartBody.Part part 244 | ); 245 | 246 | /** 247 | * @param url an instance of {@link String} 248 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 249 | * @param part an instance of {@link MultipartBody.Part}, defer to {@link Part} 250 | * @return an instance of {@link Flowable} 251 | */ 252 | @Multipart 253 | @POST 254 | Flowable postPartWithParameters( 255 | @Url String url, 256 | @QueryMap Map queryPairs, 257 | @Part MultipartBody.Part part 258 | ); 259 | 260 | /** 261 | * @param url an instance of {@link String} 262 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 263 | * @param headers {@link Map}, defer to {@link HeaderMap} 264 | * @param part an instance of {@link MultipartBody.Part}, defer to {@link Part} 265 | * @return an instance of {@link Flowable} 266 | */ 267 | @Multipart 268 | @POST 269 | Flowable postPartWithEntirety( 270 | @Url String url, 271 | @QueryMap Map queryPairs, 272 | @HeaderMap Map headers, 273 | @Part MultipartBody.Part part 274 | ); 275 | 276 | 277 | /** 278 | * @param url an instance of {@link String} 279 | * @param parts an array instance of {@link MultipartBody.Part}, defer to {@link Part} 280 | * @return an instance of {@link Flowable} 281 | */ 282 | @Multipart 283 | @POST 284 | Flowable postParts( 285 | @Url String url, 286 | @Part MultipartBody.Part[] parts 287 | ); 288 | 289 | /** 290 | * @param url an instance of {@link String} 291 | * @param headers {@link Map}, defer to {@link HeaderMap} 292 | * @param parts an array instance of {@link MultipartBody.Part}, defer to {@link Part} 293 | * @return an instance of {@link Flowable} 294 | */ 295 | @Multipart 296 | @POST 297 | Flowable postPartsWithHeaders( 298 | @Url String url, 299 | @HeaderMap Map headers, 300 | @Part MultipartBody.Part[] parts 301 | ); 302 | 303 | /** 304 | * @param url an instance of {@link String} 305 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 306 | * @param parts an array instance of {@link MultipartBody.Part}, defer to {@link Part} 307 | * @return an instance of {@link Flowable} 308 | */ 309 | @Multipart 310 | @POST 311 | Flowable postPartsWithParameters( 312 | @Url String url, 313 | @QueryMap Map queryPairs, 314 | @Part MultipartBody.Part[] parts 315 | ); 316 | 317 | /** 318 | * @param url an instance of {@link String} 319 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 320 | * @param headers {@link Map}, defer to {@link HeaderMap} 321 | * @param parts an array instance of {@link MultipartBody.Part}, defer to {@link Part} 322 | * @return an instance of {@link Flowable} 323 | */ 324 | @Multipart 325 | @POST 326 | Flowable postPartsWithEntirety( 327 | @Url String url, 328 | @QueryMap Map queryPairs, 329 | @HeaderMap Map headers, 330 | @Part MultipartBody.Part[] parts 331 | ); 332 | 333 | /** 334 | * @param url an instance of {@link String} 335 | * @param parts a {@link List} instance of {@link MultipartBody.Part}, defer to {@link Part} 336 | * @return an instance of {@link Flowable} 337 | */ 338 | @Multipart 339 | @POST 340 | Flowable postParts( 341 | @Url String url, 342 | @Part List parts 343 | ); 344 | 345 | /** 346 | * @param url an instance of {@link String} 347 | * @param headers {@link Map}, defer to {@link HeaderMap} 348 | * @param parts a {@link List} instance of {@link MultipartBody.Part}, defer to {@link Part} 349 | * @return an instance of {@link Flowable} 350 | */ 351 | @Multipart 352 | @POST 353 | Flowable postPartsWithHeaders( 354 | @Url String url, 355 | @HeaderMap Map headers, 356 | @Part List parts 357 | ); 358 | 359 | /** 360 | * @param url an instance of {@link String} 361 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 362 | * @param parts a {@link List} instance of {@link MultipartBody.Part}, defer to {@link Part} 363 | * @return an instance of {@link Flowable} 364 | */ 365 | @Multipart 366 | @POST 367 | Flowable postPartsWithParameters( 368 | @Url String url, 369 | @QueryMap Map queryPairs, 370 | @Part List parts 371 | ); 372 | 373 | /** 374 | * @param url an instance of {@link String} 375 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 376 | * @param headers {@link Map}, defer to {@link HeaderMap} 377 | * @param parts a {@link List} instance of {@link MultipartBody.Part}, defer to {@link Part} 378 | * @return an instance of {@link Flowable} 379 | */ 380 | @Multipart 381 | @POST 382 | Flowable postPartsWithEntirety( 383 | @Url String url, 384 | @QueryMap Map queryPairs, 385 | @HeaderMap Map headers, 386 | @Part List parts 387 | ); 388 | 389 | /** 390 | * @param url an instance of {@link String} 391 | * @param parts {@link String}/{@link RequestBody} pairs, defer to {@link PartMap} 392 | * @return an instance of {@link Flowable} 393 | */ 394 | @Multipart 395 | @POST 396 | Flowable postParts( 397 | @Url String url, 398 | @PartMap Map parts 399 | ); 400 | 401 | /** 402 | * @param url an instance of {@link String} 403 | * @param headers {@link Map}, defer to {@link HeaderMap} 404 | * @param parts {@link String}/{@link RequestBody} pairs, defer to {@link PartMap} 405 | * @return an instance of {@link Flowable} 406 | */ 407 | @Multipart 408 | @POST 409 | Flowable postPartsWithHeaders( 410 | @Url String url, 411 | @HeaderMap Map headers, 412 | @PartMap Map parts 413 | ); 414 | 415 | /** 416 | * @param url an instance of {@link String} 417 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 418 | * @param parts {@link String}/{@link RequestBody} pairs, defer to {@link PartMap} 419 | * @return an instance of {@link Flowable} 420 | */ 421 | @Multipart 422 | @POST 423 | Flowable postPartsWithParameters( 424 | @Url String url, 425 | @QueryMap Map queryPairs, 426 | @PartMap Map parts 427 | ); 428 | 429 | /** 430 | * @param url an instance of {@link String} 431 | * @param headers {@link Map}, defer to {@link HeaderMap} 432 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 433 | * @param parts {@link String}/{@link RequestBody} pairs, defer to {@link PartMap} 434 | * @return an instance of {@link Flowable} 435 | */ 436 | @Multipart 437 | @POST 438 | Flowable postPartsWithEntirety( 439 | @Url String url, 440 | @QueryMap Map queryPairs, 441 | @HeaderMap Map headers, 442 | @PartMap Map parts 443 | ); 444 | 445 | /** 446 | * @param url an instance of {@link String} 447 | * @param body an instance of {@link RequestBody}, defer to {@link Body} 448 | * @return an instance of {@link Flowable} 449 | */ 450 | @POST 451 | Flowable postBody( 452 | @Url String url, 453 | @Body RequestBody body 454 | ); 455 | 456 | /** 457 | * @param url an instance of {@link String} 458 | * @param headers {@link Map}, defer to {@link HeaderMap} 459 | * @param body an instance of {@link RequestBody}, defer to {@link Body} 460 | * @return an instance of {@link Flowable} 461 | */ 462 | @POST 463 | Flowable postBodyWithHeaders( 464 | @Url String url, 465 | @HeaderMap Map headers, 466 | @Body RequestBody body 467 | ); 468 | 469 | /** 470 | * @param url an instance of {@link String} 471 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 472 | * @param body an instance of {@link RequestBody}, defer to {@link Body} 473 | * @return an instance of {@link Flowable} 474 | */ 475 | @POST 476 | Flowable postBodyWithParameters( 477 | @Url String url, 478 | @QueryMap Map queryPairs, 479 | @Body RequestBody body 480 | ); 481 | 482 | /** 483 | * @param url an instance of {@link String} 484 | * @param headers {@link Map}, defer to {@link HeaderMap} 485 | * @param queryPairs {@link Map}, defer to {@link QueryMap} 486 | * @param body an instance of {@link RequestBody}, defer to {@link Body} 487 | * @return an instance of {@link Flowable} 488 | */ 489 | @POST 490 | Flowable postBodyWithEntirety( 491 | @Url String url, 492 | @QueryMap Map queryPairs, 493 | @HeaderMap Map headers, 494 | @Body RequestBody body 495 | ); 496 | } 497 | -------------------------------------------------------------------------------- /Requestor/src/main/java/com/artshell/requestor/Converter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 artshell. https://github.com/artshell 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.artshell.requestor; 18 | 19 | import java.io.IOException; 20 | 21 | import okhttp3.ResponseBody; 22 | 23 | /** 24 | * @author artshell on 02/12/2017 25 | */ 26 | 27 | public interface Converter { 28 | /** 29 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 30 | * {@link java.io.InputStream}, {@link String} 31 | * @param body 32 | * @param 33 | * @return 34 | * @throws IOException 35 | */ 36 | T apply(Class target, ResponseBody body) throws IOException; 37 | } 38 | -------------------------------------------------------------------------------- /Requestor/src/main/java/com/artshell/requestor/JsonConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 artshell. https://github.com/artshell 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.artshell.requestor; 18 | 19 | import com.google.gson.Gson; 20 | 21 | import java.io.IOException; 22 | 23 | import okhttp3.ResponseBody; 24 | 25 | /** 26 | * @author artshell on 02/12/2017 27 | */ 28 | 29 | public final class JsonConverter implements Converter { 30 | private Gson gson = new Gson(); 31 | 32 | public static JsonConverter create() { 33 | return new JsonConverter(); 34 | } 35 | 36 | @Override 37 | public T apply(Class target, ResponseBody body) throws IOException { 38 | try { 39 | return gson.fromJson(body.charStream(), target); 40 | } finally { 41 | body.close(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Requestor/src/main/java/com/artshell/requestor/MapperProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 artshell. https://github.com/artshell 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.artshell.requestor; 18 | 19 | import org.reactivestreams.Publisher; 20 | 21 | import java.io.InputStream; 22 | import java.io.Reader; 23 | 24 | import io.reactivex.Flowable; 25 | import io.reactivex.functions.Function; 26 | import okhttp3.ResponseBody; 27 | 28 | /** 29 | * @author artshell on 02/12/2017 30 | */ 31 | 32 | final class MapperProvider { 33 | private Converter mConverter; 34 | 35 | public MapperProvider(Converter converter) { 36 | mConverter = converter; 37 | } 38 | 39 | public Converter getConverter() { 40 | return mConverter; 41 | } 42 | 43 | public Function> converterFor(Class target) { 44 | return new PublisherFunction<>(mConverter, target); 45 | } 46 | 47 | private static class PublisherFunction implements Function> { 48 | private Converter mConverter; 49 | private Class clazz; 50 | 51 | PublisherFunction(Converter converter, Class target) { 52 | this.mConverter = converter; 53 | this.clazz = target; 54 | } 55 | 56 | @SuppressWarnings("unchecked") 57 | @Override 58 | public Publisher apply(ResponseBody body) throws Exception { 59 | // Fix for http status's code 204,205 60 | if (body == null) return Flowable.empty(); 61 | 62 | if (clazz == ResponseBody.class) { 63 | return Flowable.just((T) body); 64 | } else if (clazz == Byte[].class) { 65 | byte[] bts = body.bytes(); 66 | Byte[] copy = new Byte[bts.length]; 67 | for (int i = 0; i < bts.length; i++) { 68 | copy[i] = bts[i]; 69 | } 70 | return Flowable.just((T) copy); 71 | } else if (clazz == Reader.class) { 72 | return Flowable.just((T) body.charStream()); 73 | } else if (clazz == InputStream.class) { 74 | return Flowable.just((T) body.byteStream()); 75 | } else if (clazz == String.class) { 76 | return Flowable.just((T) body.string()); 77 | } else if (clazz == void.class || clazz == Void.TYPE) { 78 | return Flowable.empty(); 79 | } else { 80 | return Flowable.just(mConverter.apply(clazz, body)); 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Requestor/src/main/java/com/artshell/requestor/Protocol.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 artshell. https://github.com/artshell 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.artshell.requestor; 18 | 19 | /** 20 | * @author artshell on 11/01/2018 21 | */ 22 | 23 | public enum Protocol { 24 | JSON, XML 25 | } 26 | -------------------------------------------------------------------------------- /Requestor/src/main/java/com/artshell/requestor/RxRequestor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 artshell. https://github.com/artshell 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.artshell.requestor; 18 | 19 | import com.artshell.requestor.utils.ClassExclude; 20 | import com.artshell.requestor.utils.Objects; 21 | import com.artshell.requestor.utils.Validates; 22 | 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | import io.reactivex.Flowable; 27 | import okhttp3.HttpUrl; 28 | import okhttp3.MultipartBody; 29 | import okhttp3.RequestBody; 30 | import okhttp3.ResponseBody; 31 | import retrofit2.CallAdapter; 32 | import retrofit2.Retrofit; 33 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; 34 | import retrofit2.http.FieldMap; 35 | import retrofit2.http.HeaderMap; 36 | import retrofit2.http.QueryMap; 37 | 38 | /** 39 | * @author artshell on 25/11/2017 40 | */ 41 | 42 | public class RxRequestor { 43 | private Retrofit mRetrofit; 44 | private ApiService mDelegate; 45 | private Protocol mType; 46 | private MapperProvider mProvider; 47 | 48 | private RxRequestor(Retrofit retrofit, ApiService delegate, Protocol type, MapperProvider provider) { 49 | mRetrofit = retrofit; 50 | mDelegate = delegate; 51 | mType = type; 52 | mProvider = provider; 53 | } 54 | 55 | /** 56 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 57 | * {@link java.io.InputStream}, {@link String}, {@link Void} 58 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 59 | * @param a class 60 | * @return an instance of {@link Flowable} 61 | */ 62 | public Flowable get(Class target, String url) { 63 | ClassExclude.exclude(target); 64 | return mDelegate.get(url).flatMap(mProvider.converterFor(target)); 65 | } 66 | 67 | /** 68 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 69 | * {@link java.io.InputStream}, {@link String}, {@link Void} 70 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 71 | * @param headers refer to {@link HeaderMap} 72 | * @param a class 73 | * @return an instance of {@link Flowable} 74 | */ 75 | public Flowable getWithHeaders(Class target, String url, Map headers) { 76 | Validates.check(target, headers); 77 | return mDelegate.getWithHeaders(url, headers).flatMap(mProvider.converterFor(target)); 78 | } 79 | 80 | /** 81 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 82 | * {@link java.io.InputStream}, {@link String}, {@link Void} 83 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 84 | * @param queryPairs refer to {@link QueryMap} 85 | * @param a class 86 | * @return an instance of {@link Flowable} 87 | */ 88 | public Flowable getWithParameters(Class target, String url, Map queryPairs) { 89 | Validates.check(target, queryPairs); 90 | return mDelegate.getWithParameters(url, queryPairs).flatMap(mProvider.converterFor(target)); 91 | } 92 | 93 | /** 94 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 95 | * {@link java.io.InputStream}, {@link String}, {@link Void} 96 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 97 | * @param queryPairs refer to {@link QueryMap} 98 | * @param headers refer to {@link HeaderMap} 99 | * @param a class 100 | * @return an instance of {@link Flowable} 101 | */ 102 | public Flowable getWithEntirety(Class target, String url, Map queryPairs, Map headers) { 103 | Validates.check(target, queryPairs, headers); 104 | return mDelegate.getWithEntirety(url, queryPairs, headers).flatMap(mProvider.converterFor(target)); 105 | } 106 | 107 | /** 108 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 109 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 110 | * @param queryNames key/value pairs of {@link String}, {@link Void} array 111 | * @param a class 112 | * @return an instance of {@link Flowable} 113 | */ 114 | public Flowable getWithQueryNames(Class target, String url, String[] queryNames) { 115 | Validates.check(target, queryNames); 116 | return mDelegate.getWithQueryNames(url, queryNames).flatMap(mProvider.converterFor(target)); 117 | } 118 | 119 | /** 120 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 121 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 122 | * @param queryNames key/value pairs of {@link String}, {@link Void} of array 123 | * @param headers refer to {@link HeaderMap} 124 | * @param a class 125 | * @return an instance of {@link Flowable} 126 | */ 127 | public Flowable getWithEntirety(Class target, String url, String[] queryNames, Map headers) { 128 | Validates.check(target, queryNames, headers); 129 | return mDelegate.getWithEntirety(url, queryNames, headers).flatMap(mProvider.converterFor(target)); 130 | } 131 | 132 | /** 133 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 134 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 135 | * @param queryNames key/value pairs of {@link String}, {@link Void} of Array 136 | * @param a class 137 | * @return an instance of {@link Flowable} 138 | */ 139 | public Flowable getWithQueryNames(Class target, String url, List queryNames) { 140 | Validates.check(target, queryNames); 141 | return mDelegate.getWithQueryNames(url, queryNames).flatMap(mProvider.converterFor(target)); 142 | } 143 | 144 | /** 145 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 146 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 147 | * @param queryNames key/value pairs of {@link String}, {@link Void} of {@link List} 148 | * @param headers refer to {@link HeaderMap} 149 | * @param a class 150 | * @return an instance of {@link Flowable} 151 | */ 152 | public Flowable getWithEntirety(Class target, String url, List queryNames, Map headers) { 153 | Validates.check(target, queryNames, headers); 154 | return mDelegate.getWithEntirety(url, queryNames, headers).flatMap(mProvider.converterFor(target)); 155 | } 156 | 157 | /** 158 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 159 | * {@link java.io.InputStream}, {@link String}, {@link Void} 160 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 161 | * @param a class 162 | * @return an instance of {@link Flowable} 163 | */ 164 | public Flowable post(Class target, String url) { 165 | ClassExclude.exclude(target); 166 | return mDelegate.post(url).flatMap(mProvider.converterFor(target)); 167 | } 168 | 169 | /** 170 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 171 | * {@link java.io.InputStream}, {@link String}, {@link Void} 172 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 173 | * @param headers refer to {@link HeaderMap} 174 | * @param a class 175 | * @return an instance of {@link Flowable} 176 | */ 177 | public Flowable postWithHeaders(Class target, String url, Map headers) { 178 | Validates.check(target, headers); 179 | return mDelegate.postWithHeaders(url, headers).flatMap(mProvider.converterFor(target)); 180 | } 181 | 182 | /** 183 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 184 | * {@link java.io.InputStream}, {@link String}, {@link Void} 185 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 186 | * @param queryPairs refer to {@link QueryMap} 187 | * @param a class 188 | * @return an instance of {@link Flowable} 189 | */ 190 | public Flowable postWithParameters(Class target, String url, Map queryPairs) { 191 | Validates.check(target, queryPairs); 192 | return mDelegate.postWithParameters(url, queryPairs).flatMap(mProvider.converterFor(target)); 193 | } 194 | 195 | /** 196 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 197 | * {@link java.io.InputStream}, {@link String}, {@link Void} 198 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 199 | * @param couples refer to {@link FieldMap} 200 | * @param a class 201 | * @return an instance of {@link Flowable} 202 | */ 203 | public Flowable postCouples(Class target, String url, Map couples) { 204 | Validates.check(target, couples); 205 | return mDelegate.postCouples(url, couples).flatMap(mProvider.converterFor(target)); 206 | } 207 | 208 | /** 209 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 210 | * {@link java.io.InputStream}, {@link String}, {@link Void} 211 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 212 | * @param headers refer to {@link HeaderMap} 213 | * @param fields refer to {@link FieldMap} 214 | * @param a class 215 | * @return an instance of {@link Flowable} 216 | */ 217 | public Flowable postWithHeaders(Class target, String url, Map headers, Map fields) { 218 | Validates.check(target, headers, fields); 219 | return mDelegate.postWithHeaders(url, headers, fields).flatMap(mProvider.converterFor(target)); 220 | } 221 | 222 | /** 223 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 224 | * {@link java.io.InputStream}, {@link String}, {@link Void} 225 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 226 | * @param queryPairs refer to {@link QueryMap} 227 | * @param fields refer to {@link FieldMap} 228 | * @param a class 229 | * @return an instance of {@link Flowable} 230 | */ 231 | public Flowable postWithParameters(Class target, String url, Map queryPairs, Map fields) { 232 | Validates.check(target, queryPairs, fields); 233 | return mDelegate.postWithParameters(url, queryPairs, fields).flatMap(mProvider.converterFor(target)); 234 | } 235 | 236 | /** 237 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 238 | * {@link java.io.InputStream}, {@link String}, {@link Void} 239 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 240 | * @param queryPairs refer to {@link QueryMap} 241 | * @param headers refer to {@link HeaderMap} 242 | * @param fields refer to {@link FieldMap} 243 | * @param a class 244 | * @return an instance of {@link Flowable} 245 | */ 246 | public Flowable postWithEntirety(Class target, String url, Map queryPairs, Map headers, Map fields) { 247 | Validates.check(target, queryPairs, headers, fields); 248 | return mDelegate.postWithEntirety(url, queryPairs, headers, fields).flatMap(mProvider.converterFor(target)); 249 | } 250 | 251 | /** 252 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 253 | * {@link java.io.InputStream}, {@link String}, {@link Void} 254 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 255 | * @param part refer to {@link MultipartBody.Part} 256 | * @param a class 257 | * @return an instance of {@link Flowable} 258 | */ 259 | public Flowable postPart(Class target, String url, MultipartBody.Part part) { 260 | ClassExclude.exclude(target); 261 | return mDelegate.postPart(url, part).flatMap(mProvider.converterFor(target)); 262 | } 263 | 264 | /** 265 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 266 | * {@link java.io.InputStream}, {@link String}, {@link Void} 267 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 268 | * @param headers refer to {@link HeaderMap} 269 | * @param part refer to {@link MultipartBody.Part} 270 | * @param a class 271 | * @return an instance of {@link Flowable} 272 | */ 273 | public Flowable postPartWithHeaders(Class target, String url, Map headers, MultipartBody.Part part) { 274 | Validates.check(target, headers); 275 | return mDelegate.postPartWithHeaders(url, headers, part).flatMap(mProvider.converterFor(target)); 276 | } 277 | 278 | /** 279 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 280 | * {@link java.io.InputStream}, {@link String}, {@link Void} 281 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 282 | * @param queryPairs refer to {@link QueryMap} 283 | * @param part refer to {@link MultipartBody.Part} 284 | * @param a class 285 | * @return an instance of {@link Flowable} 286 | */ 287 | public Flowable postPartWithParameters(Class target, String url, Map queryPairs, MultipartBody.Part part) { 288 | Validates.check(target, queryPairs); 289 | return mDelegate.postPartWithParameters(url, queryPairs, part).flatMap(mProvider.converterFor(target)); 290 | } 291 | 292 | /** 293 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 294 | * {@link java.io.InputStream}, {@link String}, {@link Void} 295 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 296 | * @param queryPairs refer to {@link QueryMap} 297 | * @param headers refer to {@link HeaderMap} 298 | * @param part refer to {@link MultipartBody.Part} 299 | * @param a class 300 | * @return an instance of {@link Flowable} 301 | */ 302 | public Flowable postPartWithEntirety(Class target, String url, Map queryPairs, Map headers, MultipartBody.Part part) { 303 | Validates.check(target, queryPairs, headers); 304 | return mDelegate.postPartWithEntirety(url, queryPairs, headers, part).flatMap(mProvider.converterFor(target)); 305 | } 306 | 307 | /** 308 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 309 | * {@link java.io.InputStream}, {@link String}, {@link Void} 310 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 311 | * @param parts refer to {@link MultipartBody.Part} 312 | * @param a class 313 | * @return an instance of {@link Flowable} 314 | */ 315 | public Flowable postParts(Class target, String url, MultipartBody.Part[] parts) { 316 | Validates.check(target, parts); 317 | return mDelegate.postParts(url, parts).flatMap(mProvider.converterFor(target)); 318 | } 319 | 320 | /** 321 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 322 | * {@link java.io.InputStream}, {@link String}, {@link Void} 323 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 324 | * @param headers refer to {@link HeaderMap} 325 | * @param parts refer to {@link MultipartBody.Part} 326 | * @param a class 327 | * @return an instance of {@link Flowable} 328 | */ 329 | public Flowable postPartsWithHeaders(Class target, String url, Map headers, MultipartBody.Part[] parts) { 330 | Validates.check(target, headers, parts); 331 | return mDelegate.postPartsWithHeaders(url, headers, parts).flatMap(mProvider.converterFor(target)); 332 | } 333 | 334 | /** 335 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 336 | * {@link java.io.InputStream}, {@link String}, {@link Void} 337 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 338 | * @param queryPairs refer to {@link QueryMap} 339 | * @param parts refer to {@link MultipartBody.Part} 340 | * @param a class 341 | * @return an instance of {@link Flowable} 342 | */ 343 | public Flowable postPartsWithParameters(Class target, String url, Map queryPairs, MultipartBody.Part[] parts) { 344 | Validates.check(target, queryPairs, parts); 345 | return mDelegate.postPartsWithParameters(url, queryPairs, parts).flatMap(mProvider.converterFor(target)); 346 | } 347 | 348 | /** 349 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 350 | * {@link java.io.InputStream}, {@link String}, {@link Void} 351 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 352 | * @param queryPairs refer to {@link QueryMap} 353 | * @param headers refer to {@link HeaderMap} 354 | * @param parts refer to {@link MultipartBody.Part} 355 | * @param a class 356 | * @return an instance of {@link Flowable} 357 | */ 358 | public Flowable postPartsWithEntirety(Class target, String url, Map queryPairs, Map headers, MultipartBody.Part[] parts) { 359 | Validates.check(target, queryPairs, headers, parts); 360 | return mDelegate.postPartsWithEntirety(url, queryPairs, headers, parts).flatMap(mProvider.converterFor(target)); 361 | } 362 | 363 | /** 364 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 365 | * {@link java.io.InputStream}, {@link String}, {@link Void} 366 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 367 | * @param parts refer to {@link MultipartBody.Part} 368 | * @param a class 369 | * @return an instance of {@link Flowable} 370 | */ 371 | public Flowable postParts(Class target, String url, List parts) { 372 | Validates.check(target, parts); 373 | return mDelegate.postParts(url, parts).flatMap(mProvider.converterFor(target)); 374 | } 375 | 376 | /** 377 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 378 | * {@link java.io.InputStream}, {@link String}, {@link Void} 379 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 380 | * @param headers refer to {@link HeaderMap} 381 | * @param parts refer to {@link MultipartBody.Part} 382 | * @param a class 383 | * @return an instance of {@link Flowable} 384 | */ 385 | public Flowable postPartsWithHeaders(Class target, String url, Map headers, List parts) { 386 | Validates.check(target, headers, parts); 387 | return mDelegate.postPartsWithHeaders(url, headers, parts).flatMap(mProvider.converterFor(target)); 388 | } 389 | 390 | /** 391 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 392 | * {@link java.io.InputStream}, {@link String}, {@link Void} 393 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 394 | * @param queryPairs refer to {@link QueryMap} 395 | * @param parts refer to {@link MultipartBody.Part} 396 | * @param a class 397 | * @return an instance of {@link Flowable} 398 | */ 399 | public Flowable postPartsWithParameters(Class target, String url, Map queryPairs, List parts) { 400 | Validates.check(target, queryPairs, parts); 401 | return mDelegate.postPartsWithParameters(url, queryPairs, parts).flatMap(mProvider.converterFor(target)); 402 | } 403 | 404 | /** 405 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 406 | * {@link java.io.InputStream}, {@link String}, {@link Void} 407 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 408 | * @param queryPairs refer to {@link QueryMap} 409 | * @param headers refer to {@link HeaderMap} 410 | * @param parts refer to {@link MultipartBody.Part} 411 | * @param a class 412 | * @return an instance of {@link Flowable} 413 | */ 414 | public Flowable postPartsWithEntirety(Class target, String url, Map queryPairs, Map headers, List parts) { 415 | Validates.check(target, queryPairs, headers, parts); 416 | return mDelegate.postPartsWithEntirety(url, queryPairs, headers, parts).flatMap(mProvider.converterFor(target)); 417 | } 418 | 419 | /** 420 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 421 | * {@link java.io.InputStream}, {@link String}, {@link Void} 422 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 423 | * @param parts refer to {@link MultipartBody.Part} 424 | * @param a class 425 | * @return an instance of {@link Flowable} 426 | */ 427 | public Flowable postParts(Class target, String url, Map parts) { 428 | Validates.check(target, parts); 429 | return mDelegate.postParts(url, parts).flatMap(mProvider.converterFor(target)); 430 | } 431 | 432 | /** 433 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 434 | * {@link java.io.InputStream}, {@link String}, {@link Void} 435 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 436 | * @param headers refer to {@link HeaderMap} 437 | * @param parts refer to {@link MultipartBody.Part} 438 | * @param a class 439 | * @return an instance of {@link Flowable} 440 | */ 441 | public Flowable postPartsWithHeaders(Class target, String url, Map headers, Map parts) { 442 | Validates.check(target, headers, parts); 443 | return mDelegate.postPartsWithHeaders(url, headers, parts).flatMap(mProvider.converterFor(target)); 444 | } 445 | 446 | /** 447 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 448 | * {@link java.io.InputStream}, {@link String}, {@link Void} 449 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 450 | * @param queryPairs refer to {@link QueryMap} 451 | * @param parts refer to {@link MultipartBody.Part} 452 | * @param a class 453 | * @return an instance of {@link Flowable} 454 | */ 455 | public Flowable postPartsWithParameters(Class target, String url, Map queryPairs, Map parts) { 456 | Validates.check(target, queryPairs, parts); 457 | return mDelegate.postPartsWithParameters(url, queryPairs, parts).flatMap(mProvider.converterFor(target)); 458 | } 459 | 460 | /** 461 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 462 | * {@link java.io.InputStream}, {@link String}, {@link Void} 463 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 464 | * @param queryPairs refer to {@link QueryMap} 465 | * @param headers refer to {@link HeaderMap} 466 | * @param parts refer to {@link MultipartBody.Part} 467 | * @param a class 468 | * @return an instance of {@link Flowable} 469 | */ 470 | public Flowable postPartsWithEntirety(Class target, String url, Map queryPairs, Map headers, Map parts) { 471 | Validates.check(target, queryPairs, headers, parts); 472 | return mDelegate.postPartsWithEntirety(url, queryPairs, headers, parts).flatMap(mProvider.converterFor(target)); 473 | } 474 | 475 | /** 476 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 477 | * {@link java.io.InputStream}, {@link String}, {@link Void} 478 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 479 | * @param body refer to {@link ResponseBody} 480 | * @param a class 481 | * @return an instance of {@link Flowable} 482 | */ 483 | public Flowable postBody(Class target, String url, RequestBody body) { 484 | ClassExclude.exclude(target); 485 | return mDelegate.postBody(url, body).flatMap(mProvider.converterFor(target)); 486 | } 487 | 488 | /** 489 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 490 | * {@link java.io.InputStream}, {@link String}, {@link Void} 491 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 492 | * @param headers refer to {@link HeaderMap} 493 | * @param body refer to {@link ResponseBody} 494 | * @param a class 495 | * @return an instance of {@link Flowable} 496 | */ 497 | public Flowable postBodyWithHeaders(Class target, String url, Map headers, RequestBody body) { 498 | Validates.check(target, headers); 499 | return mDelegate.postBodyWithHeaders(url, headers, body).flatMap(mProvider.converterFor(target)); 500 | } 501 | 502 | /** 503 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 504 | * {@link java.io.InputStream}, {@link String}, {@link Void} 505 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 506 | * @param queryPairs refer to {@link QueryMap} 507 | * @param body refer to {@link ResponseBody} 508 | * @param a class 509 | * @return an instance of {@link Flowable} 510 | */ 511 | public Flowable postBodyWithParameters(Class target, String url, Map queryPairs, RequestBody body) { 512 | Validates.check(target, queryPairs); 513 | return mDelegate.postBodyWithParameters(url, queryPairs, body).flatMap(mProvider.converterFor(target)); 514 | } 515 | 516 | /** 517 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader} 518 | * {@link java.io.InputStream}, {@link String}, {@link Void} 519 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)} 520 | * @param queryPairs refer to {@link QueryMap} 521 | * @param headers refer to {@link HeaderMap} 522 | * @param body refer to {@link ResponseBody} 523 | * @param a class 524 | * @return an instance of {@link Flowable} 525 | */ 526 | public Flowable postBodyWithEntirety(Class target, String url, Map queryPairs, Map headers, RequestBody body) { 527 | Validates.check(target, queryPairs, headers); 528 | return mDelegate.postBodyWithEntirety(url, queryPairs, headers, body).flatMap(mProvider.converterFor(target)); 529 | } 530 | 531 | public Builder newBuilder() { 532 | return new Builder(this); 533 | } 534 | 535 | public static class Builder { 536 | private Retrofit mRetrofit; 537 | private ApiService mDelegate; 538 | private Protocol mType; 539 | private Converter mConverter; 540 | private MapperProvider mProvider; 541 | 542 | public Builder() {} 543 | 544 | Builder(RxRequestor requestor) { 545 | this.mRetrofit = requestor.mRetrofit; 546 | this.mDelegate = requestor.mDelegate; 547 | this.mType = requestor.mType; 548 | this.mProvider = requestor.mProvider; 549 | this.mConverter = mProvider.getConverter(); 550 | } 551 | 552 | /** 553 | * @param retrofit {@link Retrofit} 554 | * @return an instance of {@link Builder} 555 | */ 556 | public Builder setRetrofit(Retrofit retrofit) { 557 | Objects.requireNonNull(retrofit, "retrofit == null"); 558 | 559 | boolean hasFactory = false; 560 | List factories = retrofit.callAdapterFactories(); 561 | for (CallAdapter.Factory factory : factories) { 562 | hasFactory = factory instanceof RxJava2CallAdapterFactory 563 | || RxJava2CallAdapterFactory.class.isAssignableFrom(factory.getClass()); 564 | if (hasFactory) break; 565 | } 566 | 567 | Objects.requireNonNull(hasFactory ? "" : null, "You must add RxJava2CallAdapterFactory for retrofit by Retrofit.Builder#addCallAdapterFactory()"); 568 | Objects.requireNonNull(retrofit.baseUrl(), "You must add a base url for retrofit by Retrofit.Builder#baseUrl()"); 569 | mRetrofit = retrofit; 570 | return this; 571 | } 572 | 573 | /** 574 | * @param type type of data, defer to {@link Protocol} 575 | * @return 576 | */ 577 | public Builder supportBy(Protocol type) { 578 | Objects.requireNonNull(type, "type == null"); 579 | mType = type; 580 | return this; 581 | } 582 | 583 | /** 584 | * Optional configuration 585 | * @param converter refer to {@link JsonConverter} or {@link XmlConverter} if custom yourself Converter 586 | * @return an instance of {@link Builder} 587 | */ 588 | public Builder customConverter(Converter converter) { 589 | Objects.requireNonNull(converter, "converter == null"); 590 | mConverter = converter; 591 | return this; 592 | } 593 | 594 | public RxRequestor build() { 595 | Objects.requireNonNull(mRetrofit, "mRetrofit == null, You must provider an instance of Retrofit by setRetrofit()"); 596 | Objects.requireNonNull(mType, "mType == null, You must provider an instance of Protocol by supportBy()"); 597 | mDelegate = mRetrofit.create(ApiService.class); 598 | mConverter = mConverter != null ? mConverter : mType == Protocol.JSON ? JsonConverter.create() : XmlConverter.createNonStrict(); 599 | mProvider = new MapperProvider(mConverter); 600 | return new RxRequestor(mRetrofit, mDelegate, mType, mProvider); 601 | } 602 | } 603 | } 604 | -------------------------------------------------------------------------------- /Requestor/src/main/java/com/artshell/requestor/XmlConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 artshell. https://github.com/artshell 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.artshell.requestor; 18 | 19 | import com.artshell.requestor.utils.Objects; 20 | 21 | import org.simpleframework.xml.Serializer; 22 | import org.simpleframework.xml.core.Persister; 23 | 24 | import java.io.IOException; 25 | 26 | import okhttp3.ResponseBody; 27 | 28 | /** 29 | * @author artshell on 11/01/2018 30 | */ 31 | 32 | public final class XmlConverter implements Converter { 33 | 34 | private final Serializer serializer; 35 | private final boolean strict; 36 | 37 | private XmlConverter(Serializer serializer, boolean strict) { 38 | this.serializer = serializer; 39 | this.strict = strict; 40 | } 41 | 42 | public static XmlConverter create() { 43 | return create(new Persister()); 44 | } 45 | 46 | public static XmlConverter create(Serializer serializer) { 47 | Objects.requireNonNull(serializer, "serializer == null"); 48 | return new XmlConverter(serializer, true); 49 | } 50 | 51 | public static XmlConverter createNonStrict() { 52 | return createNonStrict(new Persister()); 53 | } 54 | 55 | public static XmlConverter createNonStrict(Serializer serializer) { 56 | Objects.requireNonNull(serializer, "serializer == null"); 57 | return new XmlConverter(serializer, false); 58 | } 59 | 60 | @Override 61 | public T apply(Class target, ResponseBody body) throws IOException { 62 | try { 63 | T result = serializer.read(target, body.charStream(), strict); 64 | if (result == null) { 65 | throw new IllegalStateException("Could not deserialize body as " + target); 66 | } 67 | return result; 68 | } catch (Exception e) { 69 | throw new RuntimeException(e); 70 | } finally { 71 | body.close(); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Requestor/src/main/java/com/artshell/requestor/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 artshell. https://github.com/artshell 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @ParametersAreNonnullByDefault 18 | package com.artshell.requestor; 19 | 20 | import javax.annotation.ParametersAreNonnullByDefault; -------------------------------------------------------------------------------- /Requestor/src/main/java/com/artshell/requestor/utils/ClassExclude.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 artshell. https://github.com/artshell 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.artshell.requestor.utils; 18 | 19 | /** 20 | * Created by artshell on 2017/11/22. 21 | */ 22 | 23 | public class ClassExclude { 24 | public static void exclude(Class clz) { 25 | Objects.requireNonNull(clz, "clz == null"); 26 | if (clz == byte.class || clz == Byte.class || clz == byte[].class) { 27 | throw new IllegalStateException("You should use Byte[].class as parameterize type, eg: Flowable> post(Byte[].class ...)"); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Requestor/src/main/java/com/artshell/requestor/utils/Numbers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 artshell. https://github.com/artshell 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.artshell.requestor.utils; 18 | 19 | /** 20 | * Created by artshell on 2017/11/2. 21 | */ 22 | 23 | public class Numbers { 24 | 25 | private Numbers() { 26 | throw new AssertionError("No com.artshell.utils.common.Numbers instances for you!"); 27 | } 28 | 29 | /* ====== check for long ====== */ 30 | public static boolean requireNonNegative(long number) { 31 | if (number < 0) { 32 | throw new IllegalStateException(); 33 | } 34 | return true; 35 | } 36 | 37 | public static boolean requireNonNegative(long number, String tip) { 38 | if (number < 0) { 39 | throw new IllegalStateException(tip); 40 | } 41 | return true; 42 | } 43 | 44 | public static boolean requireNonNegative(long number, Provider tipProvider) { 45 | if (number < 0) { 46 | throw new IllegalStateException(tipProvider.get()); 47 | } 48 | return true; 49 | } 50 | 51 | /* ====== check for double ====== */ 52 | public static boolean requireNonNegative(double number) { 53 | if (number < 0) { 54 | throw new IllegalStateException(); 55 | } 56 | return true; 57 | } 58 | 59 | public static boolean requireNonNegative(double number, String tip) { 60 | if (number < 0) { 61 | throw new IllegalStateException(tip); 62 | } 63 | return true; 64 | } 65 | 66 | public static boolean requireNonNegative(double number, Provider tipProvider) { 67 | if (number < 0) { 68 | throw new IllegalStateException(tipProvider.get()); 69 | } 70 | return true; 71 | } 72 | 73 | /* ====== check for float ====== */ 74 | public static boolean requireNonNegative(float number) { 75 | if (number < 0) { 76 | throw new IllegalStateException(); 77 | } 78 | return true; 79 | } 80 | 81 | public static boolean requireNonNegative(float number, String tip) { 82 | if (number < 0) { 83 | throw new IllegalStateException(tip); 84 | } 85 | return true; 86 | } 87 | 88 | public static boolean requireNonNegative(float number, Provider tipProvider) { 89 | if (number < 0) { 90 | throw new IllegalStateException(tipProvider.get()); 91 | } 92 | return true; 93 | } 94 | 95 | /* ====== check for int ====== */ 96 | public static boolean requireNonNegative(int number) { 97 | if (number < 0) { 98 | throw new IllegalStateException(); 99 | } 100 | return true; 101 | } 102 | 103 | public static boolean requireNonNegative(int number, String tip) { 104 | if (number < 0) { 105 | throw new IllegalStateException(tip); 106 | } 107 | return true; 108 | } 109 | 110 | public static boolean requireNonNegative(int number, Provider tipProvider) { 111 | if (number < 0) { 112 | throw new IllegalStateException(tipProvider.get()); 113 | } 114 | return true; 115 | } 116 | 117 | public static boolean requireNonzero(int number) { 118 | if (number == 0) { 119 | throw new IllegalStateException(); 120 | } 121 | return true; 122 | } 123 | 124 | public static boolean requireNonzero(int number, String tip) { 125 | if (number == 0) { 126 | throw new IllegalStateException(tip); 127 | } 128 | return true; 129 | } 130 | 131 | public static boolean requireNonzero(int number, Provider tipProvider) { 132 | if (number == 0) { 133 | throw new IllegalStateException(tipProvider.get()); 134 | } 135 | return true; 136 | } 137 | 138 | /* ====== check for short ====== */ 139 | public static boolean requireNonNegative(short number) { 140 | if (number < 0) { 141 | throw new IllegalStateException(); 142 | } 143 | return true; 144 | } 145 | 146 | public static boolean requireNonNegative(short number, String tip) { 147 | if (number < 0) { 148 | throw new IllegalStateException(tip); 149 | } 150 | return true; 151 | } 152 | 153 | public static boolean requireNonNegative(short number, Provider tipProvider) { 154 | if (number < 0) { 155 | throw new IllegalStateException(tipProvider.get()); 156 | } 157 | return true; 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /Requestor/src/main/java/com/artshell/requestor/utils/Objects.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 artshell. https://github.com/artshell 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.artshell.requestor.utils; 18 | 19 | /** 20 | * Created by artshell on 2017/11/1. 21 | */ 22 | 23 | public class Objects { 24 | private Objects() { 25 | throw new AssertionError("No com.artshell.utils.common.Objects instances for you!"); 26 | } 27 | 28 | public static T requireNonNull(T obj) { 29 | if (obj == null) 30 | throw new NullPointerException(); 31 | return obj; 32 | } 33 | 34 | public static T requireNonNull(T obj, String tip) { 35 | if (obj == null) 36 | throw new NullPointerException(tip); 37 | return obj; 38 | } 39 | 40 | public static T requireNonNull(T obj, Provider tipProvider) { 41 | if (obj == null) 42 | throw new NullPointerException(tipProvider.get()); 43 | return obj; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Requestor/src/main/java/com/artshell/requestor/utils/Provider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 artshell. https://github.com/artshell 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.artshell.requestor.utils; 18 | 19 | /** 20 | * Created by artshell on 2017/11/1. 21 | */ 22 | 23 | public interface Provider { 24 | T get(); 25 | } 26 | -------------------------------------------------------------------------------- /Requestor/src/main/java/com/artshell/requestor/utils/Validates.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 artshell. https://github.com/artshell 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.artshell.requestor.utils; 18 | 19 | import java.util.Collection; 20 | import java.util.Map; 21 | 22 | /** 23 | * Created by artshell on 2017/11/23. 24 | */ 25 | 26 | public class Validates { 27 | 28 | public static void check(Class clazz, String[] queryNames) { 29 | ClassExclude.exclude(clazz); 30 | Objects.requireNonNull(queryNames, "queryNames == null"); 31 | Numbers.requireNonzero(queryNames.length, "queryNames.length == 0"); 32 | } 33 | 34 | public static void check(Class clazz, String[] queryNames, Map map) { 35 | ClassExclude.exclude(clazz); 36 | Objects.requireNonNull(queryNames, "queryNames == null"); 37 | Objects.requireNonNull(map, "map == null"); 38 | Numbers.requireNonzero(queryNames.length, "queryNames.length == 0"); 39 | Numbers.requireNonzero(map.size(), "map.size() == 0"); 40 | } 41 | 42 | public static void check(Class clazz, Map map) { 43 | ClassExclude.exclude(clazz); 44 | Objects.requireNonNull(map, "map == null"); 45 | Numbers.requireNonzero(map.size(), "map.size() == 0"); 46 | } 47 | 48 | public static void check(Class clazz, Map mapOne, Map mapTwo) { 49 | ClassExclude.exclude(clazz); 50 | Objects.requireNonNull(mapOne, "mapOne == null"); 51 | Objects.requireNonNull(mapTwo, "mapTwo == null"); 52 | Numbers.requireNonzero(mapOne.size(), "mapOne.size() == 0"); 53 | Numbers.requireNonzero(mapTwo.size(), "mapTwo.size() == 0"); 54 | } 55 | 56 | public static void check(Class clazz, Map mapOne, Map mapTwo, Map mapThree) { 57 | ClassExclude.exclude(clazz); 58 | Objects.requireNonNull(mapOne, "mapOne == null"); 59 | Objects.requireNonNull(mapTwo, "mapTwo == null"); 60 | Objects.requireNonNull(mapThree, "mapThree == null"); 61 | Numbers.requireNonzero(mapOne.size(), "mapOne.size() == 0"); 62 | Numbers.requireNonzero(mapTwo.size(), "mapTwo.size() == 0"); 63 | Numbers.requireNonzero(mapThree.size(), "mapThree.size() == 0"); 64 | } 65 | 66 | public static void check(Class clazz, Collection collect) { 67 | ClassExclude.exclude(clazz); 68 | Objects.requireNonNull(collect, "collect == null"); 69 | Numbers.requireNonzero(collect.size(), "collect.size() == 0"); 70 | } 71 | 72 | public static void check(Class clazz, Collection collect, Map map) { 73 | ClassExclude.exclude(clazz); 74 | Objects.requireNonNull(collect, "collect == null"); 75 | Objects.requireNonNull(map, "map == null"); 76 | Numbers.requireNonzero(collect.size(), "collect.size() == 0"); 77 | Numbers.requireNonzero(map.size(), "map.size() == 0"); 78 | } 79 | 80 | public static void check(Class clazz, Map map, Collection collect) { 81 | ClassExclude.exclude(clazz); 82 | Objects.requireNonNull(map, "map == null"); 83 | Objects.requireNonNull(collect, "collect == null"); 84 | Numbers.requireNonzero(map.size(), "map.size() == 0"); 85 | Numbers.requireNonzero(collect.size(), "collect.size() == 0"); 86 | } 87 | 88 | public static void check(Class clazz, Map mapOne, Map mapTwo, Collection collect) { 89 | ClassExclude.exclude(clazz); 90 | Objects.requireNonNull(mapOne, "mapOne == null"); 91 | Objects.requireNonNull(mapTwo, "mapTwo == null"); 92 | Objects.requireNonNull(collect, "collect == null"); 93 | Numbers.requireNonzero(mapOne.size(), "mapOne.size() == 0"); 94 | Numbers.requireNonzero(mapTwo.size(), "mapTwo.size() == 0"); 95 | Numbers.requireNonzero(collect.size(), "collect.size() == 0"); 96 | } 97 | 98 | public static void check(Class clazz, Object[] array) { 99 | ClassExclude.exclude(clazz); 100 | Objects.requireNonNull(array, "array == null"); 101 | Numbers.requireNonzero(array.length, "array.length == 0"); 102 | } 103 | 104 | public static void check(Class clazz, Map map, Object[] array) { 105 | ClassExclude.exclude(clazz); 106 | Objects.requireNonNull(map, "map == null"); 107 | Objects.requireNonNull(array, "array == null"); 108 | Numbers.requireNonzero(map.size(), "map.size() == 0"); 109 | Numbers.requireNonzero(array.length, "array.length == 0"); 110 | } 111 | 112 | public static void check(Class clazz, Map mapOne, Map mapTwo, Object[] array) { 113 | ClassExclude.exclude(clazz); 114 | Objects.requireNonNull(mapOne, "mapOne == null"); 115 | Objects.requireNonNull(mapTwo, "mapTwo == null"); 116 | Objects.requireNonNull(array, "array == null"); 117 | Numbers.requireNonzero(mapOne.size(), "mapOne.size() == 0"); 118 | Numbers.requireNonzero(mapTwo.size(), "mapTwo.size() == 0"); 119 | Numbers.requireNonzero(array.length, "array.length == 0"); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | applicationId "com.artshell.examples" 7 | minSdkVersion 14 8 | targetSdkVersion 26 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation 'com.android.support:appcompat-v7:26.1.0' 24 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 25 | implementation 'io.reactivex.rxjava2:rxjava:2.1.9' 26 | // implementation project(path: ':Requestor') 27 | 28 | testImplementation 'junit:junit:4.12' 29 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 30 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 31 | } 32 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/artshell/examples/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.artshell.examples; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * @see Testing documentation 15 | */ 16 | @RunWith(AndroidJUnit4.class) 17 | public class ExampleInstrumentedTest { 18 | @Test 19 | public void useAppContext() throws Exception { 20 | // Context of the app under test. 21 | Context appContext = InstrumentationRegistry.getTargetContext(); 22 | 23 | assertEquals("com.artshell.examples", appContext.getPackageName()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/artshell/examples/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.artshell.examples; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | 6 | public class MainActivity extends AppCompatActivity { 7 | 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | setContentView(R.layout.activity_main); 12 | // RxRequestor requestor = new RxRequestor.Builder().build(); 13 | // Flowable post = requestor.post(String.class, "http://baidu.com"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 11 | 16 | 21 | 26 | 31 | 36 | 41 | 46 | 51 | 56 | 61 | 66 | 71 | 76 | 81 | 86 | 91 | 96 | 101 | 106 | 111 | 116 | 121 | 126 | 131 | 136 | 141 | 146 | 151 | 156 | 161 | 166 | 171 | 172 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artshell/RxRequestor/e3cc3722f4f259441247841b46bd879e3e091923/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artshell/RxRequestor/e3cc3722f4f259441247841b46bd879e3e091923/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artshell/RxRequestor/e3cc3722f4f259441247841b46bd879e3e091923/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artshell/RxRequestor/e3cc3722f4f259441247841b46bd879e3e091923/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artshell/RxRequestor/e3cc3722f4f259441247841b46bd879e3e091923/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artshell/RxRequestor/e3cc3722f4f259441247841b46bd879e3e091923/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artshell/RxRequestor/e3cc3722f4f259441247841b46bd879e3e091923/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artshell/RxRequestor/e3cc3722f4f259441247841b46bd879e3e091923/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artshell/RxRequestor/e3cc3722f4f259441247841b46bd879e3e091923/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artshell/RxRequestor/e3cc3722f4f259441247841b46bd879e3e091923/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RxRequestor 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/artshell/examples/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.artshell.examples; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * @see Testing documentation 10 | */ 11 | public class ExampleUnitTest { 12 | @Test 13 | public void addition_isCorrect() throws Exception { 14 | assertEquals(4, 2 + 2); 15 | } 16 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | maven { 9 | url "https://plugins.gradle.org/m2/" 10 | } 11 | } 12 | dependencies { 13 | classpath 'com.android.tools.build:gradle:3.1.3' 14 | classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13' 15 | classpath 'net.ltgt.gradle:gradle-apt-plugin:0.13' 16 | classpath 'com.novoda:bintray-release:0.8.1' 17 | 18 | // NOTE: Do not place your application dependencies here; they belong 19 | // in the individual module build.gradle files 20 | } 21 | } 22 | 23 | allprojects { 24 | repositories { 25 | google() 26 | jcenter() 27 | } 28 | } 29 | 30 | task clean(type: Delete) { 31 | delete rootProject.buildDir 32 | } 33 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artshell/RxRequestor/e3cc3722f4f259441247841b46bd879e3e091923/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Nov 25 13:47:30 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':Requestor' 2 | --------------------------------------------------------------------------------