|
|
|
@ -10,7 +10,7 @@ import kotlinx.coroutines.launch
|
|
|
|
|
@OptIn(DelicateCoroutinesApi::class)
|
|
|
|
|
object GasCache {
|
|
|
|
|
private val statusCache = HashMap<String, String>()
|
|
|
|
|
private val nicknameCache = HashMap<String, String>()
|
|
|
|
|
private val nicknameCache = HashMap<String, String?>()
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
|
GlobalScope.launch(Dispatchers.IO) {
|
|
|
|
@ -18,21 +18,21 @@ object GasCache {
|
|
|
|
|
val all = typeDao.getAll()
|
|
|
|
|
val context = CommonApplication.getContext()
|
|
|
|
|
all.forEach {
|
|
|
|
|
setNickname(it.type, it.nickName ?: "")
|
|
|
|
|
setNickname(it.type, it.nickName ?: "${it.type}传感器")
|
|
|
|
|
setStatus(it.type, getShowStatus(context, it.status))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun getNickname(gas: String): String {
|
|
|
|
|
return nicknameCache[gas] ?: ""
|
|
|
|
|
return nicknameCache[gas] ?: "${gas}传感器"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun getStatus(gas: String): String {
|
|
|
|
|
return statusCache[gas] ?: ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun setNickname(gas: String, nickname: String) {
|
|
|
|
|
fun setNickname(gas: String, nickname: String?) {
|
|
|
|
|
nicknameCache[gas] = nickname
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|