最终结果
最终结果
首先建立一个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();