[1.0.2]
[状态修改]
This commit is contained in:
yangyakun
2023-02-21 21:29:31 +08:00
parent 0d084aefc2
commit 409faba1e9
14 changed files with 272 additions and 65 deletions

View File

@@ -51,7 +51,7 @@ class BusPassengerFunctionDevicePresenter(view: BusPassengerFunctionDeviceFragme
}
override fun onDoorStatusCallback(isOpen: Boolean,isFirst: Boolean) {
if(isFirst) {
if(!isFirst) {
if (isOpen) {
ToastUtils.showShort("已开启车门")
} else {

View File

@@ -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("空调操作未生效,请稍后重试吧~")
}
}
}

View File

@@ -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

View File

@@ -84,7 +84,7 @@ public class TemperatureAdapter extends RecyclerView.Adapter<TemperatureAdapter.
public void setCheckIndex(int index) {
checkIndex = index;
notifyItemChanged(checkIndex);
notifyDataSetChanged();
}
class TextVH extends RecyclerView.ViewHolder {

View File

@@ -0,0 +1,57 @@
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.Paint
import android.util.AttributeSet
import android.view.View
import com.mogo.och.bus.passenger.R
class DrawBitmapView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {
private lateinit var mBitmap: Bitmap
private lateinit var mBitPaint: Paint
private var drawBitmapViewResource = R.drawable.bus_pm1_aircondition_wind_high
private var mBitWidth = 0
private var showHeight = 0
set(value) {
field = value
postInvalidate()
}
init {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.MainWindStatus)
drawBitmapViewResource = typedArray.getResourceId(R.styleable.MainWindStatus_main_wind_drawable,R.drawable.bus_pm1_aircondition_wind_high)
typedArray.recycle()
initBitmap()
initPaint()
}
fun setDrawableImage(bitmap: Bitmap){
mBitmap = bitmap
}
private fun initPaint() {
mBitPaint = Paint(Paint.ANTI_ALIAS_FLAG)
mBitPaint.isFilterBitmap = true
mBitPaint.isDither = true
}
private fun initBitmap() {
mBitmap = BitmapFactory.decodeResource(resources, drawBitmapViewResource)
mBitWidth = mBitmap.width
}
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
canvas.clipRect(0, 0, mBitWidth, showHeight)
canvas.drawBitmap(mBitmap, (width-mBitmap.width)/2f, 0f, mBitPaint)
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

View File

@@ -82,6 +82,15 @@
app:layout_constraintStart_toStartOf="@+id/gl_left"
app:layout_constraintTop_toTopOf="parent" />
<com.mogo.och.bus.passenger.view.DrawBitmapView
android:id="@+id/dbv_wind"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/iv_aircondition"
app:layout_constraintHeight_percent="0.5"
app:layout_constraintStart_toStartOf="@+id/iv_aircondition" />
<com.mogo.och.bus.passenger.view.DrawableCheckBox
android:id="@+id/tv_aircondition_switch"
android:layout_width="0dp"
@@ -283,7 +292,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
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" />
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" />
<!--endregion-->
<!--region 灯光调整-->

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="MainWindStatus">
<attr name="main_wind_drawable" format="reference" />
</declare-styleable>
</resources>

View File

@@ -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)
}
}
}