Skip to content

Commit

Permalink
📝 新增网络请求框架的使用说明
Browse files Browse the repository at this point in the history
  • Loading branch information
stars-one committed Mar 26, 2023
1 parent b6859f9 commit eeeed4f
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -803,4 +803,30 @@ hbox{
代码位于ShortCutUtils中

- `createShortCut()` 创建快捷方式
- `setAppStartup()` 设置快捷方式为开机启动
- `setAppStartup()` 设置快捷方式为开机启动

## 11.网络请求库

目前支持get post请求,可传json,且支持打印输出网络请求日志

```kotlin
//开启网络请求日志输出
NetworkUtil.isDebug = true

//get请求示例
val url = "http://127.0.0.1:8099/userlogin"
val data = hashMapOf("username" to "hello")
//这里可以指定的实体类,可方便之后将数据转为实体类对象
// 我这里是传了String,就是不进行实体类转换处理,直接返回json数据

NetworkUtil.get(url, data, hashMapOf(), object : NetworkUtil.RespCallBack<String>() {

override fun onResponse(call: Call, data: String) {
//数据
}

override fun onFailure(call: Call, e: Exception) {
e.printStackTrace()
}
})
```

0 comments on commit eeeed4f

Please sign in to comment.