[charter]

[debug]
[页面被回收mView没有被回收]
This commit is contained in:
yangyakun
2023-05-30 18:29:38 +08:00
parent 31e5b8776a
commit 5191cd4bf2

View File

@@ -373,58 +373,60 @@ class M1SoftFragment :
pattern: Int,
windSpeed: Int
) {
if (!airIsOpen && !heaterIsOpen) {
tv_aircondition_switch.text = "打开空调"
tv_aircondition_switch.isChecked = false
dbv_wind.visibility = View.GONE
} else {
tv_aircondition_switch.text = "关闭空调"
tv_aircondition_switch.isChecked = true
dbv_wind.visibility = View.VISIBLE
}
if (airIsOpen) {
val adapter = rv_aircondition_temperature.adapter
if (adapter is TemperatureAdapter) {
adapter.data.forEach {
if (it.value == temperatureCmd) {
rv_aircondition_temperature.tag = touchTag
UiThreadHandler.postDelayed({
rv_aircondition_temperature?.smoothScrollToPosition(it.index)
},500)
tv_aircondition_switch?.let {
if (!airIsOpen && !heaterIsOpen) {
tv_aircondition_switch.text = "打开空调"
tv_aircondition_switch.isChecked = false
dbv_wind.visibility = View.GONE
} else {
tv_aircondition_switch.text = "关闭空调"
tv_aircondition_switch.isChecked = true
dbv_wind.visibility = View.VISIBLE
}
if (airIsOpen) {
val adapter = rv_aircondition_temperature.adapter
if (adapter is TemperatureAdapter) {
adapter.data.forEach {
if (it.value == temperatureCmd) {
rv_aircondition_temperature.tag = touchTag
UiThreadHandler.postDelayed({
rv_aircondition_temperature?.smoothScrollToPosition(it.index)
},500)
}
}
}
when (pattern) {//1: 自动模式, 2: 制冷模式, 3: 通风模式(仅送风,无温度)
1 -> {rb_pattern_automatic.isChecked = true}
2 -> {rb_pattern_refrigeration.isChecked = true}
3 -> {rb_pattern_ventilate.isChecked = true}
else -> {}
}
heaterAirEnable(true)
when (windSpeed) {//1: 1档2: 2档3:3档
1 -> {
setWind(rb_wind_speed_low,R.drawable.bus_pm1_aircondition_wind_low)
}
2 -> {
setWind(rb_wind_speed_middle,R.drawable.bus_pm1_aircondition_wind_middle)
}
3 -> {
setWind(rb_wind_speed_high,R.drawable.bus_pm1_aircondition_wind_high)
}
else -> {}
}
}
when (pattern) {//1: 自动模式, 2: 制冷模式, 3: 通风模式(仅送风,无温度)
1 -> {rb_pattern_automatic.isChecked = true}
2 -> {rb_pattern_refrigeration.isChecked = true}
3 -> {rb_pattern_ventilate.isChecked = true}
else -> {}
}
heaterAirEnable(true)
when (windSpeed) {//1: 1档2: 2档3:3档
1 -> {
setWind(rb_wind_speed_low,R.drawable.bus_pm1_aircondition_wind_low)
if (heaterIsOpen) {
rb_pattern_heating.isChecked = true
heaterAirEnable(false)
when (windSpeed) {//1: 1档2: 2档
1 -> {
setWind(rb_wind_speed_middle,R.drawable.bus_pm1_warm_wind_middle)
}
2 -> {
setWind(rb_wind_speed_high,R.drawable.bus_pm1_warm_wind_high)
}
else -> {}
}
2 -> {
setWind(rb_wind_speed_middle,R.drawable.bus_pm1_aircondition_wind_middle)
}
3 -> {
setWind(rb_wind_speed_high,R.drawable.bus_pm1_aircondition_wind_high)
}
else -> {}
}
}
if (heaterIsOpen) {
rb_pattern_heating.isChecked = true
heaterAirEnable(false)
when (windSpeed) {//1: 1档2: 2档
1 -> {
setWind(rb_wind_speed_middle,R.drawable.bus_pm1_warm_wind_middle)
}
2 -> {
setWind(rb_wind_speed_high,R.drawable.bus_pm1_warm_wind_high)
}
else -> {}
}
}
}
@@ -547,38 +549,44 @@ class M1SoftFragment :
}
fun setLightTop1View(leftLight: Boolean, isFirst: Boolean){
if (leftLight) {
tv_light_top_01.text = requireContext().getString(R.string.bus_p_m1_close_light1)
tv_light_top_01.isChecked = true
if(!isFirst) ToastCharterUtils.showShort("打开顶灯1")
} else {
tv_light_top_01.text = requireContext().getString(R.string.bus_p_m1_open_light1)
tv_light_top_01.isChecked = false
if(!isFirst) ToastCharterUtils.showShort("关闭顶灯1")
tv_light_top_01?.let {
if (leftLight) {
tv_light_top_01.text = requireContext().getString(R.string.bus_p_m1_close_light1)
tv_light_top_01.isChecked = true
if(!isFirst) ToastCharterUtils.showShort("打开顶灯1")
} else {
tv_light_top_01.text = requireContext().getString(R.string.bus_p_m1_open_light1)
tv_light_top_01.isChecked = false
if(!isFirst) ToastCharterUtils.showShort("关闭顶灯1")
}
}
}
fun setLightTop2View(rightLight: Boolean, isFirst: Boolean){
if (rightLight) {
tv_light_top_02.text = requireContext().getString(R.string.bus_p_m1_close_light2)
tv_light_top_02.isChecked = true
if(!isFirst) ToastCharterUtils.showShort("打开顶灯2")
} else {
tv_light_top_02.text = requireContext().getString(R.string.bus_p_m1_open_light2)
tv_light_top_02.isChecked = false
if(!isFirst) ToastCharterUtils.showShort("关闭顶灯2")
tv_light_top_02?.let {
if (rightLight) {
tv_light_top_02.text = requireContext().getString(R.string.bus_p_m1_close_light2)
tv_light_top_02.isChecked = true
if(!isFirst) ToastCharterUtils.showShort("打开顶灯2")
} else {
tv_light_top_02.text = requireContext().getString(R.string.bus_p_m1_open_light2)
tv_light_top_02.isChecked = false
if(!isFirst) ToastCharterUtils.showShort("关闭顶灯2")
}
}
}
fun setLightAtmosphereView(atmosphereLight: Boolean, isFirst: Boolean){
if (atmosphereLight) {
tv_light_atmosphere.text = requireContext().getString(R.string.bus_p_m1_close_atmosphere)
tv_light_atmosphere.isChecked = true
iv_bottom_light_setting.setImageResource(R.drawable.bus_p_function_atmosphere_select)
if(!isFirst) ToastCharterUtils.showShort("打开氛围灯")
} else {
tv_light_atmosphere.text = requireContext().getString(R.string.bus_p_m1_open_atmosphere)
tv_light_atmosphere.isChecked = false
iv_bottom_light_setting.setImageResource(R.drawable.bus_p_function_atmosphere_nor)
if(!isFirst) ToastCharterUtils.showShort("关闭氛围灯")
tv_light_atmosphere?.let {
if (atmosphereLight) {
tv_light_atmosphere.text = requireContext().getString(R.string.bus_p_m1_close_atmosphere)
tv_light_atmosphere.isChecked = true
iv_bottom_light_setting.setImageResource(R.drawable.bus_p_function_atmosphere_select)
if(!isFirst) ToastCharterUtils.showShort("打开氛围灯")
} else {
tv_light_atmosphere.text = requireContext().getString(R.string.bus_p_m1_open_atmosphere)
tv_light_atmosphere.isChecked = false
iv_bottom_light_setting.setImageResource(R.drawable.bus_p_function_atmosphere_nor)
if(!isFirst) ToastCharterUtils.showShort("关闭氛围灯")
}
}
}
@@ -586,16 +594,18 @@ class M1SoftFragment :
* 灯的UI发生变化
*/
fun setLightView(leftLight: Boolean, rightLight: Boolean) {
if (leftLight && rightLight) {
iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_middle_selected)// 都打开
} else if (!leftLight && !rightLight) {
iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_nor)// 都关闭
} else {
if (leftLight) {
iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_select_left)// 左面开
}
if (rightLight) {
iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_select_right)// 左面开
iv_top_light_setting?.let {
if (leftLight && rightLight) {
iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_middle_selected)// 都打开
} else if (!leftLight && !rightLight) {
iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_nor)// 都关闭
} else {
if (leftLight) {
iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_select_left)// 左面开
}
if (rightLight) {
iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_select_right)// 左面开
}
}
}
}