Git Product home page Git Product logo

net's Introduction

不仅仅是网络请求的异步任务库

使用文档 | 备用访问


Android上不是最强网络任务库, 基于OkHttp/协程的非侵入式框架. 完美支持其原有函数和组件, 兼具Kotlin的优雅函数设计


Net 1.x 版本使用RxJava实现
Net 2.x 版本使用协程实现
Net 3.x 版本使用OkHttp+协程实现, 可指定其OkHttp版本


欢迎贡献代码/问题


主要功能

  • 开发速度No.1
  • 专为Android而生
  • 支持OkHttp所有功能/函数
  • 高内聚低耦合架构设计
  • DSL作用域编程
  • 协程并发(不会协程也可上手)
  • 并发/串行请求
  • 队列/同步请求
  • 快速切换线程
  • 全局错误处理
  • 解析JSON/Protocol
  • 支持任何数据解析的转换器
  • 网络请求返回指定泛型(String/Response/File/List/Map/Pair...)
  • 队列/同步请求返回Result
  • 自动处理下拉刷新和上拉加载
  • 自动处理分页加载
  • 自动缺省页
  • 自动处理生命周期(Activity/Fragment/ViewModel)
  • 自动处理加载对话框
  • 自动错误信息吐司
  • 自动异常捕获(定位到请求)
  • 请求标签(RequestTag)
  • Request支持Id/Group分组
  • 日志记录器(解决日志过长展示不清晰数据加密等问题, 比抓包更强大)
  • 并发请求返回最快请求结果
  • 全局取消请求/自动取消请求
  • 协程作用域支持错误和结束回调
  • 支持先强制读取缓存后网络请求二次刷新
  • 内置超强轮循器(倒计时)
  • 监听上传/下载进度信息(使用时间, 每秒速度, 剩余时间...)

安装

添加远程仓库根据创建项目的 Android Studio 版本有所不同

Android Studio Arctic Fox以下创建的项目 在项目根目录的 build.gradle 添加仓库

allprojects {
    repositories {
        // ...
        maven { url 'https://jitpack.io' }
    }
}

Android Studio Arctic Fox以上创建的项目 在项目根目录的 settings.gradle 添加仓库

dependencyResolutionManagement {
    repositories {
        // ...
        maven { url 'https://jitpack.io' }
    }
}

然后在 module 的 build.gradle 添加依赖框架

// 协程库(版本可自定)
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1'
// OkHttp(版本可自定, 要求OkHttp4以上版本)
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
// Net
implementation 'com.github.liangjingkanji:Net:3.1.1'

// 支持自动下拉刷新和缺省页的(可选)
implementation 'com.github.liangjingkanji:BRV:1.3.37'

如果你是在 Android 5 (API level 21)以下开发, 要求使用OkHttp3.x请使用: Net-okhttp3

Contribute

supported by JetBrains

License

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.

net's People

Contributors

hubrains avatar liangjingkanji avatar saltedfish-extreme avatar tomatowithegg avatar txca avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.