Repository: liujingxing/rxhttp
Branch: master
Commit: abf9696ae585
Files: 230
Total size: 760.0 KB
Directory structure:
gitextract_l14p6_sk/
├── .github/
│ └── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.md
├── README_zh.md
├── app/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── com/
│ │ └── example/
│ │ └── httpsender/
│ │ └── ExampleInstrumentedTest.java
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── example/
│ │ │ └── httpsender/
│ │ │ ├── AppHolder.java
│ │ │ ├── DownloadMultiAdapter.java
│ │ │ ├── ExceptionHelper.java
│ │ │ ├── LoggingEventListener.kt
│ │ │ ├── MainActivity.java
│ │ │ ├── MyViewModel.kt
│ │ │ ├── OnError.java
│ │ │ ├── Presenter.kt
│ │ │ ├── RxHttpManager.java
│ │ │ ├── Tip.java
│ │ │ ├── ToolBarActivity.java
│ │ │ ├── adapter/
│ │ │ │ └── FragmentPageAdapter.java
│ │ │ ├── entity/
│ │ │ │ ├── Article.java
│ │ │ │ ├── DownloadTask.java
│ │ │ │ ├── ErrorInfo.java
│ │ │ │ ├── Location.java
│ │ │ │ ├── Name.java
│ │ │ │ ├── NewsDataXml.java
│ │ │ │ ├── NewsXml.java
│ │ │ │ ├── PageList.java
│ │ │ │ ├── Response.java
│ │ │ │ ├── Url.kt
│ │ │ │ └── User.java
│ │ │ ├── fragment/
│ │ │ │ ├── AwaitFragment.kt
│ │ │ │ ├── BaseFragment.kt
│ │ │ │ ├── FlowFragment.kt
│ │ │ │ ├── MultiDownloadFragment.java
│ │ │ │ └── RxJavaFragment.kt
│ │ │ ├── interceptor/
│ │ │ │ ├── RedirectInterceptor.java
│ │ │ │ └── TokenInterceptor.java
│ │ │ ├── kt/
│ │ │ │ ├── Activity.kt
│ │ │ │ ├── KotlinExtensions.kt
│ │ │ │ └── Uri.kt
│ │ │ ├── param/
│ │ │ │ ├── GetEncryptParam.java
│ │ │ │ ├── PostEncryptFormParam.java
│ │ │ │ ├── PostEncryptJsonParam.kt
│ │ │ │ └── PostEncryptJsonParam1.java
│ │ │ ├── parser/
│ │ │ │ ├── Android10DownloadFactory.kt
│ │ │ │ ├── ResponseParser.kt
│ │ │ │ └── java/
│ │ │ │ ├── DoubleTypeParser.java
│ │ │ │ └── ResponseParser.java
│ │ │ ├── utils/
│ │ │ │ └── Preferences.java
│ │ │ ├── view/
│ │ │ │ └── ScaleTransitionPagerTitleView.java
│ │ │ └── vm/
│ │ │ ├── MultiTaskAwaitDownloader.kt
│ │ │ ├── MultiTaskDownloader.kt
│ │ │ └── MultiTaskFlowDownloader.kt
│ │ └── res/
│ │ ├── drawable/
│ │ │ └── ic_launcher_background.xml
│ │ ├── drawable-v24/
│ │ │ └── ic_launcher_foreground.xml
│ │ ├── layout/
│ │ │ ├── await_fragment.xml
│ │ │ ├── download_multi_adapter.xml
│ │ │ ├── flow_fragment.xml
│ │ │ ├── main_activity.xml
│ │ │ ├── multi_download_fragment.xml
│ │ │ ├── rxjava_fragment.xml
│ │ │ └── toolbar_activity.xml
│ │ ├── menu/
│ │ │ └── download.xml
│ │ ├── mipmap-anydpi-v26/
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ ├── values/
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ ├── styles.xml
│ │ │ └── themes.xml
│ │ └── xml/
│ │ └── network_config.xml
│ └── test/
│ └── java/
│ ├── com/
│ │ └── rxhttp/
│ │ └── compiler/
│ │ ├── AbstractTestSymbolProcessor.kt
│ │ ├── KspProcessorTest.kt
│ │ ├── TestParser1.kt
│ │ └── TestParser2.kt
│ └── com.example.httpsender/
│ └── AsyncTest.java
├── build.gradle
├── gradle/
│ ├── libs.versions.toml
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── jitpack.yml
├── maven.gradle
├── maven_dependency.md
├── rxhttp/
│ ├── build.gradle
│ └── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── rxhttp/
│ │ │ ├── AwaitTransform.kt
│ │ │ ├── CallFactoryExt.kt
│ │ │ ├── Platform.java
│ │ │ ├── RxHttpPlugins.java
│ │ │ └── wrapper/
│ │ │ ├── CallFactory.kt
│ │ │ ├── OkHttpCompat.java
│ │ │ ├── cache/
│ │ │ │ ├── CacheManager.java
│ │ │ │ ├── CacheMode.java
│ │ │ │ ├── CacheStrategy.java
│ │ │ │ ├── HeadersVary.java
│ │ │ │ └── InternalCache.java
│ │ │ ├── callback/
│ │ │ │ ├── Consumer.java
│ │ │ │ ├── Function.java
│ │ │ │ ├── IConverter.java
│ │ │ │ ├── JsonConverter.java
│ │ │ │ ├── OutputStreamFactory.kt
│ │ │ │ ├── ProgressCallback.java
│ │ │ │ └── ProgressCallbackHelper.kt
│ │ │ ├── converter/
│ │ │ │ └── GsonConverter.java
│ │ │ ├── cookie/
│ │ │ │ ├── CookieStore.java
│ │ │ │ └── ICookieJar.java
│ │ │ ├── coroutines/
│ │ │ │ ├── Await.kt
│ │ │ │ ├── CallAwait.kt
│ │ │ │ └── CallFlow.kt
│ │ │ ├── entity/
│ │ │ │ ├── DownloadOffSize.java
│ │ │ │ ├── EmptyResponseBody.java
│ │ │ │ ├── ExpandOutputStream.java
│ │ │ │ ├── FileRequestBody.java
│ │ │ │ ├── KeyValuePair.java
│ │ │ │ ├── OkResponse.java
│ │ │ │ ├── ParameterizedTypeImpl.java
│ │ │ │ ├── Progress.java
│ │ │ │ ├── UpFile.java
│ │ │ │ └── UriRequestBody.java
│ │ │ ├── exception/
│ │ │ │ ├── CacheReadFailedException.java
│ │ │ │ ├── HttpStatusCodeException.java
│ │ │ │ ├── ParseException.java
│ │ │ │ └── ProxyException.java
│ │ │ ├── intercept/
│ │ │ │ ├── CacheInterceptor.kt
│ │ │ │ ├── LogInterceptor.kt
│ │ │ │ └── RangeInterceptor.java
│ │ │ ├── param/
│ │ │ │ ├── AbstractBodyParam.java
│ │ │ │ ├── AbstractParam.java
│ │ │ │ ├── BodyParam.kt
│ │ │ │ ├── FormParam.java
│ │ │ │ ├── ICache.java
│ │ │ │ ├── IHeaders.java
│ │ │ │ ├── IParam.java
│ │ │ │ ├── IPart.java
│ │ │ │ ├── IRequest.java
│ │ │ │ ├── JsonArrayParam.java
│ │ │ │ ├── JsonParam.java
│ │ │ │ ├── Method.java
│ │ │ │ ├── NoBodyParam.java
│ │ │ │ └── Param.java
│ │ │ ├── parse/
│ │ │ │ ├── OkResponseParser.java
│ │ │ │ ├── Parser.java
│ │ │ │ ├── SmartParser.java
│ │ │ │ ├── StreamParser.kt
│ │ │ │ └── TypeParser.java
│ │ │ ├── progress/
│ │ │ │ └── ProgressRequestBody.java
│ │ │ ├── ssl/
│ │ │ │ └── HttpsUtils.java
│ │ │ └── utils/
│ │ │ ├── BuildUtil.java
│ │ │ ├── CacheUtil.java
│ │ │ ├── Converter.java
│ │ │ ├── Converter.kt
│ │ │ ├── GsonUtil.java
│ │ │ ├── JSONStringer.java
│ │ │ ├── Json.kt
│ │ │ ├── LogTime.java
│ │ │ ├── LogUtil.java
│ │ │ ├── PathEncoder.kt
│ │ │ ├── Speeder.kt
│ │ │ ├── TypeUtil.java
│ │ │ ├── Uri.kt
│ │ │ └── Utils.kt
│ │ └── java-templates/
│ │ └── rxhttp/
│ │ └── internal/
│ │ └── RxHttpVersion.kt
│ └── test/
│ └── java/
│ └── rxhttp/
│ └── wrapper/
│ └── entity/
│ └── ParameterizedTypeImplTest.java
├── rxhttp-annotation/
│ ├── build.gradle
│ └── src/
│ └── main/
│ └── java/
│ └── rxhttp/
│ └── wrapper/
│ └── annotation/
│ ├── Converter.java
│ ├── DefaultDomain.java
│ ├── Domain.java
│ ├── OkClient.java
│ ├── Param.java
│ └── Parser.java
├── rxhttp-compiler/
│ ├── build.gradle
│ └── src/
│ └── main/
│ ├── java/
│ │ └── com/
│ │ └── rxhttp/
│ │ └── compiler/
│ │ ├── Constants.kt
│ │ ├── KaptProcessor.kt
│ │ ├── KspProcessor.kt
│ │ ├── RxJavaVersion.kt
│ │ ├── Variables.kt
│ │ ├── common/
│ │ │ ├── KtUtil.kt
│ │ │ ├── ObservableUtil.kt
│ │ │ └── StringUtil.kt
│ │ ├── kapt/
│ │ │ ├── BaseRxHttpGenerator.kt
│ │ │ ├── ClassHelper.kt
│ │ │ ├── ConverterVisitor.kt
│ │ │ ├── DefaultDomainVisitor.kt
│ │ │ ├── DomainVisitor.kt
│ │ │ ├── OkClientVisitor.kt
│ │ │ ├── ParamsVisitor.kt
│ │ │ ├── ParserVisitor.kt
│ │ │ ├── RxHttpExtensions.kt
│ │ │ ├── RxHttpGenerator.kt
│ │ │ ├── RxHttpWrapper.kt
│ │ │ ├── Utils.kt
│ │ │ └── maven/
│ │ │ ├── KaptRxJava2Processor.kt
│ │ │ └── KaptRxJava3Processor.kt
│ │ └── ksp/
│ │ ├── BaseRxHttpGenerator.kt
│ │ ├── ClassHelper.kt
│ │ ├── ConverterVisitor.kt
│ │ ├── DefaultDomainVisitor.kt
│ │ ├── DomainVisitor.kt
│ │ ├── KClassHelper.kt
│ │ ├── Ksp.kt
│ │ ├── OkClientVisitor.kt
│ │ ├── ParamsVisitor.kt
│ │ ├── ParserVisitor.kt
│ │ ├── RxHttpExtensions.kt
│ │ ├── RxHttpGenerator.kt
│ │ └── RxHttpWrapper.kt
│ └── resources/
│ └── META-INF/
│ ├── gradle/
│ │ └── incremental.annotation.processors
│ └── services/
│ ├── com.google.devtools.ksp.processing.SymbolProcessorProvider
│ └── javax.annotation.processing.Processor
├── rxhttp-converter/
│ ├── converter-fastjson/
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ └── src/
│ │ └── main/
│ │ └── java/
│ │ └── rxhttp/
│ │ └── wrapper/
│ │ └── converter/
│ │ └── FastJsonConverter.java
│ ├── converter-jackson/
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ └── src/
│ │ └── main/
│ │ └── java/
│ │ └── rxhttp/
│ │ └── wrapper/
│ │ └── converter/
│ │ └── JacksonConverter.java
│ ├── converter-moshi/
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ └── src/
│ │ └── main/
│ │ └── java/
│ │ └── rxhttp/
│ │ └── wrapper/
│ │ └── converter/
│ │ └── MoshiConverter.java
│ ├── converter-protobuf/
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ └── src/
│ │ └── main/
│ │ └── java/
│ │ └── rxhttp/
│ │ └── wrapper/
│ │ └── converter/
│ │ └── ProtoConverter.java
│ ├── converter-serialization/
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ └── src/
│ │ └── main/
│ │ └── java/
│ │ └── rxhttp/
│ │ └── wrapper/
│ │ └── converter/
│ │ └── SerializationConverter.kt
│ └── converter-simplexml/
│ ├── .gitignore
│ ├── build.gradle
│ └── src/
│ └── main/
│ └── java/
│ └── rxhttp/
│ └── wrapper/
│ └── converter/
│ └── XmlConverter.java
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/fa6d3941c2c944e59831640fa0ece60d~tplv-k3u1fbpfcp-watermark.image
================================================
FILE: .gitignore
================================================
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
.idea/codeStyles/Project.xml
.idea/misc.xml
.idea/modules.xml
.idea/runConfigurations.xml
.idea/vcs.xml
.idea
gradlew.bat
gradlew
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
# RxHttp
English | [中文文档](https://github.com/liujingxing/rxhttp/blob/master/README_zh.md)
[](https://jitpack.io/#liujingxing/rxhttp)
# [(RxHttp 3.0 更新指南,升级必看)](https://github.com/liujingxing/rxhttp/wiki/RxHttp-3.0-%E6%9B%B4%E6%96%B0%E6%8C%87%E5%8D%97%EF%BC%8C%E5%8D%87%E7%BA%A7%E5%BF%85%E7%9C%8B)
# 使用RxHttp的知名App
抖音旗下***汽水音乐***(app v18.1.0 设置/关于汽水音乐/开源软件声明 可查)
# A type-safe HTTP client for Android. Written based on OkHttp

| Await | Flow | RxJava (Kotlin) |
RxJava (Java) |
|---|---|---|---|
|
```java
//await return User
//tryAwait return User?
val user = RxHttp.get("/server/..")
.add("key", "value")
.toAwait |
```java
RxHttp.get("/server/..")
.add("key", "value")
.toFlow |
```java
RxHttp.get("/server/..")
.add("key", "value")
.toObservable |
```java RxHttp.get("/server/..") .add("key", "value") .toObservable(User.class) .subscribe(user - > { //Success }, throwable -> { //Failure }) ``` |
| Await | Flow | RxJava (Kotlin) |
RxJava (Java) |
|---|---|---|---|
|
```java
//同步式写法
val user = RxHttp.get("/server/..")
.add("key", "value")
.toAwait |
```java
RxHttp.get("/server/..")
.add("key", "value")
.toFlow |
```java
RxHttp.get("/server/..")
.add("key", "value")
.toObservable |
```java RxHttp.get("/server/..") .add("key", "value") .toObservable(User.class) .subscribe(user - > { //成功回调 }, throwable -> { //异常回调 }) ``` |
> 更多功能,请[下载apk](https://github.com/liujingxing/rxhttp/blob/master/screen/app-debug.apk)体验
# 7、Donations
如果它对你帮助很大,并且你很想支持库的后续开发和维护,那么你可以扫下方二维码随意打赏我,就当是请我喝杯咖啡或是啤酒,开源不易,感激不尽

# Licenses
```
Copyright 2019 liujingxing
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
================================================
FILE: app/.gitignore
================================================
#/build
/release
================================================
FILE: app/build.gradle
================================================
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
id 'kotlin-kapt'
id 'com.google.devtools.ksp' version libs.versions.ksp
}
android {
namespace 'com.example.httpsender'
compileSdk 35
defaultConfig {
applicationId "com.example.rxhttp"
minSdk 23
targetSdk 35
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
buildFeatures {
buildConfig = true
dataBinding = true
}
lint {
abortOnError false
checkReleaseBuilds false
}
}
ksp {
arg("rxhttp_rxjava", libs.versions.rxjava.get())
// arg("rxhttp_package", "rxhttp")
}
kapt {
arguments {
arg("rxhttp_rxjava", libs.versions.rxjava.get()) //可传入rxjava2、rxjava3或具体版本号,如 3.1.1
// arg("rxhttp_package", "rxhttp") //设置RxHttp相关类的包名,多module依赖时,需要配置不同的包名
}
}
dependencies {
implementation libs.androidx.multidex
implementation libs.androidx.appcompat
implementation libs.androidx.recyclerview
implementation libs.androidx.constraintlayout
implementation libs.github.magicindicator
implementation libs.androidx.fragment.ktx
implementation libs.androidx.lifecycle.runtime.ktx
implementation libs.androidx.lifecycle.livedata.ktx
implementation libs.androidx.lifecycle.viewmodel.ktx
implementation libs.androidx.lifecycle.service
implementation projects.rxhttp
ksp projects.rxhttpCompiler
// kapt projects.rxhttpCompiler
implementation libs.okhttp
testImplementation libs.mockwebserver
// implementation libs.rxhttp
// ksp libs.rxhttp.compiler
// kapt libs.rxhttp.compiler
//管理RxJava及生命周期,Activity/Fragment 销毁,自动关闭未完成的请求
implementation libs.github.rxlife.rxjava3
implementation libs.rxandroid
implementation libs.rxjava
// implementation libs.rxhttp.converter.serialization
// implementation libs.rxhttp.converter.fastjson
// implementation libs.rxhttp.converter.jackson
// implementation libs.rxhttp.converter.moshi
// implementation libs.rxhttp.converter.protobuf
// implementation libs.rxhttp.converter.simplexml
implementation projects.rxhttpConverter.converterSerialization
implementation projects.rxhttpConverter.converterFastjson
implementation projects.rxhttpConverter.converterSimplexml
implementation projects.rxhttpConverter.converterProtobuf
implementation projects.rxhttpConverter.converterMoshi
implementation projects.rxhttpConverter.converterJackson
testImplementation libs.junit
androidTestImplementation libs.androidx.junit
androidTestImplementation libs.androidx.espresso.core
implementation libs.utilcodex
testImplementation libs.kotlin.compile.testing.ksp
testImplementation libs.kotlinpoet
testImplementation libs.kotlinpoet.ksp
testImplementation projects.rxhttpCompiler
}
================================================
FILE: app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keepclassmembers class com.example.httpsender.entity.** {
* 如Java环境中调用
* toObservable(new ResponseParser
* 注:此构造方法一定要用protected关键字修饰,否则调用此构造方法将拿不到泛型类型
*/
protected ResponseParser() {
super();
}
/**
* 该解析器会生成以下系列方法,前3个kotlin环境调用,后4个Java环境调用,所有方法内部均会调用本构造方法
* toFlowResponse
* Flow/Await下 toXxxResponse The initialization time may vary depending on the journal file size and the current actual
* cache size. The application needs to be aware of calling this function during the
* initialization phase and preferably in a background worker thread.
*
* Note that if the application chooses to not call this method to initialize the cache. By
* default, the okhttp will perform lazy initialization upon the first usage of the cache.
*
* @throws IOException 初始化失败
*/
public void initialize() throws IOException {
cache.initialize();
}
/**
* Closes the cache and deletes all of its stored values. This will delete all files in the cache
* directory including files that weren't created by the cache.
*/
private void delete() throws IOException {
cache.delete();
}
/**
* Deletes all values stored in the cache. In-flight writes to the cache will complete normally,
* but the corresponding responses will not be stored.
*/
private void evictAll() throws IOException {
cache.evictAll();
}
public Iterator A typical HTTPS file looks like this:
* Next is the response status line, followed by the number of HTTP response header lines,
* followed by those lines.
*
* HTTPS responses also contain SSL session information. This begins with a blank line, and
* then a line containing the cipher suite. Next is the length of the peer certificate chain.
* These certificates are base64-encoded and appear each on their own line. The next line
* contains the length of the local certificate chain. These certificates are also
* base64-encoded and appear each on their own line. A length of -1 is used to encode a null
* array. The last line is optional. If present, it contains the TLS version.
*/
Entry(Source in) throws IOException {
try {
BufferedSource source = Okio.buffer(in);
url = source.readUtf8LineStrict();
requestMethod = source.readUtf8LineStrict();
Headers.Builder varyHeadersBuilder = new Headers.Builder();
int varyRequestHeaderLineCount = readInt(source);
for (int i = 0; i < varyRequestHeaderLineCount; i++) {
addUnsafeNonAscii(varyHeadersBuilder, source.readUtf8LineStrict());
}
varyHeaders = varyHeadersBuilder.build();
StatusLine statusLine = OkHttpCompat.parse(source.readUtf8LineStrict());
protocol = statusLine.protocol;
code = statusLine.code;
message = statusLine.message;
Headers.Builder responseHeadersBuilder = new Headers.Builder();
int responseHeaderLineCount = readInt(source);
for (int i = 0; i < responseHeaderLineCount; i++) {
addUnsafeNonAscii(responseHeadersBuilder, source.readUtf8LineStrict());
}
String sendRequestMillisString = responseHeadersBuilder.get(SENT_MILLIS);
String receivedResponseMillisString = responseHeadersBuilder.get(RECEIVED_MILLIS);
responseHeadersBuilder.removeAll(SENT_MILLIS);
responseHeadersBuilder.removeAll(RECEIVED_MILLIS);
sentRequestMillis = sendRequestMillisString != null
? Long.parseLong(sendRequestMillisString)
: 0L;
receivedResponseMillis = receivedResponseMillisString != null
? Long.parseLong(receivedResponseMillisString)
: 0L;
responseHeaders = responseHeadersBuilder.build();
if (isHttps()) {
String blank = source.readUtf8LineStrict();
if (blank.length() > 0) {
throw new IOException("expected \"\" but was \"" + blank + "\"");
}
String cipherSuiteString = source.readUtf8LineStrict();
CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
List>>(){})
* 等价与kotlin环境下的
* toObservableResponse
>>()
*
> observer = new TestObserver<>();
RxHttp.postForm("/test")
.toObservableList(int.class)
.subscribe(observer);
assertFalse(observer.await(1, SECONDS)); //等待1s后返回数据
server.enqueue(new MockResponse()
.setBody("[1,2,3,4]")
.throttleBody(1, 100, TimeUnit.MILLISECONDS) //模拟网速慢,每100毫秒传递1个字节
);
assertTrue(observer.await(2, SECONDS)); //等待读取Body
observer.assertComplete();
}
@Test
public void successOKResponse() throws InterruptedException {
Type type = ParameterizedTypeImpl.get(OkResponse.class, User.class);
TestObserver
> = toFlow()
/**
* @param destPath Local storage path
* @param append is append download
*/
fun CallFactory.toDownloadFlow(
destPath: String,
append: Boolean = false,
): CallFlow
{@code
* http://google.com/foo
* GET
* 2
* Accept-Language: fr-CA
* Accept-Charset: UTF-8
* HTTP/1.1 200 OK
* 3
* Content-Type: image/png
* Content-Length: 100
* RxHttpCache-Control: max-age=600
* }
*
* {@code
* https://google.com/foo
* GET
* 2
* Accept-Language: fr-CA
* Accept-Charset: UTF-8
* HTTP/1.1 200 OK
* 3
* Content-Type: image/png
* Content-Length: 100
* Cache-Control: max-age=600
*
* AES_256_WITH_MD5
* 2
* base64-encoded peerCertificate[0]
* base64-encoded peerCertificate[1]
* -1
* TLSv1.2
* }
* The file is newline separated. The first two lines are the URL and the request method. Next
* is the number of HTTP Vary request header lines, followed by those lines.
*
*