[M2]回调后更新UI在主线程

This commit is contained in:
wangmingjun
2023-03-14 17:09:08 +08:00
parent 35c54d121b
commit 0bafee757a
2 changed files with 18 additions and 12 deletions

View File

@@ -5,6 +5,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater import android.view.LayoutInflater
import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsListener import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsListener
import com.mogo.eagle.core.function.hmi.ui.widget.BlueToothView import com.mogo.eagle.core.function.hmi.ui.widget.BlueToothView
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.och.bus.passenger.R import com.mogo.och.bus.passenger.R
import kotlinx.android.synthetic.m2.p_m2_view_blue_tooth.view.* import kotlinx.android.synthetic.m2.p_m2_view_blue_tooth.view.*
@@ -24,10 +25,12 @@ class M2BlueToothView @JvmOverloads constructor(
} }
override fun mofangStatus(status: Boolean) { override fun mofangStatus(status: Boolean) {
if (status) { ThreadUtils.runOnUiThread {
blueView.setImageResource(R.drawable.m2_blue_tooth_close) if (status) {
} else { blueView.setImageResource(R.drawable.m2_blue_tooth_close)
blueView.setImageResource(R.drawable.m2_blue_tooth_open) } else {
blueView.setImageResource(R.drawable.m2_blue_tooth_open)
}
} }
} }

View File

@@ -14,6 +14,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerBatteryManagementSystem
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiViewControlListenerManager import com.mogo.eagle.core.function.call.hmi.CallerHmiViewControlListenerManager
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.och.bus.passenger.R import com.mogo.och.bus.passenger.R
import kotlinx.android.synthetic.m2.p_m2_view_status_bar.view.* import kotlinx.android.synthetic.m2.p_m2_view_status_bar.view.*
import me.jessyan.autosize.utils.AutoSizeUtils import me.jessyan.autosize.utils.AutoSizeUtils
@@ -69,14 +70,16 @@ class M2StatusBarView @JvmOverloads constructor(
} }
override fun onBatteryManagementSystemStates(states: ChassisStatesOuterClass.BMSSystemStates) { override fun onBatteryManagementSystemStates(states: ChassisStatesOuterClass.BMSSystemStates) {
val bmsSoc = states.bmsSoc ThreadUtils.runOnUiThread {
if(bmsSoc >1){ val bmsSoc = states.bmsSoc
progress.progress = bmsSoc.toInt() if(bmsSoc >1){
tv_power_cos.text = "${bmsSoc.toInt()}%" progress.progress = bmsSoc.toInt()
}else{ tv_power_cos.text = "${bmsSoc.toInt()}%"
val currenPower = (bmsSoc * 100).toInt() }else{
progress.progress = currenPower val currenPower = (bmsSoc * 100).toInt()
tv_power_cos.text = "$currenPower%" progress.progress = currenPower
tv_power_cos.text = "$currenPower%"
}
} }
} }