desc:调整协程Dispatchers

main
xiaowusky 2 years ago
parent 51627e8cd4
commit f04cc53a59

@ -109,8 +109,10 @@ object ParseHelper {
// val rangHexLong: Long = HexUtils.hexToLong(rangHex) // val rangHexLong: Long = HexUtils.hexToLong(rangHex)
// 是否超量程 // 是否超量程
val overRange = value > type.rangMax || status == 8 val overRange = value > type.rangMax || status == 8
LogUtils.w("receive msg 单位转换前 $type, 浓度 = $value $unit, 最大量程 = ${type.rangMax}") LogUtils.w("receive msg 单位转换前 $type, 浓度 = $value $unit, 最大量程 = ${type.rangMax}")
if (overRange) {
value = type.rangMax.toFloat()
}
//根据单位进行数值转换 //根据单位进行数值转换
val localGasUnit = getLocalGasUnit(type.desc) val localGasUnit = getLocalGasUnit(type.desc)
@ -151,7 +153,7 @@ object ParseHelper {
unit: String, unit: String,
overRange: Boolean overRange: Boolean
) { ) {
GlobalScope.launch(Dispatchers.IO) { GlobalScope.launch(Dispatchers.Unconfined) {
// 阈值范围 // 阈值范围
val min = getGasLowThreshold(typeEnum.desc, unit) val min = getGasLowThreshold(typeEnum.desc, unit)
val max = getGasHighThreshold(typeEnum.desc, unit) val max = getGasHighThreshold(typeEnum.desc, unit)

@ -165,8 +165,8 @@ class HomeActivity : NoOptionsActivity() {
} }
private fun showTipView() { private fun showTipView() {
lifecycleScope.launch(Dispatchers.Main) {
TxtOverlay.getOverlayBitmap()?.let { TxtOverlay.getOverlayBitmap()?.let {
lifecycleScope.launch(Dispatchers.Main) {
mBinding.tipView.setImageBitmap(it) mBinding.tipView.setImageBitmap(it)
} }
} }
@ -198,13 +198,13 @@ class HomeActivity : NoOptionsActivity() {
// 设置传感器 // 设置传感器
private fun setForSensor() { private fun setForSensor() {
TxtOverlay.setTipChangeListener { TxtOverlay.setTipChangeListener {
showTipView()
if (!AppData.hasSensorData()) { if (!AppData.hasSensorData()) {
// 有传感器数据回调 // 有传感器数据回调
AppData.setSensorData(true) AppData.setSensorData(true)
closeLoadingDialog() closeLoadingDialog()
changeViewStatus() changeViewStatus()
} }
showTipView()
setWarnView() setWarnView()
watchSensor(DELAY_TIME_CHECK_SENSOR) watchSensor(DELAY_TIME_CHECK_SENSOR)
} }

Loading…
Cancel
Save