// 二维码判断; 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; }