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);
    // }
    // }
  }
  /** 初始化数据显示 */
  private void initDatas() {

    try {
      mOldUserBean =
          (UserModel) getIntent().getSerializableExtra(Constants.IntentData.INTENT_USER_BEAN);
      mNewUserBean = (UserModel) UtilsJava.depthClone(mOldUserBean);
    } catch (Exception e) {
      ErrLogUtils.uploadErrLog(this, ErrLogUtils.toString(e));
    }
  }
Example #3
0
  // 二维码判断;
  private boolean QRcodeScan(String jsonQR) {
    // {"cmpid":"8888","itemid":"01",
    // "ordernos":[{"orderno":"1234567890123"},
    // {"orderno":"1234567890123"},
    // {"orderno":"1234567890123"},..]}

    try {
      JSONObject jsonObject = new JSONObject(jsonQR);
      String cmpid = jsonObject.getString("cmpid");
      String itemid = jsonObject.getString("itemid");
      JSONArray jsonOrdernos = jsonObject.getJSONArray("ordernos");
      if (scanList.size() + jsonOrdernos.length() > Constants.Value.SCAN_COUNT) {
        showShortToast(R.string.one_time_add_100);
      } else {
        for (int i = 0; i < jsonOrdernos.length(); i++) {
          JSONObject jsonOrder = (JSONObject) jsonOrdernos.get(i);
          String orderno = jsonOrder.getString("orderno").toUpperCase();
          if (!scanList.contains(orderno.toUpperCase())) {
            scanList.add(0, orderno.toUpperCase());
          }
        }
      }
      mTextScanCount.setText(
          String.format(
              getString(R.string.barcode_total), PreferencesUtil.ordtitle, scanList.size()));
      mTextOrderNum.setText(scanList.get(0));
      //            mTextOrderNum.setBackgroundResource(R.drawable.bg_line);
      mTextOrderNum.setBackgroundColor(Color.parseColor("#313131"));
      if (scanList.size() < Constants.Value.SCAN_COUNT) {
        // 延迟1秒,减少扫描的过分灵敏度
        handler.sendEmptyMessageDelayed(R.id.restart_preview, 1000);
      }

    } catch (Exception ex) {
      handler.sendEmptyMessageDelayed(R.id.restart_preview, 1000);
      String msg =
          String.format(
              getString(R.string.order_scan_error_msg),
              PreferencesUtil.ordtitle + "",
              PreferencesUtil.code_length + "");
      showShortToast(msg);
      ex.printStackTrace();
      String time = UtilsJava.translate2SessionMessageData(System.currentTimeMillis());
      String errorMsg = "Time=" + time + "\n" + jsonQR.toString() + "\n" + ErrLogUtils.toString(ex);
      ErrLogUtils.uploadErrLog(this, errorMsg);
      return false;
    }
    return true;
  }