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(); } } }); }
private void isAuthen() { User user = User.getInstance(); if (user.isLogin()) { DhNet mDhNet = new DhNet(API.availableSeat + user.getUserId() + "/seats?token=" + user.getToken()); mDhNet.doGet( new NetTask(self) { @Override public void doInUI(Response response, Integer transfer) { // TODO Auto-generated method stub if (response.isSuccess()) { JSONObject json = response.jSONFrom("data"); try { User user = User.getInstance(); user.setIsAuthenticated(json.getInt("isAuthenticated")); // 认证车主 } catch (JSONException e) { e.printStackTrace(); } } } }); } }
private void uploadPic(String path) { Bitmap bmp = PhotoUtil.getLocalImage(new File(path)); picI.setImageBitmap(bmp); DhNet net = new DhNet( API.CWBaseurl + "/user/" + user.getUserId() + "/license/upload?token=" + user.getToken()); net.upload( new FileInfo("attach", new File(path)), new NetTask(self) { @Override public void doInUI(Response response, Integer transfer) { hidenProgressDialog(); if (response.isSuccess()) { JSONObject jo = response.jSONFromData(); picUid = JSONUtil.getString(jo, "photoId"); } else { showToast("上传失败,请重新上传"); picUid = ""; } } }); }
private void authtion() { if (TextUtils.isEmpty(picUid)) { showToast("请上传驾驶证!"); return; } if (TextUtils.isEmpty(drivingExperienceE.getText().toString())) { showToast("请输入驾龄!"); return; } if (Integer.parseInt(drivingExperienceE.getText().toString()) > 20 || Integer.parseInt(drivingExperienceE.getText().toString()) <= 0) { showToast("驾龄为1~20数字"); return; } if (TextUtils.isEmpty(brandName)) { showToast("请选择车型品牌!"); return; } DhNet net = new DhNet( API.CWBaseurl + "/user/" + user.getUserId() + "/authentication?token=" + user.getToken()); net.addParam("drivingExperience", drivingExperienceE.getText().toString()); net.addParam("carBrand", brandName); net.addParam("carBrandLogo", brandLogo); net.addParam("carModel", modelName); net.addParam("slug", modelSlug); net.doPostInDialog( new NetTask(self) { @Override public void doInUI(Response response, Integer transfer) { if (response.isSuccess()) { showToast("认证车主申请成功,请等待审核!"); Intent it = getIntent(); setResult(Activity.RESULT_OK, it); finish(); } } }); }
private void upLoadPic(String path) { User user = User.getInstance(); DhNet net = new DhNet(API.uploadAlbum + user.getUserId() + "/album/upload?token=" + user.getToken()); Log.e("url", net.getUrl()); net.upload( new FileInfo("attach", new File(path)), new NetTask(self) { @Override public void doInUI(Response response, Integer transfer) { if (response.isSuccess()) { IocContainer.getShare().get(IDialog.class).showToastShort(self, "图片上传成功!"); Intent it = new Intent(MainActivity.this, ManageAlbumActivity.class); it.putExtra("tempPath", tempPath); startActivity(it); } } }); }
@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(); }