@OnClick(R.id.tv_publish) void publish(View view) { if (Utils.isEmpty(et_title.getText().toString())) { toast("请输入标题"); return; } if (Utils.isEmpty(et_content.getText().toString())) { toast("请输入内容"); return; } if (Utils.isEmpty(type)) { if (tv_label.getTag(R.id.tag_first) == null && tv_label.getTag(R.id.tag_two) == null) { toast("请选择标签"); return; } } if (!SimpleUtils.isLogin(activity)) { skip(LoginActivity.class); return; } PostParams params = new PostParams(); showDialog(); params.put("title", et_title.getText().toString()); params.put("content", et_content.getText().toString()); params.put("address", tv_address.getText().toString()); if (tv_label.getTag(R.id.tag_two) != null) { params.put("category_id", tv_label.getTag(R.id.tag_two).toString()); // 标签id } if (tv_label.getTag(R.id.tag_first) != null) { params.put("type", tv_label.getTag(R.id.tag_first).toString()); // 标签id params.put("category_id", "2"); // 标签id } if (tb_notify.isChecked()) { params.put("private", "0"); // 标签id } else { params.put("private", "1"); // 标签id } String pics = ""; Set keys = ids.keySet(); Iterator<String> it = keys.iterator(); while (it.hasNext()) { String key = it.next(); String id = ids.get(key); if (Utils.isEmpty(pics)) { pics = id; } else { pics = pics + "," + id; } } params.put("pictures", pics); HttpUtils.postJSONObject( activity, Const.PUBLIC_CIRCLE, SimpleUtils.buildUrl(activity, params), new RespJSONObjectListener(activity) { @Override public void getResp(JSONObject obj) { dismissDialog(); RespVo respVo = GsonTools.getVo(obj.toString(), RespVo.class); if (respVo.isSuccess()) { toast("动态已发布"); EventBus.getDefault().post(new DiseaseRecordActivity.RefreshEvent()); finish(); } else { toast(respVo.getMessage()); } } @Override public void doFailed() { dismissDialog(); } }); }
private void query(final boolean isFirst) { final PostParams params = new PostParams(); params.put("page", pageNum + ""); HttpUtils.postJSONObject( activity, Const.MY_CIRCLE, SimpleUtils.buildUrl(activity, params), new RespJSONObjectListener(activity) { @Override public void getResp(JSONObject jsonObject) { list_circle.setRefreshing(false); RespVo<CircleVo> respVo = GsonTools.getVo(jsonObject.toString(), RespVo.class); if (respVo.isSuccess()) { CircleVo data = respVo.getData(activity, jsonObject, CircleVo.class); if (isFirst && !Utils.isEmpty(data.getHot_tags())) { for (final CircleVo.HotTagsVo tag : data.getHot_tags()) { View view = activity.makeView(R.layout.item_qunzu); ImageView iv_avatar = (ImageView) view.findViewById(R.id.iv_avatar); TextView tv_name = (TextView) view.findViewById(R.id.tv_name); TextView tv_desc = (TextView) view.findViewById(R.id.tv_desc); TextView tv_num = (TextView) view.findViewById(R.id.tv_num); TextView tv_jiaru = (TextView) view.findViewById(R.id.tv_jiaru); tv_num.setVisibility(View.GONE); tv_jiaru.setVisibility(View.GONE); Glide.with(activity.getApplicationContext()) .load(SimpleUtils.getImageUrl(tag.getCover())) .into(iv_avatar); tv_name.setText(tag.getTitle()); tv_desc.setText(tag.getJoined_person() + "人参与"); view.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { activity.skip(NewsListActivity.class, tag.getId(), tag.getTitle()); } }); ll_label.addView(view); } } if (pageNum == 1) { adapter.removeAll(); list_circle.setCanLoadMore(); } if (Utils.isEmpty(data.getNews())) { list_circle.setNoMoreData(); } else { if (data.getNews().size() < 10) { list_circle.setNoMoreData(); } else { list_circle.setCanLoadMore(); } adapter.addItems(data.getNews()); } pageNum++; } else { activity.toast(respVo.getMessage()); } } @Override public void doFailed() { list_circle.setRefreshing(false); } }); }