private void deleteMessage() { List<String> delList = mJsonAdapter.getCheckMessage(); if (delList.size() == 0) { showToast("请选择需要删除的消息!"); return; } JSONArray jsa = new JSONArray(delList); User user = User.getInstance(); DhNet net = new DhNet( API.CWBaseurl + "/message/remove?userId=" + user.getUserId() + "&token=" + user.getToken()); net.addParam("messages", jsa); net.doPostInDialog( "删除中...", new NetTask(self) { @Override public void doInUI(Response response, Integer transfer) { if (response.isSuccess()) { showToast("删除成功!"); leftTitleT.setVisibility(View.GONE); leftTitleT.setText("全选"); backI.setVisibility(View.VISIBLE); delB.setVisibility(View.GONE); mJsonAdapter.showCheck(false); rightTitleT.setVisibility(View.GONE); mJsonAdapter.refresh(); } } }); }
@Override public void initView() { type = getIntent().getStringExtra("type"); per = IocContainer.getShare().get(CarPlayPerference.class); per.load(); if (per.isShowMessageGuilde == 0) { findViewById(R.id.guide).setVisibility(View.VISIBLE); } findViewById(R.id.know) .setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { per.load(); per.isShowMessageGuilde = 1; per.commit(); findViewById(R.id.guide).setVisibility(View.GONE); } }); backI = (ImageView) findViewById(R.id.back); if (type.equals("comment")) { setTitle("新的留言"); } else { setTitle("活动消息"); } leftTitleT = (TextView) findViewById(R.id.left_text); leftTitleT.setText("全选"); leftTitleT.setPadding(DhUtil.dip2px(self, 12), 0, 0, 0); leftTitleT.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (leftTitleT.getText().toString().equals("全选")) { mJsonAdapter.checkAll(true); leftTitleT.setText("取消全选"); } else { leftTitleT.setText("全选"); mJsonAdapter.checkAll(false); } mJsonAdapter.notifyDataSetChanged(); } }); rightTitleT = (TextView) findViewById(R.id.right_text); rightTitleT.setText("取消"); rightTitleT.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { mJsonAdapter.showCheck(false); leftTitleT.setText("全选"); rightTitleT.setVisibility(View.GONE); delB.setVisibility(View.GONE); mJsonAdapter.cleanCheck(); backI.setVisibility(View.VISIBLE); mJsonAdapter.showCheck(false); leftTitleT.setVisibility(View.GONE); } }); delB = (Button) findViewById(R.id.del); delB.setOnClickListener(this); listView = (NetRefreshAndMoreListView) findViewById(R.id.listview); listView.setOnItemLongClickListener( new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { mJsonAdapter.showCheck(true); rightTitleT.setVisibility(View.VISIBLE); leftTitleT.setVisibility(View.VISIBLE); delB.setVisibility(View.VISIBLE); backI.setVisibility(View.GONE); return true; } }); listView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent it = null; JSONObject jo = (JSONObject) mJsonAdapter.getItem(position - 1); if (type.equals("comment")) { it = new Intent(self, ActiveDetailsActivity.class); it.putExtra("activityId", JSONUtil.getString(jo, "activityId")); startActivity(it); } else { String activityId = JSONUtil.getString(jo, "activityId"); String type = JSONUtil.getString(jo, "type").trim(); if (!TextUtils.isEmpty(activityId)) { it = new Intent(self, ActiveDetailsActivity.class); it.putExtra("activityId", activityId); startActivity(it); } if (type.equals("车主认证")) { String carModel = JSONUtil.getString(jo, "carModel"); String remarks = JSONUtil.getString(jo, "remarks"); String rs = ""; if (JSONUtil.getString(jo, "remarks").equals("")) { rs = "0"; } else { rs = "1"; } it = new Intent(self, AttestationNotifyActivity.class); it.putExtra("carModel", carModel); it.putExtra("result", rs); it.putExtra("remarks", remarks); startActivity(it); } } } }); listView.setOnEmptyDataListener( new OnEmptyDataListener() { @Override public void onEmpty(boolean showeEptyView) { ViewUtil.bindView(findViewById(R.id.msg), "暂无留言"); findViewById(R.id.empty).setVisibility(showeEptyView ? View.VISIBLE : View.GONE); } }); User user = User.getInstance(); String url = API.CWBaseurl + "/user/" + user.getUserId() + "/message/list?token=" + user.getToken() + "&type=" + type; mJsonAdapter = new MessageAdapter(url, self, R.layout.item_message_list, type); mJsonAdapter.fromWhat("data"); listView.setAdapter(mJsonAdapter); // getData(); mJsonAdapter.showNextInDialog(); }