ランキングに戻る

liangjingkanji/Net

Kotlinliangjingkanji.github.io/Net/

[永久维护] Android 基于协程/OkHttp网络请求工具

okhttp
スター成長
スター
2k
フォーク
239
週間成長
Issue
14
1k2k
2019年10月2022年1月2024年4月2026年7月
README

中文 | English

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

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


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


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


欢迎贡献代码/问题

特点

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

主要功能

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

安装

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.7.0'

如果在 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.
関連リポジトリ
jeasonlzy/okhttp-OkGo

OkGo - 3.0 震撼来袭,该库是基于 Http 协议,封装了 OkHttp 的网络请求框架,比 Retrofit 更简单易用,支持 RxJava,RxJava2,支持自定义缓存,支持批量断点下载管理和批量上传管理功能

JavaMavenApache License 2.0okhttpokgo
10.6k2.5k
goldze/MVVMHabit

👕基于谷歌最新AAC架构,MVVM设计模式的一套快速开发库,整合Okhttp+RxJava+Retrofit+Glide等主流模块,满足日常开发需求。使用该框架可以快速开发一个高质量、易维护的Android应用。

JavaMavenApache License 2.0mvvmdatabinding
7.7k1.7k
getActivity/AndroidProject

Android 技术中台,但愿人长久,搬砖不再有

JavaMavenApache License 2.0androidmvp
6.9k1.4k
amitshekhariitbhu/Fast-Android-Networking

🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀

JavaMavenApache License 2.0httpnetwork
outcomeschool.com
5.9k977
TommyLemon/Android-ZBLibrary

🔥 Android MVP 快速开发框架,做国内 「示例最全面」「注释最详细」「使用最简单」「代码最严谨」的 Android 开源 UI 框架。 🔥 An Android MVP Framework with many demos, detailed documents, simple usages and strict codes.

JavaMavenApache License 2.0zxingokhttp
5.6k1.4k
ChuckerTeam/chucker

🔎 An HTTP inspector for Android & OkHTTP (like Charles but on device)

KotlinApache License 2.0okhttpinterceptor
4.5k459
yanzhenjie/NoHttp

:lemon: Android实现Http标准协议框架,支持多种缓存模式,底层可动态切换OkHttp、URLConnection。

JavaMavenApache License 2.0nohttpokhttp
github.com/yanzhenjie/NoHttp
3.7k847
JessYanCoding/ProgressManager

⏳ Listen the progress of downloading and uploading in Okhttp, compatible Retrofit and Glide (一行代码即可监听 App 中所有网络链接的上传以及下载进度, 包括 Glide 的图片加载进度).

JavaMavenApache License 2.0okhttpglide
2.7k289
panpf/sketch

Image loading library designed for Compose Multiplatform and Android View. Supports loading Image, GIF, SVG, Video thumbnails from the network, local, resources, and photo albums.

KotlinApache License 2.0androidgif
panpf.github.io/sketch/
2.4k325
JessYanCoding/RetrofitUrlManager

🔮 Let Retrofit support multiple baseUrl and can be change the baseUrl at runtime (以最简洁的 Api 让 Retrofit 同时支持多个 BaseUrl 以及动态改变 BaseUrl).

JavaMavenApache License 2.0retrofit2baseurl
2.2k306
tonyofrancis/Fetch

The best file downloader library for Android

KotlinApache License 2.0android-developmentandroid
meta.stackoverflow.com/tags/fetch2
1.8k358
getActivity/AndroidProject-Kotlin

Android 技术中台 Kotlin 版本,但愿人长久,搬砖不再有

KotlinApache License 2.0androidkotlin
1.7k319