diff --git a/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/presenter/BusPassengerFunctionDevicePresenter.kt b/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/presenter/BusPassengerFunctionDevicePresenter.kt index b47050a2a1..737338b83d 100644 --- a/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/presenter/BusPassengerFunctionDevicePresenter.kt +++ b/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/presenter/BusPassengerFunctionDevicePresenter.kt @@ -51,7 +51,7 @@ class BusPassengerFunctionDevicePresenter(view: BusPassengerFunctionDeviceFragme } override fun onDoorStatusCallback(isOpen: Boolean,isFirst: Boolean) { - if(isFirst) { + if(!isFirst) { if (isOpen) { ToastUtils.showShort("已开启车门") } else { diff --git a/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/presenter/BusPassengerFunctionSoftPresenter.kt b/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/presenter/BusPassengerFunctionSoftPresenter.kt index 400443c6e9..fcec461be1 100644 --- a/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/presenter/BusPassengerFunctionSoftPresenter.kt +++ b/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/presenter/BusPassengerFunctionSoftPresenter.kt @@ -5,6 +5,7 @@ import com.mogo.commons.mvp.Presenter import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler import com.mogo.och.bus.passenger.ui.BusPassengerFunctionSoftFragment import com.mogo.och.common.module.manager.OCHM1LightAirconditionDoorStatusManager import com.zhidao.support.adas.high.AdasManager @@ -43,13 +44,25 @@ class BusPassengerFunctionSoftPresenter(view: BusPassengerFunctionSoftFragment?) "空调温度:${OCHM1LightAirconditionDoorStatusManager.airconditionStatus.temperature}" + "空调模式:${OCHM1LightAirconditionDoorStatusManager.airconditionStatus.pattert}" + "空调风速:${OCHM1LightAirconditionDoorStatusManager.airconditionStatus.windSpeed}") - mView?.setAirconditionHeaterView( - airconditionStatus.isOpen, - heaterIsOpen, - airconditionStatus.temperature, - airconditionStatus.pattert, - airconditionStatus.windSpeed - ) + UiThreadHandler.post { + if(airconditionStatus.isOpen){ + mView?.setAirconditionHeaterView( + airconditionStatus.isOpen, + heaterIsOpen, + airconditionStatus.temperature, + airconditionStatus.pattert, + airconditionStatus.windSpeed + ) + }else{ + mView?.setAirconditionHeaterView( + airconditionStatus.isOpen, + heaterIsOpen, + airconditionStatus.temperature, + 0, + 0 + ) + } + } } /** * 暖风机状态变化 @@ -58,23 +71,62 @@ class BusPassengerFunctionSoftPresenter(view: BusPassengerFunctionSoftFragment?) CallerLogger.d(SceneConstant.M_BUS_P + TAG, "回写--暖风机开关:${heaterStatue.isOpen}、" + "风速:${heaterStatue.windSpeed}") - mView?.setAirconditionHeaterView( - airconditionIsOpen, - heaterStatue.isOpen, - 0, - 0, - heaterStatue.windSpeed - ) + UiThreadHandler.post { + if(heaterStatue.isOpen) { + mView?.setAirconditionHeaterView( + airconditionIsOpen, + heaterStatue.isOpen, + 0, + 0, + heaterStatue.windSpeed + ) + }else{ + mView?.setAirconditionHeaterView( + airconditionIsOpen, + heaterStatue.isOpen, + 0, + 0, + 0 + ) + } + } } /** * 灯状态变化 */ - override fun onLightCallback(lightStatus: OCHM1LightAirconditionDoorStatusManager.LightStatus,isFirst: Boolean) { + override fun onLightTop1Callback(lightStatus: OCHM1LightAirconditionDoorStatusManager.LightStatus,isFirst: Boolean) { CallerLogger.d(SceneConstant.M_BUS_P + TAG, "回写--顶灯1开关:${lightStatus.isOpenLight1}、" + "顶灯2开关:${lightStatus.isOpenLight2}、" + "氛围灯开关:${lightStatus.isOpenatmosphere}、") - mView?.setLightView(lightStatus.isOpenLight1,lightStatus.isOpenLight2,lightStatus.isOpenatmosphere,isFirst) + UiThreadHandler.post { + mView?.setLightTop1View(lightStatus.isOpenLight1,isFirst) + } + } + /** + * 灯状态变化 + */ + override fun onLightTop2Callback(lightStatus: OCHM1LightAirconditionDoorStatusManager.LightStatus,isFirst: Boolean) { + CallerLogger.d(SceneConstant.M_BUS_P + TAG, + "回写--顶灯1开关:${lightStatus.isOpenLight1}、" + + "顶灯2开关:${lightStatus.isOpenLight2}、" + + "氛围灯开关:${lightStatus.isOpenatmosphere}、") + UiThreadHandler.post { + mView?.setLightTop2View(lightStatus.isOpenLight2,isFirst) + mView?.setLightView(lightStatus.isOpenLight1,lightStatus.isOpenLight2) + } + } + /** + * 灯状态变化 + */ + override fun onLightAtmosphereCallback(lightStatus: OCHM1LightAirconditionDoorStatusManager.LightStatus,isFirst: Boolean) { + CallerLogger.d(SceneConstant.M_BUS_P + TAG, + "回写--顶灯1开关:${lightStatus.isOpenLight1}、" + + "顶灯2开关:${lightStatus.isOpenLight2}、" + + "氛围灯开关:${lightStatus.isOpenatmosphere}、") + UiThreadHandler.post { + mView?.setLightAtmosphereView(lightStatus.isOpenatmosphere,isFirst) + } } /** @@ -85,12 +137,12 @@ class BusPassengerFunctionSoftPresenter(view: BusPassengerFunctionSoftFragment?) "打开空调,模式$modeCmd--档位${windSpeedCmd}--温度:$temperatureCmd") AdasManager.getInstance().sendRoboBusJinlvM1AirConditionerCmd(1,modeCmd,windSpeedCmd,temperatureCmd) disposeSubscribe(airconditionDisposable) - airconditionDisposable = createSubscribe(2000){ + airconditionDisposable = createSubscribe(5000){ if (!OCHM1LightAirconditionDoorStatusManager.airconditionStatus.isOpen&& OCHM1LightAirconditionDoorStatusManager.airconditionStatus.windSpeed!=windSpeedCmd&& OCHM1LightAirconditionDoorStatusManager.airconditionStatus.temperature!=temperatureCmd&& OCHM1LightAirconditionDoorStatusManager.airconditionStatus.pattert!=modeCmd) { - ToastUtils.showShort("操作未生效,请稍后重试吧~") + ToastUtils.showShort("空调操作未生效,请稍后重试吧~") } } } @@ -100,7 +152,7 @@ class BusPassengerFunctionSoftPresenter(view: BusPassengerFunctionSoftFragment?) disposeSubscribe(airconditionDisposable) airconditionDisposable = createSubscribe(2000){ if (OCHM1LightAirconditionDoorStatusManager.airconditionStatus.isOpen) { - ToastUtils.showShort("操作未生效,请稍后重试吧~") + ToastUtils.showShort("空调操作未生效,请稍后重试吧~") } } } diff --git a/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/ui/BusPassengerFunctionSoftFragment.kt b/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/ui/BusPassengerFunctionSoftFragment.kt index 155b600e9d..081bf8dcfd 100644 --- a/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/ui/BusPassengerFunctionSoftFragment.kt +++ b/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/ui/BusPassengerFunctionSoftFragment.kt @@ -1,12 +1,16 @@ package com.mogo.och.bus.passenger.ui +import android.animation.ObjectAnimator +import android.animation.ValueAnimator import android.content.Context +import android.graphics.BitmapFactory import android.graphics.drawable.ClipDrawable import android.graphics.drawable.LayerDrawable import android.media.AudioManager import android.os.Bundle import android.view.Gravity import android.view.View +import android.widget.RadioButton import android.widget.SeekBar import android.widget.SeekBar.OnSeekBarChangeListener import android.widget.TextView @@ -52,6 +56,8 @@ class BusPassengerFunctionSoftFragment : private var subscribeLightTop2: Disposable? = null private var subscribeAtmosphere: Disposable? = null + private var animator1: ObjectAnimator? = null + override fun initViews() { rg_select_function.setOnCheckedChangeListener { group, checkedId -> @@ -76,10 +82,24 @@ class BusPassengerFunctionSoftFragment : } rg_select_function.check(R.id.tv_setting_aircondition) setAirconditionListener() + setAirConditionAni() setLightListener() setVoiceInfo() } + private fun setAirConditionAni() { + dbv_wind.post { + val measuredHeight = dbv_wind.measuredHeight + animator1 = ObjectAnimator.ofInt(dbv_wind, "showHeight", 0, measuredHeight).apply { + duration = 1000 + repeatCount = ValueAnimator.INFINITE + if(rg_setting_windspeed.checkedRadioButtonId!=0&&tv_aircondition_switch.isChecked){ + start() + } + } + } + } + private fun setAirconditionListener() { // 开关空调或暖风机 tv_aircondition_switch.setOnCheckedChangeListener { buttonView, isChecked -> @@ -111,10 +131,16 @@ class BusPassengerFunctionSoftFragment : CallerLogger.d(SceneConstant.M_BUS_P + TAG, "调节模式") when (checkedId) { R.id.rb_pattern_heating -> { + if(!rb_pattern_heating.isPressed){ + return@setOnCheckedChangeListener + } SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di) openHeater() } R.id.rb_pattern_automatic->{ + if(!rb_pattern_automatic.isPressed){ + return@setOnCheckedChangeListener + } SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di) openAircondition() } @@ -270,9 +296,13 @@ class BusPassengerFunctionSoftFragment : 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 @@ -294,9 +324,15 @@ class BusPassengerFunctionSoftFragment : } heaterAirEnable(true) when (windSpeed) {//1: 1档,2: 2档,3:3档 - 1 -> {rb_wind_speed_low.isChecked = true} - 2 -> {rb_wind_speed_middle.isChecked = true} - 3 -> {rb_wind_speed_high.isChecked = true} + 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 -> {} } } @@ -304,12 +340,20 @@ class BusPassengerFunctionSoftFragment : rb_pattern_heating.isChecked = true heaterAirEnable(false) when (windSpeed) {//1: 1档,2: 2档 - 1 -> {rb_wind_speed_middle.isChecked = true} - 2 -> {rb_wind_speed_high.isChecked = true} + 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 -> {} } } } + fun setWind(check: RadioButton,resource:Int){ + check.isChecked = true + dbv_wind.setDrawableImage(BitmapFactory.decodeResource(resources,resource)) + } /** * 关闭暖风机 @@ -333,7 +377,7 @@ class BusPassengerFunctionSoftFragment : val adapter = rv_aircondition_temperature.adapter as TemperatureAdapter if(enable){ adapter.setEnable(true) - if(rg_select_function.checkedRadioButtonId==R.id.tv_setting_aircondition) { + if(tv_setting_aircondition.isChecked) { iv_temperature_select.visibility = View.VISIBLE } rb_wind_speed_low.setTextColor(ContextCompat.getColorStateList(requireContext(),R.color.bus_p_function_airconditon_pattern_text_color_selector)) @@ -391,7 +435,8 @@ class BusPassengerFunctionSoftFragment : } SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di) mPresenter?.setLightData1(isChecked) - setLightView(isChecked, tv_light_top_02.isChecked, tv_light_atmosphere.isChecked,true) + setLightTop1View(isChecked,true) + setLightView(isChecked,tv_light_top_02.isChecked) } tv_light_top_02.setOnCheckedChangeListener { buttonView, isChecked -> if(!buttonView.isPressed){ @@ -405,7 +450,8 @@ class BusPassengerFunctionSoftFragment : } SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di) mPresenter?.setLightData2(isChecked) - setLightView(tv_light_top_01.isChecked, isChecked, tv_light_atmosphere.isChecked,true) + setLightTop2View(isChecked,true) + setLightView(tv_light_top_01.isChecked,isChecked) } tv_light_atmosphere.setOnCheckedChangeListener { buttonView, isChecked -> if(!buttonView.isPressed){ @@ -419,27 +465,11 @@ class BusPassengerFunctionSoftFragment : } SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di) mPresenter?.setAtmosphereLightData2(isChecked) - setLightView(tv_light_top_01.isChecked, tv_light_top_02.isChecked, isChecked,true) + setLightAtmosphereView(isChecked,true) } } - private fun voiceBi(target: View): Boolean { - if (target.tag == touchTag) { - target.tag = null - return false - } else { - SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di) - return true - } - } - - /** - * 灯的UI发生变化 - */ - fun setLightView(leftLight: Boolean, rightLight: Boolean, atmosphereLight: Boolean,isFirst: Boolean) { - tv_light_top_01.tag = touchTag - tv_light_top_02.tag = touchTag - tv_light_atmosphere.tag = touchTag + 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 @@ -449,6 +479,8 @@ class BusPassengerFunctionSoftFragment : tv_light_top_01.isChecked = false if(!isFirst) ToastUtils.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 @@ -458,6 +490,25 @@ class BusPassengerFunctionSoftFragment : tv_light_top_02.isChecked = false if(!isFirst) ToastUtils.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) ToastUtils.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) ToastUtils.showShort("关闭氛围灯") + } + } + + /** + * 灯的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) { @@ -470,17 +521,6 @@ class BusPassengerFunctionSoftFragment : iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_select_right)// 左面开 } } - 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) ToastUtils.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) ToastUtils.showShort("关闭氛围灯") - } } // endregion @@ -566,6 +606,31 @@ class BusPassengerFunctionSoftFragment : super.onDestroy() } + override fun onResume() { + super.onResume() + if(rg_setting_windspeed.checkedRadioButtonId!=0&&tv_aircondition_switch.isChecked){ + animator1?.start() + } + } + + override fun onPause() { + super.onPause() + animator1?.let { + if(it.isRunning){ + it.pause() + } + } + } + + override fun onDetach() { + super.onDetach() + animator1?.let { + if(it.isRunning){ + it.end() + } + } + } + companion object { const val TAG = "BusPassengerFunctionSoftFragment" const val touchTagKey = 2 diff --git a/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/ui/adapter/TemperatureAdapter.java b/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/ui/adapter/TemperatureAdapter.java index f7f39e1bdb..bc488f8395 100644 --- a/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/ui/adapter/TemperatureAdapter.java +++ b/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/ui/adapter/TemperatureAdapter.java @@ -84,7 +84,7 @@ public class TemperatureAdapter extends RecyclerView.Adapter + + + app:constraint_referenced_ids="iv_temperature_select,v_temperature_bg,tv_aircondition_switch,tv_temperature_title,rv_aircondition_temperature,tv_aircondition_pattern_title,rg_setting_pattern,tv_aircondition_wind_speed_title,rg_setting_windspeed,dbv_wind" /> diff --git a/OCH/mogo-och-bus-passenger/src/m1/res/values/attrs.xml b/OCH/mogo-och-bus-passenger/src/m1/res/values/attrs.xml new file mode 100644 index 0000000000..321bbf2246 --- /dev/null +++ b/OCH/mogo-och-bus-passenger/src/m1/res/values/attrs.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/manager/OCHM1LightAirconditionDoorStatusManager.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/manager/OCHM1LightAirconditionDoorStatusManager.kt index b31b90ad2a..a6057afea8 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/manager/OCHM1LightAirconditionDoorStatusManager.kt +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/manager/OCHM1LightAirconditionDoorStatusManager.kt @@ -29,7 +29,9 @@ object OCHM1LightAirconditionDoorStatusManager : IMoGoRoboBusJinlvM1StatesListen return } M_LISTENERS[tag] = listener - listener.onLightCallback(lightStatus,true) + listener.onLightTop1Callback(lightStatus,true) + listener.onLightTop2Callback(lightStatus,true) + listener.onLightAtmosphereCallback(lightStatus,true) listener.onAirconditionStatusCallback(heaterStatue.isOpen,airconditionStatus,true) listener.onHeaterStatusCallback(airconditionStatus.isOpen,heaterStatue,true) } @@ -65,7 +67,9 @@ object OCHM1LightAirconditionDoorStatusManager : IMoGoRoboBusJinlvM1StatesListen fun onDoorStatusCallback(isOpen: Boolean,isFirst: Boolean){} - fun onLightCallback(lightStatus: LightStatus,isFirst: Boolean){} + fun onLightTop1Callback(lightStatus: LightStatus,isFirst: Boolean){} + fun onLightTop2Callback(lightStatus: LightStatus,isFirst: Boolean){} + fun onLightAtmosphereCallback(lightStatus: LightStatus,isFirst: Boolean){} } @@ -121,16 +125,28 @@ object OCHM1LightAirconditionDoorStatusManager : IMoGoRoboBusJinlvM1StatesListen listener.onDoorStatusCallback(doorStatus.isOpen,false) } } - if (states.mainLamp1State.isOn != lightStatus.isOpenLight1|| - states.mainLamp2State.isOn != lightStatus.isOpenLight2|| - states.smallLampState.isOn != lightStatus.isOpenatmosphere) { + if(states.mainLamp1State.isOn != lightStatus.isOpenLight1){ lightStatus.isOpenLight1 = states.mainLamp1State.isOn + M_LISTENERS.forEach { + val tag = it.key + val listener = it.value + listener.onLightTop1Callback(lightStatus,false) + } + } + if(states.mainLamp2State.isOn != lightStatus.isOpenLight2){ lightStatus.isOpenLight2 = states.mainLamp2State.isOn + M_LISTENERS.forEach { + val tag = it.key + val listener = it.value + listener.onLightTop2Callback(lightStatus,false) + } + } + if(states.smallLampState.isOn != lightStatus.isOpenatmosphere){ lightStatus.isOpenatmosphere = states.smallLampState.isOn M_LISTENERS.forEach { val tag = it.key val listener = it.value - listener.onLightCallback(lightStatus,false) + listener.onLightAtmosphereCallback(lightStatus,false) } } }