示例#1
0
  /** Returns an HttpEntity containing all request parameters */
  public HttpEntity getEntity() {

    if (bodyEntity != null) {
      return bodyEntity;
    }

    HttpEntity result = null;

    if (fileParams != null && !fileParams.isEmpty()) {

      MultipartEntity multipartEntity =
          new MultipartEntity(HttpMultipartMode.STRICT, boundary, Charset.forName(charset));

      if (bodyParams != null && !bodyParams.isEmpty()) {
        for (NameValuePair param : bodyParams) {
          try {
            multipartEntity.addPart(param.getName(), new StringBody(param.getValue()));
          } catch (UnsupportedEncodingException e) {
            LogUtils.e(e.getMessage(), e);
          }
        }
      }

      for (ConcurrentHashMap.Entry<String, ContentBody> entry : fileParams.entrySet()) {
        multipartEntity.addPart(entry.getKey(), entry.getValue());
      }

      result = multipartEntity;
    } else if (bodyParams != null && !bodyParams.isEmpty()) {
      result = new BodyParamsEntity(bodyParams, charset);
    }

    return result;
  }
  @Override
  public void onClick(View v) {

    switch (v.getId()) {
      case R.id.tv_cancel:
        if (shopOperatorBean != null) {
          showProgressDialog(true);
          ShopOperatorServer.onDeleteOperator_xutils(shopOperatorBean.getId(), this);
        }
        break;
      case R.id.tv_ok:
        // 修改
        user = et_user.getText().toString().trim(); // 用户名
        name = et_name.getText().toString().trim(); // 真实姓名
        id = et_id.getText().toString().trim(); // 身份证
        num = et_num.getText().toString().trim(); // 电话号码
        pwd = et_pwd.getText().toString().trim(); // 密码
        System.out.println(">>>>>>>>>>>>>>是否接收短信<<<<<<<<<<<<" + ismessage);
        if (match()) {
          showProgressDialog(true);
          RequestParams params = BaseServer.getParams();
          MultipartEntity multipartEntity = new MultipartEntity();
          multipartEntity.setMultipartSubtype(
              "multipart/form-data; boundary=--ling--"); // 加上这个就不报404了,坑
          params.setBodyEntity(multipartEntity);
          params.addQueryStringParameter("username", user);
          params.addQueryStringParameter("password", pwd);
          params.addQueryStringParameter("name", name);
          params.addQueryStringParameter("phoneNumber", num);
          params.addQueryStringParameter("cardNumber", id);
          params.addQueryStringParameter("receiveSms", ismessage);
          ShopOperatorServer.onUpdateOperator_xutils(params, OperatorDetailsActivity.this);
        }
        break;

      default:
        break;
    }
  }