use of com.shiqkuangsan.mycustomviews.utils.MySimplexUtil.SimpleRequestParams in project CustomViews by AndroidStudy233.
the class XUtilsActivity method sendGetUseArr.
/**
* 演示
* 如果一个接口需要传一个对象或者一个数组. 就得把它转成json数据, 然后用setBodyContent
*/
private void sendGetUseArr() {
SimpleRequestParams params = new SimpleRequestParams.Builder(Constant.mlnx_province_url).build();
params.setAsJsonContent(true);
String jsonString = JSON.toJSONString(new Province());
String jString1 = JSON.toJSONString(new ArrayList<Province>());
String jString2 = JSON.toJSONString(new String[] { "233" });
params.setBodyContent(jsonString);
MySimplexUtil.sendGet(params, new MySimplexUtil.SimpleRequstCallBack<List<Province>>() {
@Override
public void onSuccess(List<Province> result) {
if (!isDbInited)
list = result;
if (result != null && result.size() > 0)
showToast(result.get(new Random().nextInt(result.size() - 1)).toString());
}
@Override
public void onError(Throwable ex, boolean isOnCallback) {
super.onError(ex, isOnCallback);
}
});
}
Aggregations