Skip to content

Commit c970bdf

Browse files
committed
update doc
1 parent 081ff6c commit c970bdf

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

docs/EasyBundle.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ val age = easyBundle.get<Int>("age")
5757
val name = easyBundle.get<String>("name")
5858
```
5959

60+
- **使用EasyBundle进行读取**: 当读取失败时。指定默认值
61+
62+
```
63+
val easyBundle = EasyBundle.create(getBundle())
64+
val age = easyBundle.get<Int>("age", defAge)
65+
val name = easyBundle.get<String>("name", defName)
66+
```
67+
6068
- **原生方式页面取值**
6169

6270
```
@@ -219,6 +227,12 @@ val user = easyBundle.get<User>("user")
219227
User user = easyBundle.get("user", User.class)
220228
```
221229

230+
与此想对应的,**也可以为读取操作指定默认值**:当通过指定key读取数据失败时,返回提供的默认值进行使用。防止空指针
231+
232+
```
233+
val user = easyBundle.get<User>("user", deUser)
234+
```
235+
222236
### 打破Bundle存储数据限制
223237

224238
都知道,Bundle的存取api那么复杂,主要是需要过滤掉`不被系统允许的非序列化数据`

0 commit comments

Comments
 (0)