Ejemplo n.º 1
0
  private void addOrderData(String orderId) {

    if (scanList.contains(orderId)) {
      showShortToast(R.string.order_alreader_add);
      // 延迟1秒,减少扫描的过分灵敏度
      handler.sendEmptyMessageDelayed(R.id.restart_preview, 1000);
    } else if (scanList.size() < Constants.Value.SCAN_COUNT) {

      scanList.add(0, orderId);
      saveOperateLog("扫描单号:" + orderId, null);
      Set<String> set = new HashSet<String>();
      set.addAll(scanList);

      String msg = String.format(getString(R.string.added_x_list), PreferencesUtil.ordtitle);
      // "已添加到" + PreferencesUtil.ordtitle + "列表中",
      showShortToast(msg);
      // 延迟1秒,减少扫描的过分灵敏度
      handler.sendEmptyMessageDelayed(R.id.restart_preview, 1000);
    } else {
      showShortToast(R.string.one_time_add_100);
    }

    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"));
  }
Ejemplo n.º 2
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;
  }
Ejemplo n.º 3
0
  private String barCodeScan(String barCode) {
    barCode = barCode.replace("-", "").toUpperCase();

    addOrderData(barCode);
    // 延迟1秒,减少扫描的过分灵敏度
    handler.sendEmptyMessageDelayed(R.id.restart_preview, 1000);
    return barCode;
  }
Ejemplo n.º 4
0
 @Override
 protected void onPause() {
   super.onPause();
   if (handler != null) {
     handler.quitSynchronously();
     handler = null;
   }
   CameraManager.get().closeDriver();
 }