最终结果
最后更新于:2022-04-01 03:09:03
## 最终结果
首先建立一个activity,在里面输出各种类型的数据。为了测试Inner class和Object的效果,我专门建立了一个很简单的内部类User:
~~~
class User {
private String name;
private String sex;
User(String name, String sex) {
this.name = name;
this.sex = sex;
}
public void log() {
show();
}
private void show() {
L.d("user");
}
}
~~~
激动人心的测试开始了:
~~~
// string
String str = fromIntent("key");
L.d(str != null ? str : "hello world");
// json
L.json("[{\"CityId\":18,\"CityName\":\"西安\",\"ProvinceId\":27,\"CityOrder\":1},{\"CityId\":53,\"CityName\":\"广州\",\"ProvinceId\":27,\"CityOrder\":1}]'");
// object
L.Object(new User("jack", "f"));
// list
L.Object(TestUtil.getLongStringList(this));
// array
L.Object(TestUtil.getShortStringArr());
// arrays
double[][] doubles = {
{1.2, 1.6, 1.7, 30, 33},
{1.2, 1.6, 1.7, 30, 33},
{1.2, 1.6, 1.7, 30, 33},
{1.2, 1.6, 1.7, 30, 33}
};
L.Object(doubles);
// sub class
new User("name", "sex").log();
~~~
结果如下:
简单的string类型: [![此处输入图片的描述](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-09-11_55f22c958348e.png%3Fraw%3Dtrue)](https://github.com/tianzhijiexian/Android-Best-Practices/blob/master/2015.8/log/string.png?raw=true)
Json字符串:
[![此处输入图片的描述](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-09-11_55f22c9763758.png%3Fraw%3Dtrue)](https://github.com/tianzhijiexian/Android-Best-Practices/blob/master/2015.8/log/json.png?raw=true)
Object对象:
[![此处输入图片的描述](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-09-11_55f22c998826d.png%3Fraw%3Dtrue)](https://github.com/tianzhijiexian/Android-Best-Practices/blob/master/2015.8/log/pojo.png?raw=true)
数组类型:
[![此处输入图片的描述](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-09-11_55f22c9b621c9.png%3Fraw%3Dtrue)](https://github.com/tianzhijiexian/Android-Best-Practices/blob/master/2015.8/log/array.png?raw=true)
[![此处输入图片的描述](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-09-11_55f22c9d22cb4.png%3Fraw%3Dtrue)](https://github.com/tianzhijiexian/Android-Best-Practices/blob/master/2015.8/log/arrayes.png?raw=true)
内部类:
[![此处输入图片的描述](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-09-11_55f22c9f60a40.png%3Fraw%3Dtrue)](https://github.com/tianzhijiexian/Android-Best-Practices/blob/master/2015.8/log/innerCls.png?raw=true)