From e44b87ae12694b790ee756df316b835ab72976bc Mon Sep 17 00:00:00 2001 From: liujingxing <327744707@qq.com> Date: Sun, 17 Oct 2021 19:54:59 +0800 Subject: [PATCH] Update README.md --- README.md | 143 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 109 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 9b75c1c0..90611b7c 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,9 @@ A type-safe HTTP client for Android. Written based on OkHttp ### Required -Add it to your build.gradle with: +
+1、Add jitpack to your build.gradle + ```java allprojects { repositories { @@ -31,64 +33,137 @@ allprojects { } } ``` -and: - +
+
+2、Java 8 or higher + ```java -//Must be used when using kapt -apply plugin: 'kotlin-kapt' - android { - //Java 8 or higher compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } - +``` +
+
+3、Add RxHttp dependency + +```java +//Must be used when using kapt +apply plugin: 'kotlin-kapt' dependencies { - implementation 'com.squareup.okhttp3:okhttp:4.9.1' + implementation 'com.squareup.okhttp3:okhttp:4.9.1' implementation 'com.github.liujingxing.rxhttp:rxhttp:2.7.0' //Use the annotationProcessor instead of kapt, if you use Java - kapt 'com.github.liujingxing.rxhttp:rxhttp-compiler:2.7.0' + kapt 'com.github.liujingxing.rxhttp:rxhttp-compiler:2.7.0' } ``` +
### Optional + +### 1、Coverter +```java +implementation 'com.github.liujingxing.rxhttp:converter-fastjson:2.7.0' +implementation 'com.github.liujingxing.rxhttp:converter-jackson:2.7.0' +implementation 'com.github.liujingxing.rxhttp:converter-moshi:2.7.0' +implementation 'com.github.liujingxing.rxhttp:converter-protobuf:2.7.0' +implementation 'com.github.liujingxing.rxhttp:converter-simplexml:2.7.0' +``` + +### 2、RxJava +
+RxHttp + RxJava3 + + ```java +implementation 'io.reactivex.rxjava3:rxjava:3.1.1' +implementation 'io.reactivex.rxjava3:rxandroid:3.0.0' +implementation 'com.github.liujingxing.rxlife:rxlife-rxjava3:2.2.1' //RxJava3, Automatic close request +``` + +
+
+RxHttp + RxJava2 + +```java +implementation 'io.reactivex.rxjava2:rxjava:2.2.8' +implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' +implementation 'com.github.liujingxing.rxlife:rxlife-rxjava2:2.2.1' //RxJava2, Automatic close request +``` +
+
+Kapt passes the RxJava version + ```java android { kapt { arguments { - //Pass in the RxJava version name if you use RxJava arg("rxhttp_rxjava", "3.1.1") - arg("rxhttp_package", "rxhttp") //Specifies the RxHttp class package } } - //If you uses Java, pass the parameters using javaCompileOptions in defaultConfig - annotationProcessorOptions { - arguments = [ - rxhttp_rxjava: '3.1.1', - rxhttp_package: 'rxhttp' - ] +} +``` + +
+ +
+javaCompileOptions passes the RxJava version + +```java +android { + defaultConfig { + javaCompileOptions { + annotationProcessorOptions { + arguments = [ + rxhttp_rxjava: '3.1.1', + ] + } + } } } -dependencies { - //rxjava2 (RxJava2/Rxjava3 select one) - implementation 'io.reactivex.rxjava2:rxjava:2.2.8' - implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' - implementation 'com.github.liujingxing.rxlife:rxlife-rxjava2:2.2.1' //RxJava2, Automatic close request - - //rxjava3 - implementation 'io.reactivex.rxjava3:rxjava:3.1.1' - implementation 'io.reactivex.rxjava3:rxandroid:3.0.0' - implementation 'com.github.liujingxing.rxlife:rxlife-rxjava3:2.2.1' //RxJava3, Automatic close request - - implementation 'com.github.liujingxing.rxhttp:converter-fastjson:2.7.0' - implementation 'com.github.liujingxing.rxhttp:converter-jackson:2.7.0' - implementation 'com.github.liujingxing.rxhttp:converter-moshi:2.7.0' - implementation 'com.github.liujingxing.rxhttp:converter-protobuf:2.7.0' - implementation 'com.github.liujingxing.rxhttp:converter-simplexml:2.7.0' +``` + +
+ +`kapt/javaCompileOptions select one,With Kapt, if you integrate kotlin` + +### 3、set RxHttp class package name +
+kapt pass package name + +```java +android { + kapt { + arguments { + arg("rxhttp_package", "rxhttp.xxx") + } + } } ``` + +
+ +
+javaCompileOptions pass package name + +```java +android { + defaultConfig { + javaCompileOptions { + annotationProcessorOptions { + arguments = [ + rxhttp_package: 'rxhttp.xxx' + ] + } + } + } +} +``` +
+ +`kapt/javaCompileOptions select one,With Kapt, if you integrate kotlin` + **Finally, rebuild the project, which is necessary**