private void commentRiding() { RequestParams params = new RequestParams("UTF-8"); params.addQueryStringParameter("riderId", riderId); params.addQueryStringParameter("userId", preferences.getInt("userId", -1) + ""); if (superId != -1) { params.addBodyParameter("superId", superId + ""); params.addBodyParameter("parentId", superId + ""); } else { params.addBodyParameter("superId", "0"); params.addBodyParameter("parentId", "0"); } params.addBodyParameter("uniqueKey", preferences.getString("uniqueKey", null)); params.addBodyParameter("commentMemo", contentEdit.getText().toString()); xUtilsUtil.httpPost( "mobile/riderComment/insertComment.html", params, new CallBackPost() { @Override public void onMySuccess(ResponseInfo<String> responseInfo) { String s = responseInfo.result; JSONObject jsonObject = null; try { jsonObject = new JSONObject(s); } catch (JSONException e) { e.printStackTrace(); } if (jsonObject.optBoolean("result")) { contentEdit.setText(""); contentEdit.setHint("说几句吧"); if (flag) { Toasts.show(RiderDiscussActivity.this, "评论成功", 0); } else { Toasts.show(RiderDiscussActivity.this, "回复成功", 0); } discussBtn.setText("评论"); imm.hideSoftInputFromWindow(contentEdit.getWindowToken(), 0); } else { Toasts.show(RiderDiscussActivity.this, jsonObject.optString("message"), 0); } flag = true; pageIndex = 1; queryCommentPaginationList(); } @Override public void onMyFailure(HttpException error, String msg) { flag = true; } }); }
private void dataJ() { RequestParams params = new RequestParams("UTF-8"); params.addBodyParameter("pageIndex", pageIndex + ""); params.addBodyParameter("activityId", activityId + ""); xUtilsUtil.httpPost( "common/queryActivityComment.html", params, new CallBackPost() { @Override public void onMySuccess(ResponseInfo<String> responseInfo) { String s = responseInfo.result; JSONObject jsonObject = null; try { jsonObject = new JSONObject(s); } catch (JSONException e) { e.printStackTrace(); } if (jsonObject.optBoolean("result")) { pageIndex = jsonObject.optInt("pageIndex"); JSONArray dataList = jsonObject.optJSONArray("dataList"); Gson gson = new Gson(); Type type = new TypeToken<List<ActivityCommentModel>>() {}.getType(); List<ActivityCommentModel> lists = gson.fromJson(dataList.toString(), type); if (pageIndex == 1) { list.clear(); list.addAll(lists); } else { list.addAll(lists); } adapter.notifyDataSetChanged(); } else { Toasts.show(RiderDiscussActivity.this, jsonObject.optString("message"), 0); } } @Override public void onMyFailure(HttpException error, String msg) {} }); }
private void queryCommentPaginationList() { RequestParams params = new RequestParams("UTF-8"); params.addBodyParameter("riderId", riderId); params.addBodyParameter("pageIndex", "2"); xUtilsUtil.httpPost( "common/queryRiderCommentPaginationList.html", params, new CallBackPost() { @Override public void onMySuccess(ResponseInfo<String> responseInfo) { String s = responseInfo.result; JSONObject jsonObject = null; try { jsonObject = new JSONObject(s); } catch (JSONException e) { e.printStackTrace(); } if (jsonObject.optBoolean("result")) { JSONArray dataList = jsonObject.optJSONArray("dataList"); Gson gson = new Gson(); Type type = new TypeToken<List<ActivityCommentModel>>() {}.getType(); list = gson.fromJson(dataList.toString(), type); adapter = new ActivityDiscussListAdapter(RiderDiscussActivity.this, list); discussList.setAdapter(adapter); discussList.setOnTouchListener(RiderDiscussActivity.this); discussList.setOnItemClickListener(RiderDiscussActivity.this); swipeLayout.setOnRefreshListener(RiderDiscussActivity.this); swipeLayout.setOnLoadListener(RiderDiscussActivity.this); } else { Toasts.show(RiderDiscussActivity.this, jsonObject.optString("message"), 0); } } @Override public void onMyFailure(HttpException error, String msg) { Toasts.show(RiderDiscussActivity.this, msg, 0); } }); }