desc:传感器列表重复显示问题

main
xiaowusky 1 year ago
parent 4a840f7339
commit 259b55344e

@ -44,7 +44,7 @@ object ParseHelper {
LogUtils.v("receive msg, unknown gas")
return
}
LogUtils.v("receive msg, status is $status")
LogUtils.v("receive msg ${gasType.desc}, status is $status")
when (status) {
// 预热
0 -> {
@ -266,9 +266,14 @@ object ParseHelper {
val typeDao = DBUtils.gasTypeDao()
val gasType = typeDao.getByName(type.desc)
GasCache.setStatus(type.desc, getShowStatus(CommonApplication.getContext(), status))
gasType?.type = type.desc
gasType?.status = status
gasType?.sensorIndex = sensorIndex
typeDao.insert(gasType ?: GasType(type.desc, status, sensorIndex))
if (gasType == null) {
typeDao.insert(GasType(type.desc, status, sensorIndex))
} else {
typeDao.update(gasType)
}
}
}
}

@ -5,6 +5,7 @@ import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.common.commonlib.db.entity.GasType
@Dao
@ -18,6 +19,9 @@ interface GasTypeDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(gas: GasType)
@Update
suspend fun update(gas: GasType)
@Insert
suspend fun insertAll(types: List<GasType>)

Loading…
Cancel
Save