餐盘柜优化
This commit is contained in:
@@ -58,7 +58,7 @@ class UserViewModel : BaseViewModel() {
|
||||
/**
|
||||
* 获取人脸数据
|
||||
*/
|
||||
fun getUserFaceCache(pageNo: Int = 1, pageSize: Int = PAGE_SIZE) {
|
||||
fun getUserFaceCache(pageNo: Int = 1, pageSize: Int = PAGE_SIZE, refreshFaceBlock: () -> Unit={}) {
|
||||
var currentPageNo = pageNo
|
||||
launchWithLoading {
|
||||
val response = repository.getUserFaceCache(pageNum = pageNo, pageSize = pageSize)
|
||||
@@ -66,7 +66,7 @@ class UserViewModel : BaseViewModel() {
|
||||
// 获取成功一次后缓存状态
|
||||
SPUtil.getInstance().put(GlobalKey.KEY_FIRST_RUN, true)
|
||||
val list: List<UserFaceModel> = response.data ?: emptyList()
|
||||
if (pageNo==1&&list.isEmpty()) {
|
||||
if (pageNo == 1 && list.isEmpty()) {
|
||||
return@launchWithLoading
|
||||
}
|
||||
val faceEntityList = list.map {
|
||||
@@ -74,14 +74,18 @@ class UserViewModel : BaseViewModel() {
|
||||
}
|
||||
withContext(Dispatchers.Default) {
|
||||
faceApi.updateFaceData(pageNo, faceEntityList)
|
||||
refreshFaceBlock()
|
||||
if (list.size >= pageSize) {
|
||||
faceTimestamp = list.last().faceUpdateTimestamp?:0
|
||||
faceTimestamp = list.last().faceUpdateTimestamp ?: 0
|
||||
currentPageNo++
|
||||
getUserFaceCache(currentPageNo)
|
||||
getUserFaceCache(
|
||||
pageNo = currentPageNo,
|
||||
refreshFaceBlock = refreshFaceBlock
|
||||
)
|
||||
return@withContext
|
||||
}
|
||||
if (list.isNotEmpty()) {
|
||||
faceTimestamp = list.last().faceUpdateTimestamp?:0
|
||||
faceTimestamp = list.last().faceUpdateTimestamp ?: 0
|
||||
}
|
||||
SpTool.lastFaceTimestamp = faceTimestamp
|
||||
//activeEngine()
|
||||
@@ -147,7 +151,7 @@ class UserViewModel : BaseViewModel() {
|
||||
/**
|
||||
* 通过用户id获取用户信息
|
||||
*/
|
||||
fun getUserInfoById(memberId: String?, action:(EquipmentUserInfo?)->Unit={}) {
|
||||
fun getUserInfoById(memberId: String?, action: (EquipmentUserInfo?) -> Unit = {}) {
|
||||
_currentUserInfo.value = null
|
||||
launchWithLoading {
|
||||
val loginParam = LoginParam(faceId = memberId)
|
||||
@@ -166,6 +170,7 @@ class UserViewModel : BaseViewModel() {
|
||||
Timber.d("resetUserInfo")
|
||||
_currentUserInfo.value = null
|
||||
}
|
||||
|
||||
fun getDeviceConfig(block: (DeviceConfig?) -> Unit) {
|
||||
// Timber.tag(TAG).d("getDeviceConfig")
|
||||
launch {
|
||||
|
||||
Reference in New Issue
Block a user