Awesome
<p align="center"><img src="https://raw.githubusercontent.com/liangjingkanji/Net/master/docs/img/logo.gif" width="300"/> <p align="center"><strong>不仅仅是网络请求的异步任务库</strong></p> <p align="center"><a href="http://liangjingkanji.github.io/Net/">使用文档</a> | <a href="https://github.com/liangjingkanji/document/blob/master/visit-pages.md">无法访问?</a> | <a href="https://liangjingkanji.github.io/document/">贡献代码</a> | <a href="https://github.com/liangjingkanji/Net/releases/latest/download/net-sample.apk">下载体验</a> </p> <p align="center"><img src="https://raw.githubusercontent.com/liangjingkanji/Net/master/docs/img/code-preview.png" width="400"/></p> <p align="center"> <a href="https://jitpack.io/#liangjingkanji/Net-okhttp3"><img src="https://jitpack.io/v/liangjingkanji/Net-okhttp3.svg"/></a> <img src="https://img.shields.io/badge/language-kotlin-orange.svg"/> <img src="https://img.shields.io/badge/license-MIT-blue"/> <a href="https://liangjingkanji.github.io/Net/api/"><img src="https://img.shields.io/badge/api-%E5%87%BD%E6%95%B0%E6%96%87%E6%A1%A3-red"/></a> <a href="https://raw.githubusercontent.com/liangjingkanji/liangjingkanji/master/img/group-qrcode.png"><img src="https://raw.githubusercontent.com/liangjingkanji/liangjingkanji/master/img/group.svg"/></a> <a href="http://liangjingkanji.github.io/Net/updates"><img src="https://img.shields.io/badge/updates-%E6%9B%B4%E6%96%B0%E6%97%A5%E5%BF%97-brightgreen"/></a> <a href="https://github.com/liangjingkanji/Net/blob/master/docs/issues.md"><img src="https://raw.githubusercontent.com/liangjingkanji/Net/master/docs/img/issues.svg"/></a> </p> <p align="center"><img src="https://raw.githubusercontent.com/liangjingkanji/Net/master/docs/img/preview.png" align="center" width="30%;" /></p> <br>Net是基于OkHttp/协程的非侵入式框架(可使用所有Api), 可升级OkHttp版本保持网络安全
<br>Welcome to international translation of this project's documents/notes, thank you for your support!
Net 1.x 版本使用RxJava实现 <br> Net 2.x 版本使用协程实现 <br> Net-okhttp3 Net3.x的Android低版本兼容库 <br> Net 3.x 版本使用协程实现, 可自定义OkHttp版本
<br> <p align="center"><strong>欢迎贡献代码/问题</strong></p>特点
- 开发效率No.1
- 专为Android而生
- OkHttp最佳实践
- 使用高性能Okio
- 支持OkHttp所有Api
- 随时升级OkHttp版本保证网络安全性
- 详细文档/低学习成本
- 永远保持社区维护
主要功能
- 协程并发(不会协程也可上手)
- 并发/串行/队列/同步请求
- 快速切换线程
- 全局错误处理(减少崩溃率)
- 协程作用域支持错误和结束回调
- 解析任何数据(json/protocol...)的转换器
- 泛型指定网络请求返回任何类型
- 自动处理下拉刷新和上拉加载
- 自动分页加载
- 自动显示缺省页
- 自动显示加载对话框
- 自动取消请求(生命周期)
- 自动吐司错误信息
- 自动捕获异常
- 支持ViewModel
- Request携带数据(setExtra/tagOf)
- Request支持Id/Group分组
- 日志信息输出(AndroidStudio插件/App通知栏)
- 并发请求返回最快请求结果
- 全局取消请求
- Https快速配置
- Cookie持久化管理
- 定时/限时请求
- 强制缓存模式/自定义缓存Key/缓存有效期/LRU缓存算法/缓存任何数据
- 先缓存后网络请求(预览模式)
- 内置超强轮询器(计时器)
- 监听上传/下载进度(使用时间, 每秒速度, 剩余时间...)
安装
支持Android 4.4 (API level 19)以上, 更低版本请拉取仓库修改minSdkVersion
后编译成aar使用
Project 的 settings.gradle 添加仓库
dependencyResolutionManagement {
repositories {
// ...
maven { url 'https://jitpack.io' }
}
}
Module 的 build.gradle 添加依赖框架
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0" // 协程(版本自定)
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0'
// 介于okhttp 3.12.x的更新情况,Net-okhttp3已内置okhttp3:3.12.13,无需再单独引入。
implementation 'com.github.liangjingkanji:Net-okhttp3:3.6.4'
<br>
Contribute
<img src="https://s2.loli.net/2022/04/24/qrYuJ5lg67kb31n.jpg" width="100"/>supported by JetBrains
License
MIT License
Copyright (c) 2023 劉強東
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.