Skip to content

Commit

Permalink
docs: 使用文档
Browse files Browse the repository at this point in the history
  • Loading branch information
liangjingkanji committed Aug 2, 2023
1 parent 5b9ff2a commit b273d62
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<img src="https://img.shields.io/badge/language-kotlin-orange.svg"/>
<img src="https://img.shields.io/badge/license-Apache-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>
<img src="https://raw.githubusercontent.com/liangjingkanji/liangjingkanji/master/img/group.svg"/>
<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>
Expand Down
27 changes: 19 additions & 8 deletions docs/issues.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
## 常见问题

- [networkSecurityConfig导致无法打包](https://github.com/liangjingkanji/Net/issues/57)
- [没有我需要的请求参数类型](https://github.com/liangjingkanji/Net/issues/56)
- [没有我需要的功能](https://github.com/liangjingkanji/Net/issues/58)
- [使用inline reified封装请求函数导致崩溃](https://github.com/liangjingkanji/Net/issues/54)
- [错误提示 toast 内存泄漏](https://github.com/liangjingkanji/Net/issues/65)
- [如何使用Cookie](https://github.com/liangjingkanji/Net/issues/51)
Net最大的特点在于完美支持OkHttp的所有功能组件,
而Android上大部分都是基于OkHttp的网络请求解决方案 <br>
所以如果存在Net没有实现的功能可以百度/谷歌搜索`"OkHttp如何实现XX"`, 然后可以很容易在Net中使用

## 低版本兼容

如果你是在 Android 5 (API level 21)
以上开发建议使用最新版本: [Net](https://github.com/liangjingkanji/Net) <br>
如果要求低至 Android 4.4 (API level 19)
请使用兼容版本: [Net-okhttp3](https://github.com/liangjingkanji/Net-okhttp3)

如果需更低版本支持建议拉取仓库修改`minSdkVersion`后编译成aar使用

## 开发者交流

- [反馈问题](https://github.com/liangjingkanji/Net/issues)
- [其他开发者提及问题](https://github.com/liangjingkanji/Net/issues)
- [交流社区](https://github.com/liangjingkanji/Net/discussions)
- <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>
21 changes: 8 additions & 13 deletions docs/scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@

## 网络请求的作用域

网络请求的作用域可以根据生命周期自动取消网络请求, 发生错误也会自动弹出吐司(可以自定义或者取消), 并且具备一些场景的特殊功能(例如加载对话框, 缺省页, 下拉刷新等)
除异步任务外还适用于网络请求场景的作用域, 对比上面`异步任务的作用域`区别:

网络请求的作用域比上面提到的异步任务的作用域多的区别就是

1. 发生错误会触发全局错误处理`NetErrorHandler`
2. 具备一些特殊场景功能, 比如自动下拉刷新, 自动显示加载库等
1. 发生错误自动吐司(可以自定义或者取消)
2. 发生错误会触发全局错误处理`NetErrorHandler`
3. 具备一些特殊场景功能, 比如根据网络请求结果自动处理下拉刷新/上拉加载/缺省页/加载框的状态

| 函数 | 描述 |
|-|-|
Expand All @@ -33,17 +32,13 @@
|`PageRefreshLayout.scope`|创建跟随[PageRefreshLayout](https://github.com/liangjingkanji/BRV)生命周期的作用域|
|`StateLayout.scope`|创建跟随[StateLayout](https://github.com/liangjingkanji/BRV)生命周期的作用域|

<br>
> PageRefreshLayout/StateLayout 属于[BRV](https://github.com/liangjingkanji/BRV)框架中的布局, 用于支持[自动化缺省页/下拉刷新](auto-state.md)
<br>

> 如果想了解详细的协程使用方式, 可以查看一篇文章: [最全面的Kotlin协程: Coroutine/Channel/Flow 以及实际应用](https://juejin.im/post/6844904037586829320)
有时候可能面临嵌套的`scope*`函数或者作用域内有子作用域情况, 这个时候的生命周期是如何
**注意`StateLayout.scope`等存在`函数接受者`的方法和`scope`属于两个方法, 严禁一概而论 <br>**

PageRefreshLayout/StateLayout 属于第三方开源项目[BRV](https://github.com/liangjingkanji/BRV)框架中的布局, 可用于支持[自动化缺省页/下拉刷新](auto-state.md)<br>
如果想了解详细的协程使用方式, 可以查看一篇文章: [最全面的Kotlin协程: Coroutine/Channel/Flow 以及实际应用](https://juejin.im/post/6844904037586829320)

## 嵌套Scope
有时候可能面临嵌套的`scope*`函数或者作用域内有子作用域情况, 这个时候的生命周期是如何

```kotlin hl_lines="5"
scopeNet {
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ nav:
- Callback: callback.md
- 轮询器/倒计时: interval.md
- 社区讨论: https://github.com/liangjingkanji/Net/discussions
- 常见问题: https://github.com/liangjingkanji/Net/blob/master/docs/issues.md
- 常见问题: issues.md
- 项目实践: practice.md
- 更新日志: updates.md
- 3.x文档: api/index.html

0 comments on commit b273d62

Please sign in to comment.