Search in sources :

Example 1 with SimpleRequestParams

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);
        }
    });
}
Also used : SimpleRequestParams(com.shiqkuangsan.mycustomviews.utils.MySimplexUtil.SimpleRequestParams) Province(com.shiqkuangsan.mycustomviews.bean.Province) Random(java.util.Random) MySimplexUtil(com.shiqkuangsan.mycustomviews.utils.MySimplexUtil) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Province (com.shiqkuangsan.mycustomviews.bean.Province)1 MySimplexUtil (com.shiqkuangsan.mycustomviews.utils.MySimplexUtil)1 SimpleRequestParams (com.shiqkuangsan.mycustomviews.utils.MySimplexUtil.SimpleRequestParams)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Random (java.util.Random)1