416 lines
12 KiB
Java
416 lines
12 KiB
Java
package cn.shangyu.gdxzExpert.activity;
|
|
|
|
import android.content.Intent;
|
|
import android.text.TextUtils;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.BaseAdapter;
|
|
import android.widget.Button;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.ListView;
|
|
import android.widget.TextView;
|
|
|
|
import com.gyf.immersionbar.ImmersionBar;
|
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import cn.shangyu.gdxzExpert.R;
|
|
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
|
import cn.shangyu.gdxzExpert.bean.LeaseMsgDataBean;
|
|
import cn.shangyu.gdxzExpert.bean.LeaseMsgListBean;
|
|
import cn.shangyu.gdxzExpert.bean.LeaseMsgListBean.MsgBean;
|
|
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
|
|
import cn.shangyu.gdxzExpert.pulltorefreshview.PullToRefreshBase;
|
|
import cn.shangyu.gdxzExpert.pulltorefreshview.PullToRefreshBase.Mode;
|
|
import cn.shangyu.gdxzExpert.pulltorefreshview.PullToRefreshListView;
|
|
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
|
import cn.shangyu.gdxzExpert.utils.Constant;
|
|
import cn.shangyu.gdxzExpert.utils.GsonTools;
|
|
import cn.shangyu.gdxzExpert.utils.ImageOptions;
|
|
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
|
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
|
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
|
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
|
import cn.shangyu.gdxzExpert.utils.Url;
|
|
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
|
|
|
public class LeaveMsgActivity extends BaseActivity implements OnCallBackFromNet {
|
|
private View TopView;
|
|
private View view;
|
|
private int page = 1;
|
|
public static final int GET_DETAIL_RESULT = 101;
|
|
public static final int GET_COMMENT_LIST_RESULT = 102;
|
|
public static final int GET_ADD_COMMENT_RESULT = 103;
|
|
private String hospital_uuid;
|
|
private String user_uuid;
|
|
private String uuid;
|
|
private LeaveMsgActivity mActivity;
|
|
private TextView tv_case_name1, tv_scoretotal1, tv_1score1, tv_1score2,
|
|
tv_1score3, tv_gandan_comments1;
|
|
private ImageView dis_1img_01, dis_1img_02, dis_1img_03;
|
|
private LinearLayout ll_imgs1;
|
|
private PullToRefreshListView ptrLv;
|
|
private List<MsgBean> DocList = new ArrayList<MsgBean>();
|
|
private MsgAdapter mAdapter;
|
|
private Button btn_add_com;
|
|
|
|
@Override
|
|
public void setTitle() {
|
|
// TODO Auto-generated method stub
|
|
top_title.setText("留言详情");
|
|
}
|
|
|
|
@Override
|
|
public View onCreateSuccessedView() {
|
|
// TODO Auto-generated method stub
|
|
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
|
view = UIUtils.inflate(R.layout.activity_msg);
|
|
ptrLv = (PullToRefreshListView) view.findViewById(R.id.lv_item_news);
|
|
btn_add_com = (Button) view.findViewById(R.id.btn_add_com);
|
|
TopView = UIUtils.inflate(R.layout.activity_leave_msg);
|
|
tv_case_name1 = (TextView) TopView.findViewById(R.id.tv_case_name1);
|
|
tv_scoretotal1 = (TextView) TopView.findViewById(R.id.tv_scoretotal1);
|
|
tv_1score1 = (TextView) TopView.findViewById(R.id.tv_1score1);
|
|
tv_1score2 = (TextView) TopView.findViewById(R.id.tv_1score2);
|
|
tv_1score3 = (TextView) TopView.findViewById(R.id.tv_1score3);
|
|
tv_gandan_comments1 = (TextView) TopView
|
|
.findViewById(R.id.tv_gandan_comments1);
|
|
dis_1img_01 = (ImageView) TopView.findViewById(R.id.dis_1img_01);
|
|
dis_1img_02 = (ImageView) TopView.findViewById(R.id.dis_1img_02);
|
|
dis_1img_03 = (ImageView) TopView.findViewById(R.id.dis_1img_03);
|
|
ll_imgs1 = (LinearLayout) TopView.findViewById(R.id.ll_imgs1);
|
|
ptrLv.getRefreshableView().setDividerHeight(0);
|
|
btn_add_com.setOnClickListener(this);
|
|
mActivity = this;
|
|
initIntent();
|
|
getMsgDetail();
|
|
getCommentList();
|
|
return view;
|
|
}
|
|
|
|
private void getMsgDetail() {
|
|
// TODO Auto-generated method stub
|
|
Map<String, Object> param = new HashMap<String, Object>();
|
|
param.put("uuid", uuid);
|
|
param.put("hospital_uuid", hospital_uuid);
|
|
param.put("user_uuid", user_uuid);
|
|
sendJsonPostParamtoNet(Url.getMessageDetial, param, GET_DETAIL_RESULT,
|
|
this);
|
|
}
|
|
|
|
private void getCommentList() {
|
|
// TODO Auto-generated method stub
|
|
Map<String, Object> param = new HashMap<String, Object>();
|
|
param.put("page", page);
|
|
param.put("uuid", uuid);
|
|
param.put("user_uuid", user_uuid);
|
|
sendJsonPostParamtoNet(Url.getmessageCommentList, param,
|
|
GET_COMMENT_LIST_RESULT, this);
|
|
}
|
|
|
|
private void getAddComment(String content) {
|
|
showLoadingProgress();
|
|
Map<String, String> param = new HashMap<String, String>();
|
|
param.put("article_uuid", uuid);
|
|
// param.put("user_uuid", user_uuid);
|
|
// param.put("type", 6 + "");
|
|
param.put("type", "10");
|
|
param.put("comment", content);
|
|
param.put("page", "1");
|
|
// sendParamtoNet(Url.getAddComment, param, GET_ADD_COMMENT_RESULT, this,
|
|
// false);
|
|
sendJsonPostParamtoNetSignMD5(Url.addCommentV2, param, GET_ADD_COMMENT_RESULT, this
|
|
);
|
|
}
|
|
|
|
public void initIntent() {
|
|
Intent intent = getIntent();
|
|
hospital_uuid = intent.getStringExtra("hospital_uuid");
|
|
user_uuid = SharePrefUtil.getString(mActivity, "uuid", "");
|
|
uuid = intent.getStringExtra("uuid");
|
|
}
|
|
|
|
@Override
|
|
public ResultState onLoad() {
|
|
// TODO Auto-generated method stub
|
|
return ResultState.STATE_SUCCESSED;
|
|
}
|
|
|
|
@Override
|
|
protected void processClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
switch (v.getId()) {
|
|
case R.id.btn_add_com:
|
|
Intent intent = new Intent(LeaveMsgActivity.this,
|
|
ReplyFeedbackActivity.class);
|
|
intent.setType("YY");
|
|
startActivityForResult(intent, 111);
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onCallbackFromThread(String resultJson) {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onCallBackFromThread(String resultJson, int resultCode) {
|
|
// TODO Auto-generated method stub
|
|
switch (resultCode) {
|
|
case GET_DETAIL_RESULT:
|
|
processData(resultJson);
|
|
break;
|
|
case GET_COMMENT_LIST_RESULT:
|
|
processListData(resultJson);
|
|
break;
|
|
case GET_ADD_COMMENT_RESULT:
|
|
getCommentList();
|
|
ToastUtil.showMessage("评论成功");
|
|
// processListData(resultJson);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void processData(String result) {
|
|
|
|
LeaseMsgDataBean bean = GsonTools.fromGsonToBean(result,
|
|
LeaseMsgDataBean.class);
|
|
if(!StringUtil.isEmpty(bean.getData().getPublish_realname()))
|
|
{
|
|
tv_case_name1.setText(bean.getData().getPublish_realname().substring(0, 1)+"**");
|
|
}
|
|
else
|
|
{
|
|
tv_case_name1.setText("(**");
|
|
}
|
|
|
|
tv_scoretotal1.setText(bean.getData().getScoretotal() + "");
|
|
tv_1score1.setText(bean.getData().getScore1() + "");
|
|
tv_1score2.setText(bean.getData().getScore2() + "");
|
|
tv_1score3.setText(bean.getData().getScore3() + "");
|
|
tv_gandan_comments1.setText(bean.getData().getContent());
|
|
if (!StringUtil.isEmpty(bean.getData().getImg1())) {
|
|
dis_1img_01.setVisibility(View.VISIBLE);
|
|
ll_imgs1.setVisibility(View.VISIBLE);
|
|
ImageLoader.getInstance().displayImage(
|
|
Url.urlHtml + bean.getData().getImg1(), dis_1img_01,
|
|
ImageOptions.getImageOptions(R.drawable.img_gandan_house));
|
|
}
|
|
if (!StringUtil.isEmpty(bean.getData().getImg2())) {
|
|
dis_1img_02.setVisibility(View.VISIBLE);
|
|
ImageLoader.getInstance().displayImage(
|
|
Url.urlHtml + bean.getData().getImg2(), dis_1img_02,
|
|
ImageOptions.getImageOptions(R.drawable.img_gandan_house));
|
|
}
|
|
if (!StringUtil.isEmpty(bean.getData().getImg3())) {
|
|
dis_1img_03.setVisibility(View.VISIBLE);
|
|
ImageLoader.getInstance().displayImage(
|
|
Url.urlHtml + bean.getData().getImg3(), dis_1img_03,
|
|
ImageOptions.getImageOptions(R.drawable.img_gandan_house));
|
|
}
|
|
if (bean.getIsExpertFromHospital() == 0) {
|
|
btn_add_com.setVisibility(View.GONE);
|
|
} else {
|
|
btn_add_com.setVisibility(View.VISIBLE);
|
|
}
|
|
ptrLv.getRefreshableView().addHeaderView(TopView);
|
|
if (mAdapter == null) {
|
|
mAdapter = new MsgAdapter();
|
|
}
|
|
ptrLv.getRefreshableView().setAdapter(mAdapter);
|
|
ptrLv.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
|
|
@Override
|
|
public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
page=1;
|
|
getCommentList();
|
|
}
|
|
|
|
@Override
|
|
public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
page++;
|
|
getCommentList();
|
|
}
|
|
});
|
|
}
|
|
|
|
public void processListData(String result) {
|
|
|
|
LeaseMsgListBean bean = GsonTools.fromGsonToBean(result,
|
|
LeaseMsgListBean.class);
|
|
// 判断是下拉刷新还是加载更多,true表示是下拉刷新
|
|
if (page == 1) {
|
|
// 初始化消息列表的数据
|
|
DocList.clear();
|
|
// 数据为空
|
|
|
|
if (bean == null || bean.data == null || bean.data.size() == 0) {
|
|
onLoaded();
|
|
setLastUpdateTime();
|
|
// return;
|
|
|
|
} else {
|
|
DocList.addAll(bean.data);
|
|
}
|
|
} else {
|
|
// 加载更多下一页时候e
|
|
DocList.addAll(bean.data);
|
|
|
|
}
|
|
Iterator<MsgBean> it=DocList.iterator();
|
|
while (it.hasNext()) {
|
|
MsgBean bean1 = it.next();
|
|
if ("0".equals(bean1.getExamine_status())) {
|
|
if (SharePrefUtil.getString(UIUtils.getContext(), Constant.uuid, "").equals(bean1.getExpert_uuid())
|
|
||SharePrefUtil.getString(UIUtils.getContext(), Constant.uuid, "").equals(bean1.getUser_uuid())) {
|
|
continue;
|
|
} else {
|
|
it.remove();
|
|
}
|
|
}
|
|
}
|
|
if (mAdapter == null) {
|
|
mAdapter = new MsgAdapter();
|
|
ptrLv.getRefreshableView().setAdapter(mAdapter);
|
|
} else {
|
|
mAdapter.notifyDataSetChanged();
|
|
|
|
}
|
|
// 完成刷新
|
|
onLoaded();
|
|
// 得到总页码数
|
|
int totalPage = bean.totalPage;
|
|
if (totalPage <= 1 || totalPage < page) {
|
|
if (page != 1) {
|
|
ToastUtil.showMessage("没有更多数据了");
|
|
}
|
|
ptrLv.setMode(Mode.PULL_FROM_START);
|
|
|
|
} else {
|
|
ptrLv.setMode(Mode.BOTH);
|
|
}
|
|
|
|
// 设置刷新的时间
|
|
setLastUpdateTime();
|
|
}
|
|
|
|
/**
|
|
* 设置刷新时间
|
|
*/
|
|
private void setLastUpdateTime() {
|
|
String text = CommonUtil.getStringDate();
|
|
ptrLv.getLoadingLayoutProxy().setLastUpdatedLabel(text);
|
|
}
|
|
|
|
/**
|
|
* 数据加载完成时,取消加载动画
|
|
*/
|
|
private void onLoaded() {
|
|
dismissLoadingProgress();
|
|
ptrLv.onRefreshComplete();
|
|
}
|
|
|
|
public class MsgAdapter extends BaseAdapter {
|
|
|
|
@Override
|
|
public int getCount() {
|
|
// TODO Auto-generated method stub
|
|
|
|
return DocList.size();
|
|
}
|
|
|
|
@Override
|
|
public Object getItem(int position) {
|
|
// TODO Auto-generated method stub
|
|
return DocList.get(position);
|
|
}
|
|
|
|
@Override
|
|
public long getItemId(int position) {
|
|
// TODO Auto-generated method stub
|
|
return position;
|
|
}
|
|
|
|
@Override
|
|
public View getView(int position, View convertView, ViewGroup parent) {
|
|
// TODO Auto-generated method stub
|
|
ViewHolder vh = null;
|
|
if (convertView == null) {
|
|
convertView = UIUtils.inflate(R.layout.item_msg_contment);
|
|
vh = new ViewHolder();
|
|
vh.mTv_content = (TextView) convertView
|
|
.findViewById(R.id.tv_content);
|
|
vh.mTv_name = (TextView) convertView.findViewById(R.id.tv_name);
|
|
convertView.setTag(vh);
|
|
|
|
} else {
|
|
vh = (ViewHolder) convertView.getTag();
|
|
|
|
}
|
|
|
|
if (DocList.get(position).getComment().contains(":")) {
|
|
|
|
vh.mTv_content
|
|
.setText(DocList
|
|
.get(position)
|
|
.getComment()
|
|
.substring(
|
|
DocList.get(position).getComment()
|
|
.indexOf(":") + 1,
|
|
DocList.get(position).getComment()
|
|
.length()));
|
|
} else {
|
|
vh.mTv_content.setText(" ");
|
|
}
|
|
if (DocList.get(position).getComment().contains(":")) {
|
|
String sss = DocList
|
|
.get(position)
|
|
.getComment()
|
|
.substring(0,
|
|
DocList.get(position).getComment().indexOf(":"));
|
|
if (sss.contains("gdxz")) {
|
|
sss = sss.replace("gdxz", "");
|
|
} else {
|
|
sss = sss.substring(0, 1) + "**";
|
|
}
|
|
vh.mTv_name.setText(sss);
|
|
} else {
|
|
vh.mTv_name.setText(" ");
|
|
}
|
|
|
|
return convertView;
|
|
}
|
|
|
|
public class ViewHolder {
|
|
public TextView mTv_name, mTv_content;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
if (resultCode == 2) {
|
|
String reply = data.getExtras().getString("reply");
|
|
|
|
if (TextUtils.isEmpty(reply)) {
|
|
return;
|
|
}
|
|
String name = SharePrefUtil.getString(mActivity, "realName", null);
|
|
page = 1;
|
|
getAddComment(name + "gdxz:" + reply);
|
|
}
|
|
}
|
|
}
|