Merge remote-tracking branch 'origin/dev_robobus-m1-p-app-module_1.0.0_230112_1.0.0' into dev_robobus-m1-p-app-module_1.0.0_230112_1.0.0

This commit is contained in:
wangmingjun
2023-02-10 19:37:43 +08:00
9 changed files with 409 additions and 134 deletions

View File

@@ -8,11 +8,16 @@ import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.och.bus.passenger.ui.BusPassengerFunctionDeviceFragment
import com.mogo.och.common.module.manager.OCHM1LightAirconditionDoorStatusManager
import com.zhidao.support.adas.high.AdasManager
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import java.util.concurrent.TimeUnit
class BusPassengerFunctionDevicePresenter(view: BusPassengerFunctionDeviceFragment?) :
BusBasePassengerFunctionDevicePresenter<BusPassengerFunctionDeviceFragment?>(view),
OCHM1LightAirconditionDoorStatusManager.OCHM1LightAirconditionDoorCallback {
private var subscribe: Disposable?=null
companion object{
private const val TAG = "BusPassengerFunctionDevicePresenter"
}
@@ -34,23 +39,52 @@ class BusPassengerFunctionDevicePresenter(view: BusPassengerFunctionDeviceFragme
}
}
fun startStopSide() {
when (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state) {
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {// 不可自动驾驶
ToastUtils.showShort("设备未就绪请稍等")
fun openDoor(){
subscribe?.let {
if (!it.isDisposed) {
it.dispose()
}
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE -> {//
ToastUtils.showShort("启动自动驾驶中")
// TODO: 查找线路和订单来确定 CallerAutoPilotControlManager.startAutoPilot(parameters);
}
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {
AdasManager.getInstance().sendPlanningCmd(2)
}
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {
ToastUtils.showShort("平行驾驶中请稍后")
}
else -> {}
}
subscribe = Observable.timer(1000, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
AdasManager.getInstance().sendRoboBusJinlvM1FrontDoorCmd(0)
}
AdasManager.getInstance().sendRoboBusJinlvM1FrontDoorCmd(1);
}
fun closeDoor(){
subscribe?.let {
if (!it.isDisposed) {
it.dispose()
}
}
subscribe = Observable.timer(1000, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
AdasManager.getInstance().sendRoboBusJinlvM1FrontDoorCmd(0)
}
AdasManager.getInstance().sendRoboBusJinlvM1FrontDoorCmd(2)
}
fun startStopSide() {
AdasManager.getInstance().sendPlanningCmd(2)
// when (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state) {
// IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {// 不可自动驾驶
// ToastUtils.showShort("设备未就绪请稍等")
// }
// IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE -> {//
// ToastUtils.showShort("启动自动驾驶中")
// // TODO: 查找线路和订单来确定 CallerAutoPilotControlManager.startAutoPilot(parameters);
// }
// IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {
// AdasManager.getInstance().sendPlanningCmd(2)
// }
// IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {
// ToastUtils.showShort("平行驾驶中请稍后")
// }
// else -> {}
// }
}
}

View File

@@ -2,6 +2,8 @@ package com.mogo.och.bus.passenger.presenter
import androidx.lifecycle.LifecycleOwner
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.och.bus.passenger.ui.BusPassengerFunctionSoftFragment
import com.mogo.och.common.module.manager.OCHM1LightAirconditionDoorStatusManager
import com.zhidao.support.adas.high.AdasManager
@@ -20,13 +22,18 @@ class BusPassengerFunctionSoftPresenter(view: BusPassengerFunctionSoftFragment?)
override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
OCHM1LightAirconditionDoorStatusManager.removeListener(TAG)
}
/**
* 空调状态变化
*/
override fun onAirconditionStatusCallback(heaterIsOpen: Boolean,airconditionStatus: OCHM1LightAirconditionDoorStatusManager.AirconditionStatus) {
CallerLogger.d(SceneConstant.M_BUS_P + TAG,
"回写--空调开关:${OCHM1LightAirconditionDoorStatusManager.airconditionStatus.isOpen}" +
"空调温度:${OCHM1LightAirconditionDoorStatusManager.airconditionStatus.temperature}" +
"空调模式:${OCHM1LightAirconditionDoorStatusManager.airconditionStatus.pattert}" +
"空调风速:${OCHM1LightAirconditionDoorStatusManager.airconditionStatus.windSpeed}")
mView?.setAirconditionHeaterView(
airconditionStatus.isOpen,
heaterIsOpen,
@@ -39,9 +46,12 @@ class BusPassengerFunctionSoftPresenter(view: BusPassengerFunctionSoftFragment?)
* 暖风机状态变化
*/
override fun onHeaterStatusCallback(airconditionIsOpen:Boolean,heaterStatue: OCHM1LightAirconditionDoorStatusManager.HeaterStatue) {
CallerLogger.d(SceneConstant.M_BUS_P + TAG,
"回写--暖风机开关:${heaterStatue.isOpen}" +
"风速:${heaterStatue.windSpeed}")
mView?.setAirconditionHeaterView(
heaterStatue.isOpen,
airconditionIsOpen,
heaterStatue.isOpen,
0,
0,
heaterStatue.windSpeed
@@ -51,35 +61,56 @@ class BusPassengerFunctionSoftPresenter(view: BusPassengerFunctionSoftFragment?)
* 灯状态变化
*/
override fun onLightCallback(lightStatus: OCHM1LightAirconditionDoorStatusManager.LightStatus) {
CallerLogger.d(SceneConstant.M_BUS_P + TAG,
"回写--顶灯1开关:${lightStatus.isOpenLight1}" +
"顶灯2开关:${lightStatus.isOpenLight2}" +
"氛围灯开关:${lightStatus.isOpenatmosphere}")
mView?.setLightView(lightStatus.isOpenLight1,lightStatus.isOpenLight2,lightStatus.isOpenatmosphere)
}
/**
* 设置空调
*/
fun sendRoboBusJinlvM1AirConditionerCmd(switchCmd: Int, modeCmd: Int, windSpeedCmd: Int, temperatureCmd: Int) {
AdasManager.getInstance().sendRoboBusJinlvM1AirConditionerCmd(switchCmd,modeCmd,windSpeedCmd,temperatureCmd)
fun openAndSetAircondition(modeCmd: Int, windSpeedCmd: Int, temperatureCmd: Int) {
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "" +
"打开空调,模式$modeCmd--档位${windSpeedCmd}--温度:$temperatureCmd")
AdasManager.getInstance().sendRoboBusJinlvM1AirConditionerCmd(1,modeCmd,windSpeedCmd,temperatureCmd)
}
fun closeAircondition() {
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "关闭空调")
AdasManager.getInstance().sendRoboBusJinlvM1AirConditionerCmd(2,0,0,0)
}
/**
* 设置暖风
*/
fun sendRoboBusJinlvM1HeaderCmd(switchCmd: Int, windSpeedCmd: Int) {
AdasManager.getInstance().sendRoboBusJinlvM1HeaderCmd(switchCmd,windSpeedCmd)
fun openAndSetHeader(windSpeedCmd: Int) {
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "打开暖风机、档位${windSpeedCmd}")
AdasManager.getInstance().sendRoboBusJinlvM1HeaderCmd(1,windSpeedCmd)
}
fun setLightData(leftLight: Boolean, rightLight: Boolean, atmosphereLight: Boolean) {
if (leftLight && rightLight) {
AdasManager.getInstance().sendRoboBusJinlvM1MainLampCmd(1,1)
} else if (!leftLight && !rightLight) {
AdasManager.getInstance().sendRoboBusJinlvM1MainLampCmd(2,2)
} else {
if (leftLight) {
AdasManager.getInstance().sendRoboBusJinlvM1MainLampCmd(1,2)
}
if (rightLight) {
AdasManager.getInstance().sendRoboBusJinlvM1MainLampCmd(2,1)
}
fun closeHeader(){
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "关闭暖风机")
AdasManager.getInstance().sendRoboBusJinlvM1HeaderCmd(2,0)
}
fun setLightData1(leftLight: Boolean){
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "顶灯2:$leftLight")
if(leftLight){
AdasManager.getInstance().sendRoboBusJinlvM1MainLamp1Cmd(1)
}else{
AdasManager.getInstance().sendRoboBusJinlvM1MainLamp1Cmd(2)
}
}
fun setLightData2(rightLight: Boolean){
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "顶灯1:$rightLight")
if(rightLight){
AdasManager.getInstance().sendRoboBusJinlvM1MainLamp2Cmd(1)
}else{
AdasManager.getInstance().sendRoboBusJinlvM1MainLamp2Cmd(2)
}
}
fun setAtmosphereLightData2(atmosphereLight: Boolean){
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "氛围灯:$atmosphereLight")
if (atmosphereLight) {
AdasManager.getInstance().sendRoboBusJinlvM1SmallLampCmd(1)
} else {

View File

@@ -7,7 +7,11 @@ import com.mogo.och.bus.passenger.R
import com.mogo.och.bus.passenger.presenter.BusPassengerFunctionDevicePresenter
import com.mogo.och.common.module.utils.SoundPoolHelper
import com.zhidao.support.adas.high.AdasManager
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import kotlinx.android.synthetic.m1.bus_p_function_setting_devices_fragment.*
import java.util.concurrent.TimeUnit
/**
* @author: yangyakun
@@ -15,6 +19,7 @@ import kotlinx.android.synthetic.m1.bus_p_function_setting_devices_fragment.*
*/
class BusPassengerFunctionDeviceFragment :
MvpFragment<BusPassengerFunctionDeviceFragment?, BusPassengerFunctionDevicePresenter?>() {
override fun getLayoutId(): Int = R.layout.bus_p_function_setting_devices_fragment
override fun getTagName(): String = TAG
@@ -38,11 +43,11 @@ class BusPassengerFunctionDeviceFragment :
}
tv_car_setting_opendoor.onClick {
// 开门 AdasManager.getInstance().sendRoboBusJinlvM1FrontDoorCmd(2);
AdasManager.getInstance().sendRoboBusJinlvM1FrontDoorCmd(1);
mPresenter?.openDoor()
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
}
tv_car_setting_closedoor.onClick {
AdasManager.getInstance().sendRoboBusJinlvM1FrontDoorCmd(2);
mPresenter?.closeDoor()
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
}
}

View File

@@ -1,6 +1,8 @@
package com.mogo.och.bus.passenger.ui
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ClipDrawable
import android.graphics.drawable.LayerDrawable
import android.graphics.drawable.ScaleDrawable
import android.media.AudioManager
@@ -17,6 +19,7 @@ import androidx.recyclerview.widget.SnapHelper
import com.mogo.commons.mvp.MvpFragment
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.ClickUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.och.bus.passenger.R
import com.mogo.och.bus.passenger.bean.Temperature
@@ -41,7 +44,7 @@ class BusPassengerFunctionSoftFragment :
override fun getTagName(): String = TAG
private var currentTemperature:Temperature?=null
private var currentTemperature: Temperature? = null
override fun initViews() {
rg_select_function.setOnCheckedChangeListener { group, checkedId ->
@@ -73,45 +76,99 @@ class BusPassengerFunctionSoftFragment :
private fun setAirconditionListener() {
// 开关空调或暖风机
tv_aircondition_switch.setOnCheckedChangeListener { buttonView, isChecked ->
if (tv_aircondition_switch.tag == touchTag) {
tv_aircondition_switch.tag = null
}else{
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
if(!buttonView.isPressed){
return@setOnCheckedChangeListener
}
if (rg_setting_pattern.checkedRadioButtonId==R.id.rb_pattern_heating) {
if(isChecked){// 打开暖风机
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
if (rg_setting_pattern.checkedRadioButtonId == R.id.rb_pattern_heating) {
if (isChecked) {// 打开暖风机
openHeater()
}else{// 关闭暖风机
} else {// 关闭暖风机
closeHeater()
}
}else{
if(isChecked){// 打开空调
} else {
if (isChecked) {// 打开空调
openAircondition()
}else{//关闭空调
} else {//关闭空调
closeAircondition()
}
}
}
// 模式调节
rg_setting_pattern.setOnCheckedChangeListener { group, checkedId ->
if (rg_setting_pattern.tag == touchTag) {
rg_setting_pattern.tag = null
}else{
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
if (!tv_aircondition_switch.isChecked) {
return@setOnCheckedChangeListener
}
CallerLogger.d(SceneConstant.M_BUS_P+ TAG,"调节模式")
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()
}
R.id.rb_pattern_refrigeration->{
if(!rb_pattern_refrigeration.isPressed){
return@setOnCheckedChangeListener
}
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
openAircondition()
}
R.id.rb_pattern_ventilate->{
if(!rb_pattern_ventilate.isPressed){
return@setOnCheckedChangeListener
}
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
openAircondition()
}
else -> {
openAircondition()
}
}
}
val pickerLayoutManager = PickerLayoutManager(requireContext(), PickerLayoutManager.HORIZONTAL, false)
// 风速调节
rg_setting_windspeed.setOnCheckedChangeListener { group, checkedId ->
if (!tv_aircondition_switch.isChecked) {
return@setOnCheckedChangeListener
}
when (checkedId) {
R.id.rb_wind_speed_low-> {
if(!rb_wind_speed_low.isPressed){
return@setOnCheckedChangeListener
}
}
R.id.rb_wind_speed_middle-> {
if(!rb_wind_speed_middle.isPressed){
return@setOnCheckedChangeListener
}
}
R.id.rb_wind_speed_high-> {
if(!rb_wind_speed_high.isPressed){
return@setOnCheckedChangeListener
}
}
else -> {}
}
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
if (rg_setting_pattern.checkedRadioButtonId == R.id.rb_pattern_heating) {//暖风机
openHeater()
} else {
openAircondition()
}
}
val pickerLayoutManager =
PickerLayoutManager(requireContext(), PickerLayoutManager.HORIZONTAL, false)
pickerLayoutManager.isChangeAlpha = true
pickerLayoutManager.scaleDownBy = 0.39f
pickerLayoutManager.scaleDownBy = 0.29f
pickerLayoutManager.scaleDownDistance = 0.8f
val adapter = TemperatureAdapter(requireContext(), getData(), rv_aircondition_temperature)
@@ -119,54 +176,49 @@ class BusPassengerFunctionSoftFragment :
snapHelper.attachToRecyclerView(rv_aircondition_temperature)
rv_aircondition_temperature.layoutManager = pickerLayoutManager
rv_aircondition_temperature.adapter = adapter
rv_aircondition_temperature.addItemDecoration(HorizontalDecoration(20))
// 风速调节
rg_setting_windspeed.setOnCheckedChangeListener { group, checkedId ->
if (rg_setting_windspeed.tag == touchTag) {
rg_setting_windspeed.tag = null
}else{
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
}
CallerLogger.d(SceneConstant.M_BUS_P+ TAG,"调节风速")
if (rg_setting_pattern.checkedRadioButtonId==R.id.rb_pattern_heating) {//暖风机
openHeater()
}else{
openAircondition()
}
}
rv_aircondition_temperature.addItemDecoration(HorizontalDecoration(15))
pickerLayoutManager.setOnScrollStopListener { view ->
if (view is TextView) {
view.setTextColor(Color.WHITE)
// 未拖到中点、自动滚动到中点会短时间触发两次
if (ClickUtils.isClickTooFrequent(rv_aircondition_temperature)) {
return@setOnScrollStopListener
}
val tag = view.tag
if (tag is Temperature) {
currentTemperature = tag
ToastUtils.showShort(tag.value)
if(rv_aircondition_temperature.tag== touchTag){
rv_aircondition_temperature.tag = null
return@setOnScrollStopListener
}else {
SoundPoolHelper.getSoundPoolHelper()
.playSoundWithRedId(context, R.raw.bus_di)
}
if (!tv_aircondition_switch.isChecked) {
return@setOnScrollStopListener
}
openAircondition()
}
}
}
}
private fun getData(): MutableList<Temperature> {
val mutableListOf = mutableListOf<Temperature>()
mutableListOf.add(Temperature(0,16,"16°"))
mutableListOf.add(Temperature(1,17,"17°"))
mutableListOf.add(Temperature(2,18,"18°"))
mutableListOf.add(Temperature(3,19,"19°"))
mutableListOf.add(Temperature(4,20,"20°"))
mutableListOf.add(Temperature(5,21,"21°"))
mutableListOf.add(Temperature(6,22,"22°"))
mutableListOf.add(Temperature(7,23,"23°"))
mutableListOf.add(Temperature(8,24,"24°"))
mutableListOf.add(Temperature(9,25,"25°"))
mutableListOf.add(Temperature(10,26,"26°"))
mutableListOf.add(Temperature(0, 16, "16°"))
mutableListOf.add(Temperature(1, 17, "17°"))
mutableListOf.add(Temperature(2, 18, "18°"))
mutableListOf.add(Temperature(3, 19, "19°"))
mutableListOf.add(Temperature(4, 20, "20°"))
mutableListOf.add(Temperature(5, 21, "21°"))
mutableListOf.add(Temperature(6, 22, "22°"))
mutableListOf.add(Temperature(7, 23, "23°"))
mutableListOf.add(Temperature(8, 24, "24°"))
mutableListOf.add(Temperature(9, 25, "25°"))
mutableListOf.add(Temperature(10, 26, "26°"))
return mutableListOf
}
@@ -174,56 +226,59 @@ class BusPassengerFunctionSoftFragment :
* 关闭空调
*/
private fun closeAircondition() {
CallerLogger.d(SceneConstant.M_BUS_P+ TAG,"关闭空调")
mPresenter?.sendRoboBusJinlvM1AirConditionerCmd(2,0,0,0)
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "关闭空调")
mPresenter?.closeAircondition()
}
/**
* 开启空调
*/
private fun openAircondition() {
CallerLogger.d(SceneConstant.M_BUS_P+ TAG,"打开空调")
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "打开空调")
var modeCmd = 0
var windSpeedCmd = 0
val temperatureCmd = currentTemperature?.value?:26
val temperatureCmd = currentTemperature?.value ?: 26
closeHeater()//关闭暖风
when (rg_setting_pattern.checkedRadioButtonId) {
R.id.rb_pattern_automatic -> modeCmd = 1 // 自动
R.id.rb_pattern_refrigeration -> modeCmd = 2 // 制冷
R.id.rb_pattern_ventilate -> modeCmd = 3 // 通风
R.id.rb_pattern_ventilate -> modeCmd = 3 // 通风
else -> {}
}
when (rg_setting_windspeed.checkedRadioButtonId) {
R.id.rb_wind_speed_low -> windSpeedCmd = 1 // 1档
R.id.rb_wind_speed_middle -> windSpeedCmd = 2 // 2档
R.id.rb_wind_speed_high -> windSpeedCmd = 3 // 3档
R.id.rb_wind_speed_high -> windSpeedCmd = 3 // 3档
else -> {}
}
mPresenter?.sendRoboBusJinlvM1AirConditionerCmd(1,modeCmd,windSpeedCmd,temperatureCmd)
mPresenter?.openAndSetAircondition(modeCmd, windSpeedCmd, temperatureCmd)
}
/**
* 根据车的状态会写页面状态
*/
fun setAirconditionHeaterView(airIsOpen:Boolean,heaterIsOpen:Boolean,temperatureCmd:Int,pattern:Int,windSpeed:Int){
if(!airIsOpen&&!heaterIsOpen){
tv_aircondition_switch.tag = touchTag
fun setAirconditionHeaterView(
airIsOpen: Boolean,
heaterIsOpen: Boolean,
temperatureCmd: Int,
pattern: Int,
windSpeed: Int
) {
if (!airIsOpen && !heaterIsOpen) {
tv_aircondition_switch.isChecked = false
}else{
tv_aircondition_switch.tag = touchTag
} else {
tv_aircondition_switch.isChecked = true
}
if(airIsOpen){
if (airIsOpen) {
val adapter = rv_aircondition_temperature.adapter
if (adapter is TemperatureAdapter) {
adapter.data.forEach {
if (it.value==temperatureCmd) {
if (it.value == temperatureCmd) {
rv_aircondition_temperature.tag = touchTag
rv_aircondition_temperature.smoothScrollToPosition(it.index)
}
}
}
rg_setting_pattern.tag = touchTag
when (pattern) {//1: 自动模式, 2: 制冷模式, 3: 通风模式(仅送风,无温度)
1 -> {rb_pattern_automatic.isChecked = true}
2 -> {rb_pattern_refrigeration.isChecked = true}
@@ -231,7 +286,6 @@ class BusPassengerFunctionSoftFragment :
else -> {}
}
heaterAirEnable(true)
rg_setting_windspeed.tag = touchTag
when (windSpeed) {//1: 1档2: 2档3:3档
1 -> {rb_wind_speed_low.isChecked = true}
2 -> {rb_wind_speed_middle.isChecked = true}
@@ -239,11 +293,9 @@ class BusPassengerFunctionSoftFragment :
else -> {}
}
}
if(heaterIsOpen){
rg_setting_pattern.tag = touchTag
if (heaterIsOpen) {
rb_pattern_heating.isChecked = true
heaterAirEnable(false)
rg_setting_windspeed.tag = touchTag
when (windSpeed) {//1: 1档2: 2档
1 -> {rb_wind_speed_middle.isChecked = true}
2 -> {rb_wind_speed_high.isChecked = true}
@@ -256,87 +308,107 @@ class BusPassengerFunctionSoftFragment :
* 关闭暖风机
*/
private fun closeHeater() {
CallerLogger.d(SceneConstant.M_BUS_P+ TAG,"关闭暖风")
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "关闭暖风")
heaterAirEnable(true)
when (rg_setting_windspeed.checkedRadioButtonId) {
R.id.rb_wind_speed_low -> {}
R.id.rb_wind_speed_middle -> {
mPresenter?.sendRoboBusJinlvM1HeaderCmd(2,1)
}
R.id.rb_wind_speed_high -> {
mPresenter?.sendRoboBusJinlvM1HeaderCmd(2,2)
AdasManager.getInstance().sendRoboBusJinlvM1HeaderCmd(2,2)
}
else -> {}
}
mPresenter?.closeHeader()
}
private fun heaterAirEnable(enable:Boolean){
private fun heaterAirEnable(enable: Boolean) {
tv_temperature_title.isEnabled = enable
rv_aircondition_temperature.isEnabled = enable
rb_wind_speed_low.isEnabled = enable
val layoutManager = rv_aircondition_temperature.layoutManager
if (layoutManager is PickerLayoutManager) {
layoutManager.setHorizontallyScroll(enable)
}
}
/**
* 开启暖风机
*/
private fun openHeater() {
CallerLogger.d(SceneConstant.M_BUS_P+ TAG,"打开暖风")
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "打开暖风")
heaterAirEnable(false)
closeAircondition()//关闭空调
when (rg_setting_windspeed.checkedRadioButtonId) {
R.id.rb_wind_speed_low -> {
rb_wind_speed_middle.tag = touchTag
rb_wind_speed_middle.toggle()
mPresenter?.openAndSetHeader(1)
}
R.id.rb_wind_speed_middle -> {
AdasManager.getInstance().sendRoboBusJinlvM1HeaderCmd(1,1)
mPresenter?.openAndSetHeader(1)
}
R.id.rb_wind_speed_high -> {
AdasManager.getInstance().sendRoboBusJinlvM1HeaderCmd(1,2)
mPresenter?.openAndSetHeader(2)
}
else -> {
rb_wind_speed_middle.tag = touchTag
rb_wind_speed_middle.toggle()
mPresenter?.openAndSetHeader(1)
}
}
}
// region 灯
private fun setLightListener() {
tv_light_top_01.setOnCheckedChangeListener { buttonView, isChecked ->
if(!buttonView.isPressed){
return@setOnCheckedChangeListener
}
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
mPresenter?.setLightData(isChecked, tv_light_top_02.isChecked, tv_light_atmosphere.isChecked)
mPresenter?.setLightData1(isChecked)
setLightView(isChecked, tv_light_top_02.isChecked, tv_light_atmosphere.isChecked)
}
tv_light_top_02.setOnCheckedChangeListener { buttonView, isChecked ->
if(!buttonView.isPressed){
return@setOnCheckedChangeListener
}
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
mPresenter?.setLightData(isChecked, tv_light_top_02.isChecked, tv_light_atmosphere.isChecked)
mPresenter?.setLightData2(isChecked)
setLightView(tv_light_top_01.isChecked, isChecked, tv_light_atmosphere.isChecked)
}
tv_light_atmosphere.setOnCheckedChangeListener { buttonView, isChecked ->
if(!buttonView.isPressed){
return@setOnCheckedChangeListener
}
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
mPresenter?.setLightData(isChecked, tv_light_top_02.isChecked, tv_light_atmosphere.isChecked)
mPresenter?.setAtmosphereLightData2(isChecked)
setLightView(tv_light_top_01.isChecked, tv_light_top_02.isChecked, isChecked)
}
}
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) {
if(leftLight){
tv_light_top_01.tag = touchTag
tv_light_top_02.tag = touchTag
tv_light_atmosphere.tag = touchTag
if (leftLight) {
tv_light_top_01.text = requireContext().getString(R.string.bus_p_m1_close_light1)
}else{
tv_light_top_01.isChecked = true
} else {
tv_light_top_01.text = requireContext().getString(R.string.bus_p_m1_open_light1)
tv_light_top_01.isChecked = false
}
if(rightLight){
if (rightLight) {
tv_light_top_02.text = requireContext().getString(R.string.bus_p_m1_close_light2)
}else{
tv_light_top_02.isChecked = true
} else {
tv_light_top_02.text = requireContext().getString(R.string.bus_p_m1_open_light2)
tv_light_top_02.isChecked = false
}
if (leftLight && rightLight) {
iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_middle_selected)// 都打开
@@ -352,9 +424,11 @@ class BusPassengerFunctionSoftFragment :
}
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)
} 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)
}
}
@@ -372,7 +446,7 @@ class BusPassengerFunctionSoftFragment :
val color1060FF = ContextCompat.getColor(requireContext(), R.color.bus_p_m1_1060ff)
val color96A5C2 = ContextCompat.getColor(requireContext(), R.color.bus_p_m1_96a5c2)
val temp03 = MineGradientDrawable(color2CBFFC, color1060FF, dp2px)
val scaleDrawable3 = ScaleDrawable(temp03, Gravity.START, 1f, 0f)
val scaleDrawable3 = ClipDrawable(temp03, Gravity.START, ClipDrawable.HORIZONTAL)
val temp01 = MineGradientDrawable(color96A5C2, color96A5C2, dp2px)
val arr = arrayOf(temp01, scaleDrawable3)
val ld = LayerDrawable(arr)
@@ -387,7 +461,7 @@ class BusPassengerFunctionSoftFragment :
if (fromUser) {
mMaxVolume?.let {
var currnetValue = ((progress.toFloat() / 100) * it).toInt()
if(currnetValue <=0){
if (currnetValue <= 0) {
currnetValue = 1;
}
mAudioManager?.setStreamVolume(
@@ -417,13 +491,13 @@ class BusPassengerFunctionSoftFragment :
val mCurrentVolume = mAudioManager?.getStreamVolume(AudioManager.STREAM_MUSIC)
mMaxVolume?.let { max ->
mCurrentVolume?.let { current ->
if(current==1){
if (current == 1) {
sb_voice_bar.progress = 5
tv_current_voice_value.text= "5%"
}else {
tv_current_voice_value.text = "5%"
} else {
val fl = current.toFloat() / max * 100
sb_voice_bar.progress = fl.toInt()
tv_current_voice_value.text= "${fl.toInt()}%"
tv_current_voice_value.text = "${fl.toInt()}%"
}
}
}
@@ -439,6 +513,7 @@ class BusPassengerFunctionSoftFragment :
const val TAG = "BusPassengerFunctionSoftFragment"
const val touchTagKey = 2
const val touchTag = 2
@JvmStatic
fun newInstance(): BusPassengerFunctionSoftFragment {
val args = Bundle()

View File

@@ -0,0 +1,70 @@
package com.mogo.och.bus.passenger.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.CheckBox;
import androidx.annotation.Nullable;
import java.lang.ref.WeakReference;
public class DrawableCheckBox extends androidx.appcompat.widget.AppCompatCheckBox {
public DrawableCheckBox(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
public DrawableCheckBox(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public DrawableCheckBox(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
protected void onDraw(Canvas canvas) {
//获取设置的图片
Drawable[] drawables = getCompoundDrawables();
if (drawables != null) {
//第一个是left
Drawable drawableLeft = drawables[0];
if (drawableLeft != null) {
//获取文字的宽度
float textWidth = getPaint().measureText(getText().toString());
int drawablePadding = getCompoundDrawablePadding();
int drawableWidth = 0;
drawableWidth = drawableLeft.getIntrinsicWidth();
float bodyWidth = textWidth + drawableWidth + drawablePadding;
int y = getWidth();
canvas.translate((getWidth() - bodyWidth) / 2, 0);
}
}
super.onDraw(canvas);
}
}

View File

@@ -3,11 +3,16 @@ package com.mogo.och.bus.passenger.view;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.eagle.core.utilcode.util.ClickUtils;
import com.mogo.och.bus.passenger.R;
public class PickerLayoutManager extends LinearLayoutManager {
private float scaleDownBy = 0.66f;
@@ -16,6 +21,8 @@ public class PickerLayoutManager extends LinearLayoutManager {
private onScrollStopListener onScrollStopListener;
private boolean mCanHorizontallyScroll = true;
public PickerLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
@@ -26,6 +33,19 @@ public class PickerLayoutManager extends LinearLayoutManager {
scaleDownView();
}
@Override
public boolean canScrollHorizontally() {
if (!mCanHorizontallyScroll){
return false;
}else {
return super.canScrollHorizontally();
}
}
public void setHorizontallyScroll(boolean b){
mCanHorizontallyScroll = b;
}
@Override
public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) {
int orientation = getOrientation();
@@ -56,6 +76,9 @@ public class PickerLayoutManager extends LinearLayoutManager {
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
if(!mCanHorizontallyScroll){
return;
}
RecyclerView.SmoothScroller smoothScroller = new CenterSmoothScroller(recyclerView.getContext());
smoothScroller.setTargetPosition(position);
startSmoothScroll(smoothScroller);
@@ -80,6 +103,13 @@ public class PickerLayoutManager extends LinearLayoutManager {
}
onScrollStopListener.selectedView(getChildAt(selected));
}
}else {
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
if (child instanceof TextView) {
((TextView) child).setTextColor(ContextCompat.getColor(child.getContext(), R.color.bus_p_m1_47576E));
}
}
}
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/dp_44"/>
<solid android:color="@android:color/transparent"/>
</shape>

View File

@@ -82,7 +82,7 @@
app:layout_constraintStart_toStartOf="@+id/gl_left"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
<com.mogo.och.bus.passenger.view.DrawableCheckBox
android:id="@+id/tv_aircondition_switch"
android:layout_width="0dp"
android:layout_height="@dimen/dp_76"
@@ -92,8 +92,9 @@
android:button="@null"
android:checked="true"
android:drawableLeft="@drawable/bus_p_function_switch_left_selector"
android:gravity="center"
android:text="打开空调"
android:gravity="left|center_vertical"
android:drawablePadding="@dimen/dp_13"
android:textColor="@drawable/bus_p_function_airconditon_text_color_selector"
android:textSize="@dimen/dp_24"
app:layout_constraintBottom_toTopOf="@+id/tv_light_top_02"
@@ -114,12 +115,32 @@
app:layout_constraintStart_toStartOf="@+id/tv_aircondition_switch"
app:layout_constraintTop_toTopOf="@+id/rv_aircondition_temperature" />
<View
android:id="@+id/v_temperature_bg"
app:layout_constraintStart_toStartOf="@+id/rv_aircondition_temperature"
app:layout_constraintEnd_toEndOf="@+id/rv_aircondition_temperature"
app:layout_constraintTop_toTopOf="@+id/rv_aircondition_temperature"
app:layout_constraintBottom_toBottomOf="@+id/rv_aircondition_temperature"
android:background="@drawable/bus_p_function_aircondition_common_bg"
android:layout_width="0dp"
android:layout_height="0dp"/>
<ImageView
android:id="@+id/iv_temperature_select"
app:layout_constraintStart_toStartOf="@+id/rv_aircondition_temperature"
app:layout_constraintEnd_toEndOf="@+id/rv_aircondition_temperature"
app:layout_constraintTop_toTopOf="@+id/rv_aircondition_temperature"
app:layout_constraintBottom_toBottomOf="@+id/rv_aircondition_temperature"
android:src="@drawable/bus_p_function_aircondition_pattern_selected"
android:layout_width="@dimen/dp_59"
android:layout_height="@dimen/dp_60"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_aircondition_temperature"
android:layout_width="0dp"
android:layout_height="@dimen/dp_60"
android:layout_marginTop="@dimen/dp_41"
android:background="@drawable/bus_p_function_aircondition_common_bg"
android:background="@drawable/bus_p_function_aircondition_common_bg_01"
app:layout_constraintEnd_toEndOf="@+id/tv_aircondition_switch"
app:layout_constraintTop_toBottomOf="@+id/tv_aircondition_switch"
app:layout_constraintWidth_percent="0.244" />
@@ -262,7 +283,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
app:constraint_referenced_ids="tv_aircondition_switch,tv_temperature_title,rv_aircondition_temperature,tv_aircondition_pattern_title,rg_setting_pattern,tv_aircondition_wind_speed_title,rg_setting_windspeed" />
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" />
<!--endregion-->
<!--region 灯光调整-->

View File

@@ -29,6 +29,9 @@ object OCHM1LightAirconditionDoorStatusManager : IMoGoRoboBusJinlvM1StatesListen
return
}
M_LISTENERS[tag] = listener
listener.onLightCallback(lightStatus)
listener.onAirconditionStatusCallback(heaterStatue.isOpen,airconditionStatus)
listener.onHeaterStatusCallback(airconditionStatus.isOpen,heaterStatue)
}
fun removeListener(tag: String) {