示例#1
0
  /** 更新资料编辑 */
  protected void updateInfoData() {
    getUserData();
    // 添加要上传的图片
    // addUploadImages();

    // 判断用户是否修改了资料
    if (mNewUserBean.equals(mOldUserBean) && Bimp.imgPath.size() == 0) {
      showLongToast(getString(R.string.eidt_info_tip_msg));
      return;
    }
    // 设置用户操作的动作码
    PreferencesUtil.setSteps(Constants.Step.SAVE);
    mNewUserBean.imgList = Bimp.getUploadImg();
    // 提交编辑请求
    // AsyncHttpService.modifyUserInfo(mNewUserBean, imgList,
    AsyncHttpService.modifyUserInfo(
        mNewUserBean,
        new JsonHttpResponseHandler() {

          @Override
          public void onStart() {
            showLoadDialog((R.string.is_submitted_ellipsis));
            super.onStart();
          }

          @Override
          public void onFailure(
              int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
            super.onFailure(statusCode, headers, throwable, errorResponse);
            showLongToast(getString(R.string.httpisNull));
            mDialogLoading.dismiss();
          }

          @Override
          public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            Log.d(TAG, "info: " + response.toString());
            dismissLoadDialog();
            super.onSuccess(statusCode, headers, response);
            try {
              if (UtilsError.isErrorCode(EditInfoActivity.this, response)) {
                return;
              }

              PreferencesUtil.putValue(PreferencesUtil.KEY_USER_NAME, mNewUserBean.userName);
              showLongToast(R.string.data_editor_success);
              thisFinish();

            } catch (Exception e) {
              dismissLoadDialog();
              e.printStackTrace();
              ErrLogUtils.uploadErrLog(EditInfoActivity.this, ErrLogUtils.toString(e));
            }
          }
        },
        this);
  }
示例#2
0
  private void getUserData() {
    mNewUserBean.userName = mEditName.getText().toString().trim();
    mNewUserBean.truckNum = mEditPlate.getText().toString().trim();
    // 如果用户为车辆用户,则获取相应信息
    if (Constants.Value.YES.equals(PreferencesUtil.is_driver)) {
      mNewUserBean.truckNum = mEditPlate.getText().toString().trim();
      mNewUserBean.truckType = mEditModel.getText().toString().trim();
      try {
        mNewUserBean.truckLength = Double.parseDouble(mEditLength.getText().toString());
        mNewUserBean.truckWeight = Double.parseDouble(mEidtLoad.getText().toString());
      } catch (Exception e) {
        ErrLogUtils.uploadErrLog(this, ErrLogUtils.toString(e));
        finish();
      }
    }

    // // 去掉重复的图片
    // Set<String> set = new HashSet<String>();
    // set.addAll(Bimp.drr);
    //
    // for (String path : set) {
    // path = path.substring(path.lastIndexOf("/") + 1,
    // path.lastIndexOf("."));
    // path = UtilsAndroid.Sdcard.SDPATH_FORMATS + path + ".JPEG";
    // File file = new File(path);
    // System.out.println("ipath:" + path);
    // if (file.exists()) {
    // imgList.add(path);
    // }
    // }
  }