优化识别及增加扫码枪逻辑
This commit is contained in:
@@ -8,6 +8,9 @@ import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 扫描枪事件处理
|
||||
*/
|
||||
@@ -21,11 +24,17 @@ public class ScanGunKeyEventHelper {
|
||||
private final Context mContext;
|
||||
|
||||
// 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 String mDeviceName = "Linux 3.4.35 with ak-hsudc Composite Gadget (ACM + HID)";
|
||||
//private String mDeviceName1 = "USBKey Chip USBKey Module";
|
||||
|
||||
private String[] deviceNameArray = new String[]{
|
||||
"CROWN CROWN Barcode KeyBorad FS",
|
||||
"Linux 3.4.35 with ak-hsudc Composite Gadget (ACM + HID)",
|
||||
"USBKey Chip USBKey Module"
|
||||
};
|
||||
private long lastTime = 0L;
|
||||
|
||||
public ScanGunKeyEventHelper(Context context, OnScanSuccessListener onScanSuccessListener) {
|
||||
|
||||
mContext = context;
|
||||
mOnScanSuccessListener = onScanSuccessListener;
|
||||
mStringBufferResult = new StringBuffer();
|
||||
@@ -38,6 +47,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);
|
||||
@@ -161,6 +178,8 @@ public class ScanGunKeyEventHelper {
|
||||
L.e("event===" + deviceName +
|
||||
"===Char===" + event.getCharacters() +
|
||||
"===Action===" + event.getAction());
|
||||
return deviceName.equals(mDeviceName) || deviceName.equals(mDeviceName1);
|
||||
//return deviceName.equals(mDeviceName) || deviceName.equals(mDeviceName1);
|
||||
List<String> devices = Arrays.asList(deviceNameArray);
|
||||
return devices.contains(deviceName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,10 +45,15 @@ public class FaceEntity implements Parcelable {
|
||||
@ColumnInfo(name = "register_time")
|
||||
private long registerTime;
|
||||
/**
|
||||
* 用户类型:1-普通会员、2-临时用户、3-内部员工、或者其它待定类型
|
||||
* 用户类型:1-普通会员、2-临时用户、或者其它待定类型
|
||||
*/
|
||||
@ColumnInfo(name = "user_type")
|
||||
private String userType;
|
||||
/**
|
||||
* 会员编号
|
||||
*/
|
||||
@ColumnInfo(name = "cardNo")
|
||||
private String cardNo;
|
||||
|
||||
@Ignore
|
||||
private int trackId;//人脸追踪ID
|
||||
@@ -66,6 +71,8 @@ public class FaceEntity implements Parcelable {
|
||||
this.imagePath = faceEntity.imagePath;
|
||||
this.featureData = faceEntity.featureData;
|
||||
this.registerTime = faceEntity.registerTime;
|
||||
this.userType = faceEntity.getUserType();
|
||||
this.cardNo = faceEntity.getCardNo();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +82,8 @@ public class FaceEntity implements Parcelable {
|
||||
userName = in.readString();
|
||||
imagePath = in.readString();
|
||||
featureData = in.createByteArray();
|
||||
userType = in.readString();
|
||||
cardNo = in.readString();
|
||||
}
|
||||
|
||||
public static final Creator<FaceEntity> CREATOR = new Creator<FaceEntity>() {
|
||||
@@ -145,6 +154,16 @@ public class FaceEntity implements Parcelable {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public String getCardNo() {
|
||||
return cardNo;
|
||||
}
|
||||
|
||||
public void setCardNo(String cardNo) {
|
||||
this.cardNo = cardNo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
@@ -158,10 +177,9 @@ public class FaceEntity implements Parcelable {
|
||||
dest.writeString(imagePath);
|
||||
dest.writeByteArray(featureData);
|
||||
dest.writeString(userType);
|
||||
dest.writeString(cardNo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
@@ -176,12 +194,13 @@ public class FaceEntity implements Parcelable {
|
||||
TextUtils.equals(this.userName, that.userName) &&
|
||||
TextUtils.equals(this.imagePath, that.imagePath) &&
|
||||
Arrays.equals(featureData, that.featureData) &&
|
||||
TextUtils.equals(this.userType, that.userType);
|
||||
TextUtils.equals(this.userType, that.userType) &&
|
||||
TextUtils.equals(this.cardNo, that.cardNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Objects.hash(faceId, registerTime, userName, imagePath, userType);
|
||||
int result = Objects.hash(faceId, registerTime, userName, imagePath, userType, cardNo);
|
||||
result = 31 * result + Arrays.hashCode(featureData);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user