refactor(servicing): 重构司机信息获取逻辑

- 更新 Api 定义,将 GeneralInfo 请求的返回类型改为 DriverInfoBean- 重构 GlobalData 类,使用 GlobalLocalData 类封装本地数据操作
- 优化 ConfirmEleScreen组件,增加 ConfirmEleCheckBoxItem复用组件
- 调整签名视图的字体大小- 移除 VerifyOrderActivity 中的冗余代码
- 更新 ZDManager 中的 MMKV 初始化逻辑
This commit is contained in:
songzhiling
2025-04-23 10:02:11 +08:00
parent f0f6810efd
commit c606ed95cd
11 changed files with 195 additions and 273 deletions

View File

@ -9,7 +9,7 @@ import com.za.common.log.LogUtil
import com.za.room.RoomHelper
import com.za.room.db.user.DriverInfoBean
object GlobalData {
object GlobalData : GlobalLocalData() {
lateinit var application : Application
private val mmkv : MMKV by lazy { MMKV.defaultMMKV() }
var activityCount : Int = 0
@ -45,26 +45,21 @@ object GlobalData {
//新订单是否已经被处理
var isHandlerNewOrder : Boolean? = false
private val lock = Any()
var driverInfoBean : DriverInfoBean?
var driverInfoBean : DriverInfoBean? = null
get() {
synchronized(lock) {
val driverInfoBean =
mmkv.decodeParcelable("driverInfoBean", DriverInfoBean::class.java)
LogUtil.print("driverInfo get", "driverInfoBean = $driverInfoBean")
return driverInfoBean
if (field == null) {
field = localDriverInfoBean
}
LogUtil.print("get driverInfoBean", "获取司机信息: $field")
return field
}
set(value) {
synchronized(lock) {
mmkv.encode("driverInfoBean", value)
if (value != null) {
lastLoginBean = value
}
LogUtil.print("driverInfo set", "driverInfoBean = $value")
}
localDriverInfoBean = value
field = value
LogUtil.print("set driverInfoBean", "司机信息: $field")
}
var lastLoginBean : DriverInfoBean? = null
get() {
val driverInfoBean = mmkv.decodeParcelable("lastLoginBean", DriverInfoBean::class.java)
@ -85,17 +80,16 @@ object GlobalData {
field = value
}
var currentOrder : OrderInfo? = null
get() {
return mmkv.decodeParcelable("currentOrder", OrderInfo::class.java)
if (field == null) {
field = localCurrentOrder
}
return field
}
set(value) {
mmkv.encode("currentOrder", value)
if (RoomHelper.db?.orderDao()?.getCurrentOrder() == null && value != null) {
RoomHelper.db?.orderDao()?.insertOrder(value)
} else if (value != null) {
RoomHelper.db?.orderDao()?.update(value)
}
localCurrentOrder = value
field = value
}
@ -133,5 +127,4 @@ object GlobalData {
fun clearOrderCache(taskId : Int) {
RoomHelper.clearOrderFromTaskCode(taskId = taskId)
}
}