添加init界面,调整了认证后逻辑,调整了扫描枪扫描处理

This commit is contained in:
zxj
2025-08-01 18:23:54 +08:00
parent d20ee771b0
commit 47f6e814a6
22 changed files with 279 additions and 197 deletions
+2 -1
View File
@@ -18,4 +18,5 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile
-keep class androidx.core.app.CoreComponentFactory { *; }
@@ -23,9 +23,9 @@ public class ScanGunKeyEventHelper {
// private String mDeviceName = "TMC HIDKeyBoard";
private String mDeviceName = "Linux 3.4.35 with ak-hsudc Composite Gadget (ACM + HID)";
private String mDeviceName1 = "USBKey Chip USBKey Module";
private long lastTime = 0L;
public ScanGunKeyEventHelper(Context context, OnScanSuccessListener onScanSuccessListener) {
mContext = context;
mOnScanSuccessListener = onScanSuccessListener;
mStringBufferResult = new StringBuffer();
@@ -38,6 +38,14 @@ public class ScanGunKeyEventHelper {
*/
private void performScanSuccess() {
String barcode = mStringBufferResult.toString();
L.d("performScanSuccess barcode = " + barcode);
long currentTime = System.currentTimeMillis();
if (currentTime - lastTime < 5 * 1000) {
L.d("performScanSuccess 操作太频繁");
mStringBufferResult.setLength(0);
return;
}
lastTime = currentTime;
if (mOnScanSuccessListener != null && !TextUtils.isEmpty(barcode))
mOnScanSuccessListener.onScanSuccess(barcode);
mStringBufferResult.setLength(0);
@@ -34,4 +34,10 @@ public class SerialApi {
}
serialPortManager.sendCommand(generateOpenCommand(boxNumber), callback);
}
public static void close() {
if (serialPortManager != null) {
serialPortManager.close();
}
}
}