// 创建完成 private void createNewGroupFinish() { // 封面 if (null == currentImageName || currentImageName.length() < 1) { ToastUtil.show(this, "封面怎么可以没有 ∪︿∪"); return; } // 名称 if (topicNameEditText.getText().toString().trim().length() < 1) { ToastUtil.show(this, "标题怎么可以没有 ∪︿∪"); return; } // 名称 if (topicNameEditText.getText().toString().trim().length() > 16) { ToastUtil.show(this, "标题不能超过16个字 ∪︿∪"); return; } // 介绍 if (topicDescEditText.getText().toString().trim().length() < 1) { ToastUtil.show(this, "描述不能没有 ∪︿∪"); return; } // 介绍 if (topicDescEditText.getText().toString().trim().length() < 25) { ToastUtil.show(this, "描述不能少于26个字 ∪︿∪"); return; } // 介绍 if (topicDescEditText.getText().toString().trim().length() > 200) { ToastUtil.show(this, "描述不能超过200个字"); return; } // 类型 if (topicCategoryID < 1) { ToastUtil.show(this, "类型还没选呢 ∪︿∪"); return; } // 参数设置 RequestParams params = new RequestParams(); params.addBodyParameter("user_id", UserManager.getInstance().getUser().getUid() + ""); params.addBodyParameter("topic_name", topicNameEditText.getText().toString().trim()); params.addBodyParameter("topic_desc", topicDescEditText.getText().toString().trim()); params.addBodyParameter("category_id", topicCategoryID + ""); File uplodaFile = new File(FileUtil.BIG_IMAGE_PATH + currentImageName); if (!uplodaFile.exists()) { return; } params.addBodyParameter("image", uplodaFile); showLoading("创建中 (≡ω≡.)", false); HttpManager.post( JLXCConst.POST_NEW_TOPIC, params, new JsonRequestCallBack<String>( new LoadDataHandler<String>() { @Override public void onSuccess(JSONObject jsonResponse, String flag) { super.onSuccess(jsonResponse, flag); LogUtils.i(jsonResponse.toJSONString(), 1); hideLoading(); int status = jsonResponse.getInteger(JLXCConst.HTTP_STATUS); if (status == JLXCConst.STATUS_SUCCESS) { ToastUtil.show( CreateGroupActivity.this, jsonResponse.getString(JLXCConst.HTTP_MESSAGE)); // 删除临时文件 File tmpFile = new File(FileUtil.BIG_IMAGE_PATH + currentImageName); if (tmpFile.exists()) { tmpFile.delete(); } tmpImageName = ""; currentImageName = ""; JSONObject jsonObject = jsonResponse.getJSONObject(JLXCConst.HTTP_RESULT); // 发送通知 GroupTopicModel model = new GroupTopicModel(); model.setTopic_id(jsonObject.getIntValue("id")); model.setTopic_cover_image(jsonObject.getString("topic_cover_image")); model.setTopic_name(jsonObject.getString("topic_name")); model.setTopic_detail(jsonObject.getString("topic_detail")); model.setNews_count(0); model.setMember_count(1); sendBroadCastData(model); finishWithRight(); } if (status == JLXCConst.STATUS_FAIL) { ToastUtil.show( CreateGroupActivity.this, jsonResponse.getString(JLXCConst.HTTP_MESSAGE)); } } @Override public void onFailure(HttpException arg0, String arg1, String flag) { hideLoading(); super.onFailure(arg0, arg1, flag); ToastUtil.show(CreateGroupActivity.this, "网络异常 ∪︿∪"); } }, null)); }
// 发布动态 private void publishNews() { if ("".equals(contentEditText.getText().toString().trim()) && addImageLayout.getChildCount() == 1) { ToastUtil.show(this, "内容和图片至少有一个不能为空=_="); return; } if (contentEditText.getText().toString().length() > 140) { ToastUtil.show(this, "内容不能超过140字=_="); return; } final UserModel userModel = UserManager.getInstance().getUser(); showLoading("发布中,请稍候...", false); RequestParams params = new RequestParams(); // 用户id params.addBodyParameter("uid", userModel.getUid() + ""); // 内容 params.addBodyParameter("content_text", contentEditText.getText().toString()); // location params.addBodyParameter("location", locationString); // 哪个圈子里的 if (topicId > 0) { params.addBodyParameter("topic_id", topicId + ""); } // 图片 for (int i = 0; i < addImageLayout.getChildCount(); i++) { View view = addImageLayout.getChildAt(i); // 如果不是添加按钮 if (view != addImageView) { // 图片 File file = new File((String) view.getTag()); if (file.exists()) { params.addBodyParameter("image" + i, file); } } } // 姓名 HttpManager.post( JLXCConst.PUBLISH_NEWS, params, new JsonRequestCallBack<String>( new LoadDataHandler<String>() { @Override public void onSuccess(JSONObject jsonResponse, String flag) { super.onSuccess(jsonResponse, flag); hideLoading(); int status = jsonResponse.getIntValue("status"); switch (status) { case JLXCConst.STATUS_SUCCESS: // toast ToastUtil.show( PublishNewsActivity.this, jsonResponse.getString(JLXCConst.HTTP_MESSAGE)); hideLoading(); finishWithRight(); publishFinishBroadcast(); break; case JLXCConst.STATUS_FAIL: hideLoading(); Toast.makeText( PublishNewsActivity.this, jsonResponse.getString(JLXCConst.HTTP_MESSAGE), Toast.LENGTH_SHORT) .show(); break; } } @Override public void onFailure(HttpException arg0, String arg1, String flag) { LogUtils.i(arg0.getMessage(), 1); super.onFailure(arg0, arg1, flag); hideLoading(); Toast.makeText(PublishNewsActivity.this, "网络异常", Toast.LENGTH_SHORT).show(); } }, null)); }