Skip to content

Commit d407065

Browse files
author
linjiang
committed
📝 update docs for v1.2.0.
1 parent 311831d commit d407065

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,24 @@ new OkHttpClient.Builder()
8686

8787
## Extended features
8888

89+
### Make the response of Http more readable
90+
The result of Http request is usually the json format. In order to be more beautiful when viewing json, you can add a formatter to json in the following way:
91+
92+
1. implement `tech.linjiang.pandora.network.JsonFormatter` interface,You can refer to the specific implementation of `JsonFormatterImpl` in the app-module:
93+
```
94+
public class JsonFormatterImpl implements JsonFormatter {
95+
@Override
96+
public String format(String result) {
97+
return JSON.toJSONString(JSON.parse(result));
98+
}
99+
}
100+
```
101+
102+
2. Add new formatter to Pandora:
103+
```
104+
Pandora.get().getInterceptor().setJsonFormatter(new JsonFormatterImpl());
105+
```
106+
89107
### Inspect the View property
90108
Pandora supports viewing and partially modifying the properties of View, ViewGroup, and common TextView and ImageView by default. If you want to inspect more view attributes, you can expand them in the following ways:
91109

README_CN.md

+18
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ new OkHttpClient.Builder()
8282

8383
## 扩展特性
8484

85+
### 让Http的response更具可读性
86+
Http请求的结果通常是json格式,为了在查看json时更美观,可以通过以下方式为json增加formatter:
87+
88+
1. 实现`tech.linjiang.pandora.network.JsonFormatter`接口,可以参考app模块下的`JsonFormatterImpl`的具体实现:
89+
```
90+
public class JsonFormatterImpl implements JsonFormatter {
91+
@Override
92+
public String format(String result) {
93+
return JSON.toJSONString(JSON.parse(result));
94+
}
95+
}
96+
```
97+
98+
2. 将实现的formatter添加到Pandora:
99+
```
100+
Pandora.get().getInterceptor().setJsonFormatter(new JsonFormatterImpl());
101+
```
102+
85103
### 查看View属性
86104
Pandora默认支持动态查看和部分修改View、ViewGroup以及常见的TextView、ImageView控件的属性,如果想查看更多控件的属性,可以通过以下方式进行扩展:
87105

0 commit comments

Comments
 (0)