|
|
|
@ -21,6 +21,7 @@ import com.yinuo.safetywatcher.watcher.port.saveGasUnit
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.hideIme
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.showIme
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.showToast
|
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
|
|
|
|
@ -69,9 +70,10 @@ class SensorSettingActivity : NoOptionsActivity() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 昵称和量程
|
|
|
|
|
lifecycleScope.launch {
|
|
|
|
|
lifecycleScope.launch(Dispatchers.IO) {
|
|
|
|
|
val typeDao = DBUtils.gasTypeDao()
|
|
|
|
|
val gasType = typeDao.getByName(gasName)
|
|
|
|
|
launch(Dispatchers.Main) {
|
|
|
|
|
if (gasType != null && !gasType.nickName.isNullOrEmpty()) {
|
|
|
|
|
mBinding.etName.setText(gasType.nickName)
|
|
|
|
|
} else {
|
|
|
|
@ -80,6 +82,7 @@ class SensorSettingActivity : NoOptionsActivity() {
|
|
|
|
|
val gasRange = getGasRange(gasName)
|
|
|
|
|
mBinding.etStep.text = getString(R.string.sensor_step_txt).plus(": $gasRange")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置各种监听
|
|
|
|
|
setListener()
|
|
|
|
@ -151,7 +154,7 @@ class SensorSettingActivity : NoOptionsActivity() {
|
|
|
|
|
|
|
|
|
|
private fun saveSetting() {
|
|
|
|
|
val nickName = mBinding.etName.text.toString()
|
|
|
|
|
GlobalScope.launch {
|
|
|
|
|
GlobalScope.launch(Dispatchers.IO) {
|
|
|
|
|
val typeDao = DBUtils.gasTypeDao()
|
|
|
|
|
val gasType = typeDao.getByName(gasName)
|
|
|
|
|
val ifEmpty = nickName.ifEmpty { "${gasName}传感器" }
|
|
|
|
|