优化
This commit is contained in:
@@ -419,16 +419,17 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
// private val dealyMillis = 10 * 60 * 1000L
|
// private val dealyMillis = 10 * 60 * 1000L
|
||||||
private val initialDelay = 5 * 60 * 1000L
|
private val initialDelay = 5 * 60 * 1000L
|
||||||
private val dealyMillis = 5 * 60 * 1000L
|
private val dealyMillis = 5 * 60 * 1000L
|
||||||
fun startFaceTask() {
|
fun startFaceTask(block: (List<String?>) -> Unit) {
|
||||||
faceTaskJob =
|
faceTaskJob =
|
||||||
intervalExecutor.startIntervalTaskWithInitialDelay(initialDelay, dealyMillis) {
|
intervalExecutor.startIntervalTaskWithInitialDelay(initialDelay, dealyMillis) {
|
||||||
getFaceIncrementList()
|
getFaceIncrementList(action = block)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var faceTimestamp = 0L
|
private var faceTimestamp = 0L
|
||||||
|
|
||||||
//private var taskPageNo = 1
|
//private var taskPageNo = 1
|
||||||
private fun getFaceIncrementList(pageNo: Int = 1) {
|
private fun getFaceIncrementList(pageNo: Int = 1, action:(List<String?>)-> Unit) {
|
||||||
val timestamp = SpTool.lastFaceTimestamp
|
val timestamp = SpTool.lastFaceTimestamp
|
||||||
if (timestamp == 0L) {
|
if (timestamp == 0L) {
|
||||||
return
|
return
|
||||||
@@ -443,6 +444,8 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
return@runOnUiThread
|
return@runOnUiThread
|
||||||
}
|
}
|
||||||
updateFaceData(list)
|
updateFaceData(list)
|
||||||
|
val userIdList = list.map { it.userId }
|
||||||
|
action(userIdList)
|
||||||
//if (list.size >= settingViewModel.PAGE_SIZE) {
|
//if (list.size >= settingViewModel.PAGE_SIZE) {
|
||||||
// faceTimestamp = list.last().faceUpdateTimestamp ?: 0
|
// faceTimestamp = list.last().faceUpdateTimestamp ?: 0
|
||||||
// taskPageNo++
|
// taskPageNo++
|
||||||
@@ -461,12 +464,15 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
private fun updateFaceData(list: List<UserFaceModel>) {
|
private fun updateFaceData(list: List<UserFaceModel>) {
|
||||||
Thread {
|
Thread {
|
||||||
val faceList = mutableListOf<FaceEntity>()
|
val faceList = mutableListOf<FaceEntity>()
|
||||||
|
val faceDao = FaceDatabase.getInstance(this).faceDao()
|
||||||
try {
|
try {
|
||||||
list.forEach { model ->
|
list.forEach { model ->
|
||||||
if (model.faceDeleted == true) {
|
if (model.faceDeleted == true) {
|
||||||
//删除数据
|
//删除数据
|
||||||
FaceDatabase.getInstance(this).faceDao().deleteFaceById(model.userId)
|
faceDao.deleteFaceById(model.userId)
|
||||||
} else {
|
} else {
|
||||||
|
val faceData = faceDao.queryByUserName(model.userId)
|
||||||
|
if (faceData == null) {
|
||||||
//保存数据
|
//保存数据
|
||||||
val faceEntity = FaceEntity(
|
val faceEntity = FaceEntity(
|
||||||
model.userId,
|
model.userId,
|
||||||
@@ -479,6 +485,7 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
faceList.add(faceEntity)
|
faceList.add(faceEntity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,11 +53,12 @@ class DeviceInitActivity : BaseActivity<ActivityDeviceInitBinding>() {
|
|||||||
userViewModel.getUserFaceCache { status, msg ->
|
userViewModel.getUserFaceCache { status, msg ->
|
||||||
getDeviceConfig()
|
getDeviceConfig()
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
}
|
|
||||||
}
|
|
||||||
getDeviceConfig()
|
getDeviceConfig()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getDeviceConfig() {
|
private fun getDeviceConfig() {
|
||||||
userViewModel.getDeviceConfig { deviceConfig ->
|
userViewModel.getDeviceConfig { deviceConfig ->
|
||||||
|
|||||||
@@ -138,7 +138,9 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
//开启人脸增量数据定时任务
|
//开启人脸增量数据定时任务
|
||||||
startFaceTask()
|
startFaceTask {
|
||||||
|
loadLogInfo("collectFace增量接口数据用户id:${Gson().toJson(it)}")
|
||||||
|
}
|
||||||
|
|
||||||
val soundMap = hashMapOf<String, Int>()
|
val soundMap = hashMapOf<String, Int>()
|
||||||
soundMap[COLLECT_SUCCESS] = R.raw.collect_success
|
soundMap[COLLECT_SUCCESS] = R.raw.collect_success
|
||||||
@@ -827,6 +829,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
private var currentUserId: String? = null
|
private var currentUserId: String? = null
|
||||||
|
|
||||||
private fun saveFaceInfo(faceModel: UserFaceModel) {
|
private fun saveFaceInfo(faceModel: UserFaceModel) {
|
||||||
|
Thread {
|
||||||
try {
|
try {
|
||||||
loadLogInfo("collectFace,saveFaceInfo: ----------8,保存人脸取特征数据-----------")
|
loadLogInfo("collectFace,saveFaceInfo: ----------8,保存人脸取特征数据-----------")
|
||||||
val faceDao = FaceDatabase.getInstance(this).faceDao()
|
val faceDao = FaceDatabase.getInstance(this).faceDao()
|
||||||
@@ -852,6 +855,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
loadLogInfo("collectFace,saveFaceInfo: ----------14,${collectCount}次人脸采集异常:${e.message}-----------")
|
loadLogInfo("collectFace,saveFaceInfo: ----------14,${collectCount}次人脸采集异常:${e.message}-----------")
|
||||||
ToastUtils.showToast("人脸采集异常:${e.message}")
|
ToastUtils.showToast("人脸采集异常:${e.message}")
|
||||||
}
|
}
|
||||||
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private var collectCount = 0
|
private var collectCount = 0
|
||||||
|
|||||||
@@ -26,9 +26,11 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvContent"
|
android:id="@+id/tvContent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="30dp"
|
android:layout_marginTop="30dp"
|
||||||
|
android:layout_marginHorizontal="50dp"
|
||||||
|
android:gravity="center"
|
||||||
tools:text="解绑后该用户将无法使用餐盘柜"
|
tools:text="解绑后该用户将无法使用餐盘柜"
|
||||||
android:textColor="#ff999999"
|
android:textColor="#ff999999"
|
||||||
android:textSize="24sp"/>
|
android:textSize="24sp"/>
|
||||||
|
|||||||
@@ -1,31 +1,29 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
android:layout_width="240dp"
|
android:layout_width="240dp"
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
android:background="@drawable/dialog_waiting">
|
android:background="@drawable/dialog_waiting">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:indeterminateTint="@color/teal_200"
|
||||||
|
android:indeterminateTintMode="src_atop" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvTip"
|
android:id="@+id/tvTip"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_marginStart="30dp"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:text="请稍等"
|
android:text="请稍等"
|
||||||
android:textSize="22sp" />
|
android:textSize="22sp" />
|
||||||
|
|
||||||
<ProgressBar
|
</LinearLayout>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_marginRight="30dp"
|
|
||||||
android:layout_toLeftOf="@id/tvTip"
|
|
||||||
android:indeterminateTint="@color/teal_200"
|
|
||||||
android:indeterminateTintMode="src_atop" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
Reference in New Issue
Block a user