- 新增ApiServiceV2接口定义,支持人脸缓存、增量数据、设备配置等功能 - 添加NetViewModelV2视图模型,实现新版本API的数据处理逻辑 - 创建RemoteRepositoryV2仓库,封装API V2的网络请求操作 - 新增UserFaceModelV2数据模型,优化人脸特征数据结构 - 添加DeviceConfigV2设备配置模型,支持更多设备参数 - 在ApiClient中注册apiServiceV2实例 - 更新BaseActivity使用NetViewModelV2替代UserViewModel - 修改DeviceInitActivity中的人脸数据获取和设备配置逻辑 - 重构FaceDao数据库访问对象,优化用户类型查询和删除操作 - 更新FaceEntity实体类,增加更多用户相关字段 - 移除BaseViewModel中的旧版网络基础功能代码 - 优化人脸数据同步和存储流程,提升性能表现
74 lines
2.4 KiB
Kotlin
74 lines
2.4 KiB
Kotlin
//package com.sw.platecabinet.viewmodel
|
|
//
|
|
//import androidx.lifecycle.ViewModel
|
|
//import androidx.lifecycle.viewModelScope
|
|
//import com.sw.plate.utils.ToastUtils
|
|
//import com.sw.platecabinet.model.response.ApiResponse
|
|
//import com.sw.platecabinet.network.ApiClient
|
|
//import com.sw.platecabinet.repository.RemoteRepository
|
|
//import kotlinx.coroutines.flow.MutableStateFlow
|
|
//import kotlinx.coroutines.flow.StateFlow
|
|
//import kotlinx.coroutines.launch
|
|
//import timber.log.Timber
|
|
//
|
|
//abstract class BaseViewModel() : ViewModel() {
|
|
// protected val repository = RemoteRepository(ApiClient.apiService)
|
|
//
|
|
// // 显示进度条
|
|
// private val _showLoading = MutableStateFlow<Boolean>(false)
|
|
// val showLoading: StateFlow<Boolean> = _showLoading
|
|
//
|
|
// /**
|
|
// * 带进度条的请求
|
|
// */
|
|
// protected fun launchWithLoading(block: suspend () -> Unit) {
|
|
// viewModelScope.launch {
|
|
// try {
|
|
// _showLoading.value = true
|
|
// block()
|
|
// } catch (e: Exception) {
|
|
// // 错误处理可被子类重写
|
|
// handleError(e)
|
|
// } finally {
|
|
// _showLoading.value = false
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// /**
|
|
// * 不带进度条的请求
|
|
// */
|
|
// protected fun launch(block: suspend () -> Unit) {
|
|
// viewModelScope.launch() {
|
|
// try {
|
|
// block()
|
|
// } catch (e: Exception) {
|
|
// // 错误处理可被子类重写
|
|
// handleError(e)
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// protected open fun parseResponse(response: ApiResponse<*>): Boolean {
|
|
// if (response.isSuccess()) {
|
|
// return true
|
|
// }
|
|
// Timber.d("msg = ${response.msg}, code = ${response.code}")
|
|
// ToastUtils.showToast("${response.msg}(${response.code})")
|
|
// return false
|
|
// }
|
|
//
|
|
//
|
|
// fun handleError(exception: Exception) {
|
|
// Timber.d("handleError ${exception.message}")
|
|
// }
|
|
//
|
|
//// fun parseEquipmentInfo(equipmentInfo: EquipmentInfo) {
|
|
////// GlobalData.appBaseUrl = equipmentInfo.appPackageUrl!!
|
|
////// GlobalData.appBaseUrl="https://vip.shuziweidao.com"
|
|
////// GlobalData.sdkKey = equipmentInfo.arcsoftSdkKey!!
|
|
////// GlobalData.appId = equipmentInfo.arcsoftAppId!!
|
|
////// GlobalData.activeKey = equipmentInfo.arcsoftActiveKey!!
|
|
////// GlobalData.restId = equipmentInfo.canteenId!!
|
|
//// }
|
|
//} |