[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 com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsListener
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 kotlinx.android.synthetic.m2.p_m2_view_blue_tooth.view.*
@@ -24,10 +25,12 @@ class M2BlueToothView @JvmOverloads constructor(
}
override fun mofangStatus(status: Boolean) {
if (status) {
blueView.setImageResource(R.drawable.m2_blue_tooth_close)
} else {
blueView.setImageResource(R.drawable.m2_blue_tooth_open)
ThreadUtils.runOnUiThread {
if (status) {
blueView.setImageResource(R.drawable.m2_blue_tooth_close)
} 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.hmi.CallerHmiViewControlListenerManager
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 kotlinx.android.synthetic.m2.p_m2_view_status_bar.view.*
import me.jessyan.autosize.utils.AutoSizeUtils
@@ -69,14 +70,16 @@ class M2StatusBarView @JvmOverloads constructor(
}
override fun onBatteryManagementSystemStates(states: ChassisStatesOuterClass.BMSSystemStates) {
val bmsSoc = states.bmsSoc
if(bmsSoc >1){
progress.progress = bmsSoc.toInt()
tv_power_cos.text = "${bmsSoc.toInt()}%"
}else{
val currenPower = (bmsSoc * 100).toInt()
progress.progress = currenPower
tv_power_cos.text = "$currenPower%"
ThreadUtils.runOnUiThread {
val bmsSoc = states.bmsSoc
if(bmsSoc >1){
progress.progress = bmsSoc.toInt()
tv_power_cos.text = "${bmsSoc.toInt()}%"
}else{
val currenPower = (bmsSoc * 100).toInt()
progress.progress = currenPower
tv_power_cos.text = "$currenPower%"
}
}
}