コード例 #1
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (ScanOrdersActivity.RESULT_CODE_LOOK_ORDER == resultCode) {
      // 从订单查看列表页返回
      scanList = data.getStringArrayListExtra(ScanOrdersActivity.EXTRA_ORDER_LIST);
    } else if (OrderExecuteActivity.REQUEST_CODE_EXECUTE_ORDER == resultCode) {
      // 从订单执行提交页返回,清空扫描订单缓存
      scanList.clear();

    } else if (RESULT_CODE_ADD_REPORT == resultCode) {
      // 从异常报告提交页返回,清空扫描订单缓存
      scanList.clear();
    }
    mNewOrder = (ExecuteAction) UtilsJava.depthClone(mNewOrder);
    // 去除重复数据,更新界面提示信息
    Set<String> set = new HashSet<String>();
    set.addAll(scanList);
    mTextScanCount.setText(
        String.format(getString(R.string.barcode_total), PreferencesUtil.ordtitle, set.size()));
    if (scanList.size() == 0) {
      mTextOrderNum.setText("");
      mTextOrderNum.setBackgroundColor(Color.parseColor("#00000000"));
    }
    super.onActivityResult(requestCode, resultCode, data);
  }
コード例 #2
0
  /** 初始化数据显示 */
  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));
    }
  }
コード例 #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;
  }
コード例 #4
0
 private void initBaseData() {
   // test is third party
   isThirdParty = false;
   mThirdOrderList = new ArrayList<String>();
   // init store data;
   if (TextUtils.isEmpty(PreferencesUtil.user_company)) {
     PreferencesUtil.initStoreData();
   }
   // get Order data , copy order data;
   mOrderModel =
       (ExecuteAction) getIntent().getExtras().getSerializable(Constants.Feild.KEY_ACTION);
   mNewOrder = (ExecuteAction) UtilsJava.depthClone(mOrderModel);
   // get Scan Model;
   String options = PreferencesUtil.getValue(Constants.Feild.KEY_OPTIONS);
   if (!TextUtils.isEmpty(options)) {
     try {
       JSONObject jsonObject = new JSONObject(options);
       if (!jsonObject.isNull("scanModel")) mScanModel = jsonObject.getString("scanModel");
     } catch (JSONException e) {
       e.printStackTrace();
     }
   }
 }