优化
This commit is contained in:
@@ -22,6 +22,7 @@ import com.sw.plate.utils.ScanGunKeyEventHelper
|
||||
import com.sw.plate.utils.ToastUtils
|
||||
import com.sw.plate.utils.arcface.facedb.FaceDatabase
|
||||
import com.sw.plate.utils.arcface.facedb.entity.FaceEntity
|
||||
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
||||
import com.sw.plate.utils.comn.SerialApi
|
||||
import com.sw.plate.utils.comn.SerialPortManager
|
||||
import com.sw.platecabinet.R
|
||||
@@ -397,9 +398,13 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
fun startFaceTask() {
|
||||
faceTaskJob =
|
||||
intervalExecutor.startIntervalTaskWithInitialDelay(initialDelay, dealyMillis) {
|
||||
val timestamp = SpTool.getLastFaceTimestamp()
|
||||
if (timestamp == 0L) {
|
||||
return@startIntervalTaskWithInitialDelay
|
||||
}
|
||||
settingViewModel.getFaceIncrementList(
|
||||
pageNo = taskPageNo,
|
||||
timestamp = SpTool.getLastFaceTimestamp()
|
||||
timestamp = timestamp
|
||||
) { list ->
|
||||
runOnUiThread {
|
||||
if (list.isEmpty()) {
|
||||
@@ -412,6 +417,7 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private val recognizeViewModel by viewModels<RecognizeViewModel>()
|
||||
private fun updateFaceData(list: List<UserFaceModel>) {
|
||||
Thread {
|
||||
val faceList = mutableListOf<FaceEntity>()
|
||||
@@ -439,7 +445,7 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
if (faceList.isNotEmpty()) {
|
||||
FaceDatabase.getInstance(this).faceDao().insert(faceList)
|
||||
}
|
||||
recognizeViewModel.refreshFaceList();
|
||||
recognizeViewModel.refreshFaceList()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ package com.sw.plate.utils.arcface.facedb.entity;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.Ignore;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -42,6 +44,14 @@ public class FaceEntity implements Parcelable {
|
||||
*/
|
||||
@ColumnInfo(name = "register_time")
|
||||
private long registerTime;
|
||||
/**
|
||||
* 用户类型:1-普通会员、2-临时用户、3-内部员工、或者其它待定类型
|
||||
*/
|
||||
@ColumnInfo(name = "user_type")
|
||||
private String userType;
|
||||
|
||||
@Ignore
|
||||
private int trackId;//人脸追踪ID
|
||||
|
||||
public FaceEntity(String userName, String imagePath, byte[] featureData) {
|
||||
this.userName = userName;
|
||||
@@ -119,6 +129,22 @@ public class FaceEntity implements Parcelable {
|
||||
this.registerTime = registerTime;
|
||||
}
|
||||
|
||||
public int getTrackId() {
|
||||
return trackId;
|
||||
}
|
||||
|
||||
public void setTrackId(int trackId) {
|
||||
this.trackId = trackId;
|
||||
}
|
||||
|
||||
public String getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(String userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
@@ -131,8 +157,11 @@ public class FaceEntity implements Parcelable {
|
||||
dest.writeString(userName);
|
||||
dest.writeString(imagePath);
|
||||
dest.writeByteArray(featureData);
|
||||
dest.writeString(userType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
@@ -142,16 +171,17 @@ public class FaceEntity implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
FaceEntity that = (FaceEntity) o;
|
||||
return faceId == that.faceId &&
|
||||
registerTime == that.registerTime &&
|
||||
userName.equals(that.userName) &&
|
||||
imagePath.equals(that.imagePath) &&
|
||||
Arrays.equals(featureData, that.featureData);
|
||||
return this.faceId == that.faceId &&
|
||||
this.registerTime == that.registerTime &&
|
||||
TextUtils.equals(this.userName, that.userName) &&
|
||||
TextUtils.equals(this.imagePath, that.imagePath) &&
|
||||
Arrays.equals(featureData, that.featureData) &&
|
||||
TextUtils.equals(this.userType, that.userType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Objects.hash(faceId, registerTime, userName, imagePath);
|
||||
int result = Objects.hash(faceId, registerTime, userName, imagePath, userType);
|
||||
result = 31 * result + Arrays.hashCode(featureData);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user