Browse Source

更新文档

drake 3 years ago
parent
commit
b5fd612c84

+ 7 - 7
docs/auto-dialog.md

@@ -26,19 +26,19 @@ scopeDialog {
 
 === "初始化"
     ```kotlin
-    initNet("http://github.com/") {
-        onDialog { // lambda返回一个Dialog对象
-            ProgressDialog(it).apply { // it 为 FragmentActivity
-                setMessage("正在努力请求中")
+    NetConfig.init("http://github.com/") {
+            setDialogFactory { // 全局加载对话框
+                ProgressDialog(it).apply {
+                    setMessage("我是全局自定义的加载对话框...")
+                }
             }
-        }
     }
     ```
 === "设置全局"
     ```kotlin
-    NetConfig.onDialog = { //
+    NetConfig.dialogFactory = NetDialogFactory {
         ProgressDialog(it).apply {
-            setMessage("请稍等")
+            setMessage("我是全局自定义的加载对话框...")
         }
     }
     ```

+ 4 - 4
docs/config.md

@@ -9,7 +9,7 @@
 
             // http://google.com/  这是接口全局域名, 可以使用NetConfig.host进行单独的修改
 
-            initNet("http://github.com/") {
+            NetConfig.init("http://github.com/") {
                 setLog(BuildConfig.DEBUG) // 作用域发生异常是否打印
                 setConverter(GsonConvert()) // 转换器
             }
@@ -30,7 +30,7 @@
                 .setConverter(GsonConvert())
                 .addInterceptor(LogRecordInterceptor(BuildConfig.DEBUG))
 
-            initNet("http://github.com/", okHttpClientBuilder)
+            NetConfig.init("http://github.com/", okHttpClientBuilder)
         }
     }
     ```
@@ -42,11 +42,11 @@
 | 函数 | 描述 |
 |-|-|
 | setLog | 输出网络异常日志 |
-| setHost | 全局域名, 和initNet("Host")函数中的第一个参数等效 |
+| setHost | 全局域名, 和NetConfig.init("Host")函数中的第一个参数等效 |
 | setConverter | [转换器](converter.md), 将网络返回的数据转换成你想要的数据结构 |
 | setRequestInterceptor | [请求拦截器](interceptor.md), 用于添加全局请求头/参数 |
 | setErrorHandler | [全局错误处理](error-handle.md) |
-| onDialog | [全局对话框](auto-dialog.md) |
+| dialogFactory | [全局对话框](auto-dialog.md) |
 
 ## 动态配置
 

+ 1 - 1
docs/converter.md

@@ -24,7 +24,7 @@ scopeNetLife {
 
 === "全局"
     ```kotlin hl_lines="2"
-    initNet("http://github.com/") {
+    NetConfig.init("http://github.com/") {
         setConverter(SerializationConverter())
     }
     ```

+ 9 - 0
docs/enqueue-request.md

@@ -36,6 +36,15 @@ NetCallback相较于Callback的特性
 2. 新增三个回调函数: onSuccess/onFailure/onComplete
 3. 以上三个回调函数都运行在主线程
 
+<br>
+基本特性也被扩展在Callback中. 除开库本身自带的Callback你也可以仿照实现自己的特殊Callback
+
+| 函数 | 描述 |
+|-|-|
+| DialogCallback | 自动显示隐藏加载对话框 |
+| StateCallback | 自动显示缺省页 |
+| PageCallback | 自动下拉刷新/上拉加载 |
+
 ## onResult
 
 使用`onResult`可以更加灵活方便的处理队列请求. 使用Kotlin的空安全函数可以区分处理请求结果

+ 1 - 1
docs/error-handle.md

@@ -14,7 +14,7 @@ Net具备完善的全局错误处理机制 <br>
 示例
 
 ```kotlin
-initNet("http://localhost:80/") {
+NetConfig.init("http://localhost:80/") {
 
     setErrorHandler(object : NetErrorHandler() {
         override fun onError(e: Throwable) {

+ 1 - 1
docs/exception-track.md

@@ -23,7 +23,7 @@ scopeNetLife {
 在初始化时候可以关闭日志打印
 
 ```kotlin
-initNet("http://github.com/") {
+NetConfig.init("http://github.com/") {
     setLog(false) // 关闭日志
 }
 ```

+ 2 - 2
docs/https.md

@@ -19,7 +19,7 @@ scopeNetLife {
 === "全局配置"
 
     ```kotlin
-    initNet("https://www.google.com/"){
+    NetConfig.init("https://www.google.com/"){
         trustSSLCertificate() // 信任所有证书
     }
     ```
@@ -42,7 +42,7 @@ scopeNetLife {
 === "全局配置"
 
     ```kotlin
-    initNet("http://github.com/") {
+    NetConfig.init("http://github.com/") {
         val privateCertificate = resources.assets.open("https.certificate")
         setSSLCertificate(privateCertificate)
     }

+ 2 - 2
docs/interceptor.md

@@ -10,7 +10,7 @@ class App : Application() {
     override fun onCreate() {
         super.onCreate()
 
-        initNet("http://github.com/") {
+        NetConfig.init("http://github.com/") {
             addInterceptor { chain -> chain.proceed(chain.request()) }
         }
     }
@@ -31,7 +31,7 @@ RequestInterceptor属于轻量级的请求拦截器, 在每次请求的时候该
 初始化时添加请求拦截器的示例代码
 
 ```kotlin
-initNet("http://github.com/") {
+NetConfig.init("http://github.com/") {
     setRequestInterceptor(object : RequestInterceptor {
         override fun interceptor(request: BaseRequest) {
             request.param("client", "Net")

+ 1 - 1
docs/kotlin-serialization.md

@@ -25,7 +25,7 @@
 
 === "全局配置"
     ```kotlin
-    initNet("http://google.com/") {
+    NetConfig.init("http://google.com/") {
         setConverter(SerializationConvert())
         // ... 其他配置
     }

+ 2 - 2
docs/log-recorder.md

@@ -5,7 +5,7 @@ Net扩展[Okhttp Profiler](https://github.com/itkacher/OkHttpProfiler)插件以
 ## 添加日志拦截器
 
 ```kotlin hl_lines="2"
-initNet("http://github.com/") {
+NetConfig.init("http://github.com/") {
     addInterceptor(LogRecordInterceptor(BuildConfig.DEBUG))
 }
 ```
@@ -70,7 +70,7 @@ scopeNetLife {
 然后初始化时添加自己实现拦截器即可
 
 ```kotlin
-initNet("http://github.com/") {
+NetConfig.init("http://github.com/") {
     addInterceptor(MyLogRecordInterceptor(BuildConfig.DEBUG))
 }
 ```

+ 1 - 1
docs/okhttp-client.md

@@ -13,7 +13,7 @@ object NetConfig {
 ## 全局OkHttpClient
 
 ```kotlin
-initNet("http://github.com/") {
+NetConfig.init("http://github.com/") {
     // 此处this即为OkHttpClient.Builder
 }
 ```

+ 1 - 1
docs/read-cache.md

@@ -3,7 +3,7 @@ Net_v2基于[Kalle](https://github.com/yanzhenjie/Kalle)开发, 支持Kalle的9
 缓存模式要求在初始化的时候开启
 
 ```kotlin
-initNet("http://github.com/") {
+NetConfig.init("http://github.com/") {
     cacheEnabled() // 开启缓存
 }
 ```