代码优化
This commit is contained in:
@@ -396,6 +396,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
SpTool.savePlateData(items)
|
||||
}
|
||||
}
|
||||
|
||||
private val openDebouncer by lazy { Debouncer(5000) }
|
||||
|
||||
private fun initArcView() {
|
||||
@@ -407,10 +408,8 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
|
||||
override fun onDestroy() {
|
||||
loadLogInfo("onDestroy")
|
||||
if (rgbCameraHelper != null) {
|
||||
rgbCameraHelper?.release()
|
||||
rgbCameraHelper = null
|
||||
}
|
||||
|
||||
recognizeViewModel.destroy()
|
||||
|
||||
@@ -605,10 +604,10 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
}
|
||||
}
|
||||
|
||||
fun openRectInfoDraw(view: View?) {
|
||||
openRectInfoDraw = !openRectInfoDraw
|
||||
recognizeViewModel.setDrawRectInfoTextValue(openRectInfoDraw)
|
||||
}
|
||||
// fun openRectInfoDraw(view: View?) {
|
||||
// openRectInfoDraw = !openRectInfoDraw
|
||||
// recognizeViewModel.setDrawRectInfoTextValue(openRectInfoDraw)
|
||||
// }
|
||||
|
||||
|
||||
override fun onGlobalLayout() {
|
||||
@@ -623,7 +622,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
if (rgbCameraHelper != null && rgbCameraHelper!!.isStopped) {
|
||||
loadLogInfo("collectFace,resumeCamera: ")
|
||||
isRecognition = true
|
||||
rgbCameraHelper?.start()
|
||||
rgbCameraHelper!!.start()
|
||||
} else {
|
||||
//recognizeViewModel.onPreviewFrame(ByteArray(1382400), true)
|
||||
|
||||
@@ -736,7 +735,9 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
|
||||
private fun judgeRecognizeState(): Boolean {
|
||||
val rectColor = binding.dualCameraFaceRectView.rectColor
|
||||
if (rectColor == RecognizeColor.COLOR_SUCCESS && currentUserId.isNullOrBlank().not() && facePreviewInfoList.isNullOrEmpty().not()) {
|
||||
if (rectColor == RecognizeColor.COLOR_SUCCESS && currentUserId.isNullOrBlank()
|
||||
.not() && facePreviewInfoList.isNullOrEmpty().not()
|
||||
) {
|
||||
//人未离开,再次识别
|
||||
loadLogInfo("userId=$currentUserId")
|
||||
openPlateDebouncer.debounce {
|
||||
@@ -803,7 +804,8 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
saveFaceInfo(faceModel) {
|
||||
runOnUiThread {
|
||||
Glide.with(this@LoginByFaceActivity).load(imageFile).into(binding.ivCollectPhoto)
|
||||
Glide.with(this@LoginByFaceActivity).load(imageFile)
|
||||
.into(binding.ivCollectPhoto)
|
||||
}
|
||||
}
|
||||
uploadFaceDebouncer.reset()
|
||||
@@ -891,12 +893,11 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||
return@startCountDown
|
||||
}
|
||||
}, onFinish = {
|
||||
CountDownUtil.cancelCountDown()
|
||||
if (facePreviewInfoList.isNullOrEmpty().not()) {
|
||||
loadLogInfo("leftCountDown.onFinish-cancel()")
|
||||
CountDownUtil.cancelCountDown()
|
||||
return@startCountDown
|
||||
}
|
||||
CountDownUtil.cancelCountDown()
|
||||
goInitActivity()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user