Net

Project Url: liangjingkanji/Net
Introduction: Android 最强网络请求库, 不仅仅是网络请求的异步框架, 支持 Kotlin/协程/并发/自动化/缓存/转换器的全能网络请求库
More: Author   ReportBugs   
Tags:

基于协程完善的 Android 网络请求库

使用文档 | 无法访问? | 贡献代码 | 下载体验


Net 是基于OkHttp/协程的非侵入式框架(可使用所有 Api), 可升级 OkHttp 版本保持网络安全


Welcome to international translation of this project's documents/notes, thank you for your support!

Net 1.x 版本使用 RxJava 实现
Net 2.x 版本使用协程实现
Net-okhttp3 Net3.x 的 Android 低版本兼容库
Net 3.x 版本使用协程实现, 可自定义 OkHttp 版本


欢迎贡献代码/问题

  • [x] 开发效率 No.1
  • [x] 专为 Android 而生
  • [x] OkHttp 最佳实践
  • [x] 使用高性能 Okio
  • [x] 支持 OkHttp 所有 Api
  • [x] 随时升级 OkHttp 版本保证网络安全性
  • [x] 详细文档/低学习成本
  • [x] 永远保持社区维护

主要功能

  • [x] 协程并发(不会协程也可上手)
  • [x] 并发/串行/队列/同步请求
  • [x] 快速切换线程
  • [x] 全局错误处理(减少崩溃率)
  • [x] 协程作用域支持错误和结束回调
  • [x] 解析任何数据(json/protocol...)的转换器
  • [x] 泛型指定网络请求返回任何类型
  • [x] 自动处理下拉刷新和上拉加载
  • [x] 自动分页加载
  • [x] 自动显示缺省页
  • [x] 自动显示加载对话框
  • [x] 自动取消请求(生命周期)
  • [x] 自动吐司错误信息
  • [x] 自动捕获异常
  • [x] 支持 ViewModel
  • [x] Request 携带数据(setExtra/tagOf)
  • [x] Request 支持 Id/Group 分组
  • [x] 日志信息输出(AndroidStudio 插件/App 通知栏)
  • [x] 并发请求返回最快请求结果
  • [x] 全局取消请求
  • [x] Https 快速配置
  • [x] Cookie 持久化管理
  • [x] 定时/限时请求
  • [x] 强制缓存模式/自定义缓存 Key/缓存有效期/LRU 缓存算法/缓存任何数据
  • [x] 先缓存后网络请求(预览模式)
  • [x] 内置超强轮询器(计时器)
  • [x] 监听上传/下载进度(使用时间, 每秒速度, 剩余时间...)


安装

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'
implementation 'com.squareup.okhttp3:okhttp:4.11.0' // 要求 OkHttp4 以上
implementation 'com.github.liangjingkanji:Net:3.6.4'

如果在 Android 5 (API level 21)以下开发, 请使用 Net-okhttp3

Contribute

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.
Apps
About Me
GitHub: Trinea
Facebook: Dev Tools