From 8fb382b6098f78da8e05b7922a9195fdb8da27d0 Mon Sep 17 00:00:00 2001 From: yangyakun Date: Mon, 14 Aug 2023 20:00:42 +0800 Subject: [PATCH] =?UTF-8?q?[5.0.0]=20[video=20=E6=8A=BD=E5=8F=96view]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mogo/och/bus/passenger/ui/MainFragment.kt | 90 +++++--- .../ui/softcontrol/SoftControlView.kt | 196 +++++++++++------- .../ui/softcontrol/SoftControlViewModel.kt | 160 ++++++++------ .../layoutmanage/CarouselLayoutManager.java | 15 +- .../ui/softcontrol/view/DrawBitmapView.kt | 13 +- .../och/bus/passenger/ui/video/VideoView.kt | 167 +++++++++++++++ .../src/main/res/layout/m1_main_fragment.xml | 150 +++++++------- .../src/main/res/layout/m1_soft_fragment.xml | 2 + .../src/main/res/layout/m1_video_fragment.xml | 2 + .../src/main/res/values/dimens.xml | 1 + 10 files changed, 541 insertions(+), 255 deletions(-) create mode 100644 OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/video/VideoView.kt diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/MainFragment.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/MainFragment.kt index 8d0c3a0e38..86a50b8cb3 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/MainFragment.kt +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/MainFragment.kt @@ -21,7 +21,6 @@ import com.mogo.och.bus.passenger.callback.IClearViewCallback import com.mogo.och.bus.passenger.presenter.BusPassengerPresenter import com.mogo.och.bus.passenger.ui.bottom.BottomBar import com.mogo.och.bus.passenger.ui.bottom.BottomClickView -import com.mogo.och.common.module.manager.debug.DebugViewWatchDogFragment import com.mogo.och.bus.passenger.ui.dialogfragment.M1CarUserNoOrderFragment import com.mogo.och.bus.passenger.ui.dialogfragment.M1ContainFragment import com.mogo.och.bus.passenger.ui.dialogfragment.NoviceGuidanceFragment @@ -43,13 +42,17 @@ class MainFragment : private var noviceGuidanceFragment: WeakReference? = null private val endStation = - BitmapFactory.decodeResource(AbsMogoApplication.getApp().resources, - R.drawable.m1_small_map_view_dir_end) + BitmapFactory.decodeResource( + AbsMogoApplication.getApp().resources, + R.drawable.m1_small_map_view_dir_end + ) private val lineTrajectory = - BitmapFactory.decodeResource(AbsMogoApplication.getApp().resources, - R.drawable.charter_p_trajectory_line) + BitmapFactory.decodeResource( + AbsMogoApplication.getApp().resources, + R.drawable.charter_p_trajectory_line + ) - private val goneView = object : IClearViewCallback{ + private val goneView = object : IClearViewCallback { override fun goneAllView() { bb_boorombar.setCheckIndex(BottomBar.SelectView.NONE) } @@ -89,20 +92,20 @@ class MainFragment : }) - bb_boorombar.setCheckChangeListener(object :BottomBar.ApplyClickLintener{ + bb_boorombar.setCheckChangeListener(object : BottomBar.ApplyClickLintener { override fun onApplyClick(selectItem: BottomBar.SelectView) { when (selectItem) { BottomBar.SelectView.ORDERINFO -> showBizView(orderinfo = true) BottomBar.SelectView.SETTING -> showBizView(softControl = true) BottomBar.SelectView.LINE -> showBizView(selectLine = true) - //BottomBar.SelectView.VIDEO -> TODO() - else ->{ + BottomBar.SelectView.VIDEO -> showBizView(showVideo = true) + else -> { showBizView() } } } }) - bb_boorombar.setApplyClickListener(object : BottomClickView.ApplyClickLintener{ + bb_boorombar.setApplyClickListener(object : BottomClickView.ApplyClickLintener { override fun onApplyClick() { bb_boorombar.setCheckIndex(BottomBar.SelectView.NONE) } @@ -110,9 +113,10 @@ class MainFragment : biz_orderinfo.goneViewListener = goneView biz_softcontrol.goneViewListener = goneView biz_selectline.goneViewListener = goneView + biz_video.goneViewListener = goneView - aciv_enter_video.setOnClickListener{ - openSettingPage(M1ContainFragment.VIDEOTAB) + aciv_enter_video.setOnClickListener { + bb_boorombar.setCheckIndex(BottomBar.SelectView.VIDEO) } aciv_map_2_default.setOnClickListener { omvOverMap.displayCustomOverView() @@ -121,26 +125,36 @@ class MainFragment : } } - fun setCarMode(type: Int){ + fun setCarMode(type: Int) { mPresenter?.setCarChangeListener(type) } - private fun showBizView(orderinfo:Boolean=false,softControl:Boolean=false,selectLine:Boolean=false){ - if(orderinfo){ + private fun showBizView( + orderinfo: Boolean = false, + softControl: Boolean = false, + selectLine: Boolean = false, + showVideo: Boolean = false + ) { + if (orderinfo) { biz_orderinfo.visibility = View.VISIBLE - }else{ + } else { biz_orderinfo.visibility = View.GONE } - if(softControl){ + if (softControl) { biz_softcontrol.visibility = View.VISIBLE - }else{ + } else { biz_softcontrol.visibility = View.GONE } - if(selectLine){ + if (selectLine) { biz_selectline.visibility = View.VISIBLE - }else{ + } else { biz_selectline.visibility = View.GONE } + if (showVideo) { + biz_video.visibility = View.VISIBLE + } else { + biz_video.visibility = View.GONE + } } private fun openSettingPage(tab: String) { @@ -148,7 +162,7 @@ class MainFragment : bpFunctionGroupDialogFragment = WeakReference(M1ContainFragment.newInstance()) } val bpFunctionGroup = bpFunctionGroupDialogFragment?.get() - M1ContainFragment.openSettingPage(childFragmentManager,parentFragmentManager,bpFunctionGroup,tab) + M1ContainFragment.openSettingPage(childFragmentManager, parentFragmentManager, bpFunctionGroup, tab) } fun setCarModle(rawInfo: Int){ @@ -168,9 +182,10 @@ class MainFragment : fun drawEndStation(latLng: LatLng) { val listOf = listOf(latLng) - omvOverMap.drawSiteMarkers(listOf,endStation,0.5f,1f) + omvOverMap.drawSiteMarkers(listOf, endStation, 0.5f, 1f) } - fun cleanEndStation(){ + + fun cleanEndStation() { omvOverMap.clearSiteMarkers() omvOverMap.clearCustomPolyline() } @@ -214,23 +229,33 @@ class MainFragment : m1CarUserNoOrderFragment = WeakReference(M1CarUserNoOrderFragment.newInstance()) } val m1CarUserNoOrderFragment = m1CarUserNoOrderFragment?.get() - M1CarUserNoOrderFragment.showOpenAndCloseDoor(childFragmentManager,parentFragmentManager,m1CarUserNoOrderFragment) + M1CarUserNoOrderFragment.showOpenAndCloseDoor( + childFragmentManager, + parentFragmentManager, + m1CarUserNoOrderFragment + ) } + fun showNoviceGuidanceFragment() { if (noviceGuidanceFragment?.get() == null) { noviceGuidanceFragment = WeakReference(NoviceGuidanceFragment.newInstance()) } val noviceGuidanceFragmentWeak = noviceGuidanceFragment?.get() - NoviceGuidanceFragment.showNoviceGuidance(childFragmentManager,parentFragmentManager,noviceGuidanceFragmentWeak) + NoviceGuidanceFragment.showNoviceGuidance( + childFragmentManager, + parentFragmentManager, + noviceGuidanceFragmentWeak + ) } - fun closeOpenAndCloseDoor(){ + + fun closeOpenAndCloseDoor() { val bpFunctionGroup = m1CarUserNoOrderFragment?.get() bpFunctionGroup?.let { bpFunctionGroup.dismissAllowingStateLoss() } UiThreadHandler.postDelayed({ cleanEndStation() - },2_000) + }, 2_000) } @Subscribe(threadMode = ThreadMode.MAIN) @@ -243,15 +268,18 @@ class MainFragment : omvOverMap?.clearSiteNameViews() mPresenter?.drawEndStation() } else { - if(eventLineSites.lineInfo==null){//更新站点 + if (eventLineSites.lineInfo == null) {//更新站点 mPresenter?.drawStationInfo(eventLineSites.sites!!) - }else{// 更新轨迹和站点 - mPresenter?.getLineTrajectory(eventLineSites.lineInfo,eventLineSites.sites!!) + } else {// 更新轨迹和站点 + mPresenter?.getLineTrajectory(eventLineSites.lineInfo, eventLineSites.sites!!) } } } - fun drawOverMapViewStation(stationsList: MutableList,siteMarkers: List?){ + fun drawOverMapViewStation( + stationsList: MutableList, + siteMarkers: List? + ) { omvOverMap?.clearSiteMarkers() omvOverMap?.clearSiteNameViews() omvOverMap?.drawSiteMarkers(stationsList) diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/SoftControlView.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/SoftControlView.kt index b9dea77481..2cfcf5f3e3 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/SoftControlView.kt +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/SoftControlView.kt @@ -76,7 +76,7 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba private val TAG = "OrderInfoView" - private var viewModel:SoftControlViewModel?=null + private var viewModel: SoftControlViewModel? = null constructor(context: Context) : super(context) @@ -95,7 +95,7 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba defStyleRes: Int ) : super(context, attributeSet, defStyleAttr, defStyleRes) - var goneViewListener: IClearViewCallback?=null + var goneViewListener: IClearViewCallback? = null private var currentTemperature: Temperature? = null @@ -106,12 +106,13 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba private var subscribeAnimator: Disposable? = null private var animator1: ObjectAnimator? = null - - private val loadingAni = ObjectAnimator.ofFloat(iv_loading, "rotation", 0f, 90f ,180f, 270f, 360f).apply { - repeatCount = -1 - interpolator = LinearInterpolator() - duration = 1000 - } + + private val loadingAni = + ObjectAnimator.ofFloat(iv_loading, "rotation", 0f, 90f, 180f, 270f, 360f).apply { + repeatCount = -1 + interpolator = LinearInterpolator() + duration = 1000 + } private fun initView() { @@ -121,7 +122,7 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba } } - private fun setViewGone(){ + private fun setViewGone() { goneViewListener?.goneAllView() } @@ -136,28 +137,31 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba R.id.tv_setting_aircondition -> { g_light_setting.visibility = View.GONE g_voice_setting.visibility = View.GONE - if(loadingAni.isRunning){ + if (loadingAni.isRunning) { iv_loading.visibility = View.VISIBLE g_aircondition_setting.visibility = View.GONE - }else{ + } else { g_aircondition_setting.visibility = View.VISIBLE } } + R.id.tv_setting_lighting -> { g_light_setting.visibility = View.VISIBLE g_voice_setting.visibility = View.GONE g_aircondition_setting.visibility = View.GONE iv_loading.visibility = View.GONE } + R.id.tv_setting_voice -> { g_voice_setting.visibility = View.VISIBLE g_aircondition_setting.visibility = View.GONE g_light_setting.visibility = View.GONE iv_loading.visibility = View.GONE } + else -> {} } - if(rb_pattern_heating.isChecked){ + if (rb_pattern_heating.isChecked) { iv_temperature_select.visibility = View.GONE } } @@ -169,9 +173,9 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba } - fun setWind(check: RadioButton, resource:Int){ + fun setWind(check: RadioButton, resource: Int) { check.isChecked = true - dbv_wind.setDrawableImage(BitmapFactory.decodeResource(resources,resource)) + dbv_wind.setDrawableImage(BitmapFactory.decodeResource(resources, resource)) } /** @@ -191,18 +195,28 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba layoutManager.setHorizontallyScroll(enable) } val adapter = rv_aircondition_temperature.adapter as TemperatureAdapter - if(enable){ + if (enable) { adapter.setEnable(true) - if(tv_setting_aircondition.isChecked) { - if(iv_loading.visibility==View.GONE){ + if (tv_setting_aircondition.isChecked) { + if (iv_loading.visibility == View.GONE) { iv_temperature_select.visibility = View.VISIBLE } } - rb_wind_speed_low.setTextColor(ContextCompat.getColorStateList(context,R.color.bus_p_function_airconditon_pattern_text_color_selector)) - }else{ + rb_wind_speed_low.setTextColor( + ContextCompat.getColorStateList( + context, + R.color.bus_p_function_airconditon_pattern_text_color_selector + ) + ) + } else { adapter.setEnable(false) iv_temperature_select.visibility = View.GONE - rb_wind_speed_low.setTextColor(ContextCompat.getColor(context,R.color.bus_p_m1_6647576e)) + rb_wind_speed_low.setTextColor( + ContextCompat.getColor( + context, + R.color.bus_p_m1_6647576e + ) + ) } } @@ -220,12 +234,15 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba rb_wind_speed_middle.toggle() switch = 1 } + R.id.rb_wind_speed_middle -> { switch = 1 } + R.id.rb_wind_speed_high -> { switch = 2 } + else -> { rb_wind_speed_middle.tag = M1SoftFragment.touchTag rb_wind_speed_middle.toggle() @@ -262,7 +279,7 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba viewModel?.closeAircondition(modeCmd, windSpeedCmd, temperatureCmd) } - fun showAni(){ + fun showAni() { iv_loading.visibility = View.VISIBLE loadingAni.target = iv_loading loadingAni.start() @@ -272,9 +289,9 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba .subscribe { loadingAni.cancel() iv_loading.visibility = View.GONE - if(tv_setting_aircondition.isChecked){ + if (tv_setting_aircondition.isChecked) { g_aircondition_setting.visibility = View.VISIBLE - if(rb_pattern_heating.isChecked){ + if (rb_pattern_heating.isChecked) { iv_temperature_select.visibility = View.GONE } } @@ -308,7 +325,7 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba viewModel?.openAndSetAircondition(modeCmd, windSpeedCmd, temperatureCmd) } - private fun setCheckAir(adapter: TemperatureAdapter, tag:Temperature){ + private fun setCheckAir(adapter: TemperatureAdapter, tag: Temperature) { adapter.setCheckIndex(tag.index) currentTemperature = tag if (rv_aircondition_temperature.tag == M1SoftFragment.touchTag) { @@ -325,7 +342,7 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba // region 灯 private fun setLightListener(viewModel: SoftControlViewModel?) { tv_light_top_01.setOnCheckedChangeListener { buttonView, isChecked -> - if(!buttonView.isPressed){ + if (!buttonView.isPressed) { return@setOnCheckedChangeListener } tv_light_top_01.isEnabled = false @@ -336,26 +353,26 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba } SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di) viewModel?.setLightData1(isChecked) - setLightTop1View(isChecked,true) - setLightView(isChecked,tv_light_top_02.isChecked) + setLightTop1View(isChecked, true) + setLightView(isChecked, tv_light_top_02.isChecked) } tv_light_top_02.setOnCheckedChangeListener { buttonView, isChecked -> - if(!buttonView.isPressed){ + if (!buttonView.isPressed) { return@setOnCheckedChangeListener } tv_light_top_02.isEnabled = false - subscribeLightTop2 = Observable.timer(2000, TimeUnit.MILLISECONDS) + subscribeLightTop2 = Observable.timer(2000, TimeUnit.MILLISECONDS) .observeOn(AndroidSchedulers.mainThread()) .subscribe { tv_light_top_02.isEnabled = true } SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di) viewModel?.setLightData2(isChecked) - setLightTop2View(isChecked,true) - setLightView(tv_light_top_01.isChecked,isChecked) + setLightTop2View(isChecked, true) + setLightView(tv_light_top_01.isChecked, isChecked) } tv_light_atmosphere.setOnCheckedChangeListener { buttonView, isChecked -> - if(!buttonView.isPressed){ + if (!buttonView.isPressed) { return@setOnCheckedChangeListener } tv_light_atmosphere.isEnabled = false @@ -366,48 +383,50 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba } SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di) viewModel?.setAtmosphereLightData2(isChecked) - setLightAtmosphereView(isChecked,true) + setLightAtmosphereView(isChecked, true) } } - override fun setLightTop1View(leftLight: Boolean, isFirst: Boolean){ + override fun setLightTop1View(leftLight: Boolean, isFirst: Boolean) { tv_light_top_01?.let { if (leftLight) { tv_light_top_01.text = context.getString(R.string.bus_p_m1_close_light1) tv_light_top_01.isChecked = true - if(!isFirst) ToastCharterUtils.showShort("打开顶灯1") + if (!isFirst) ToastCharterUtils.showShort("打开顶灯1") } else { tv_light_top_01.text = context.getString(R.string.bus_p_m1_open_light1) tv_light_top_01.isChecked = false - if(!isFirst) ToastCharterUtils.showShort("关闭顶灯1") + if (!isFirst) ToastCharterUtils.showShort("关闭顶灯1") } } } - override fun setLightTop2View(rightLight: Boolean, isFirst: Boolean){ + + override fun setLightTop2View(rightLight: Boolean, isFirst: Boolean) { tv_light_top_02?.let { if (rightLight) { tv_light_top_02.text = context.getString(R.string.bus_p_m1_close_light2) tv_light_top_02.isChecked = true - if(!isFirst) ToastCharterUtils.showShort("打开顶灯2") + if (!isFirst) ToastCharterUtils.showShort("打开顶灯2") } else { tv_light_top_02.text = context.getString(R.string.bus_p_m1_open_light2) tv_light_top_02.isChecked = false - if(!isFirst) ToastCharterUtils.showShort("关闭顶灯2") + if (!isFirst) ToastCharterUtils.showShort("关闭顶灯2") } } } - override fun setLightAtmosphereView(atmosphereLight: Boolean, isFirst: Boolean){ + + override fun setLightAtmosphereView(atmosphereLight: Boolean, isFirst: Boolean) { tv_light_atmosphere?.let { if (atmosphereLight) { tv_light_atmosphere.text = context.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("打开氛围灯") + if (!isFirst) ToastCharterUtils.showShort("打开氛围灯") } else { tv_light_atmosphere.text = context.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("关闭氛围灯") + if (!isFirst) ToastCharterUtils.showShort("关闭氛围灯") } } } @@ -506,7 +525,6 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba // endregion - private fun setAirConditionAni() { dbv_wind.post { dbv_wind?.let { @@ -514,7 +532,7 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba animator1 = ObjectAnimator.ofInt(it, "showHeight", 0, measuredHeight).apply { duration = 1000 repeatCount = ValueAnimator.INFINITE - if(rg_setting_windspeed.checkedRadioButtonId!=0&&tv_aircondition_switch.isChecked){ + if (rg_setting_windspeed.checkedRadioButtonId != 0 && tv_aircondition_switch.isChecked) { start() } } @@ -525,11 +543,11 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba private fun setAirconditionListener(viewModel: SoftControlViewModel?) { // 开关空调或暖风机 tv_aircondition_switch.setOnCheckedChangeListener { buttonView, isChecked -> - if(!buttonView.isPressed){ + if (!buttonView.isPressed) { return@setOnCheckedChangeListener } SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di) - if(isChecked){//打开 + if (isChecked) {//打开 tv_aircondition_switch.setText("关闭空调") if (rg_setting_pattern.checkedRadioButtonId == R.id.rb_pattern_heating) { openHeater()// 打开暖风机 @@ -537,7 +555,7 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba openAircondition()// 打开空调 } showAni() - }else{// 关闭 + } else {// 关闭 tv_aircondition_switch.setText("打开空调") closeHeater()// 关闭暖风机 closeAircondition()//关闭空调 @@ -548,38 +566,42 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba CallerLogger.d(SceneConstant.M_BUS_P + M1SoftFragment.TAG, "调节模式") when (checkedId) { R.id.rb_pattern_heating -> { - if(!rb_pattern_heating.isPressed){ + 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){ + + 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){ + + 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){ + + R.id.rb_pattern_ventilate -> { + if (!rb_pattern_ventilate.isPressed) { return@setOnCheckedChangeListener } SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di) openAircondition() } + else -> { openAircondition() } } - if(tv_aircondition_switch.isChecked) { + if (tv_aircondition_switch.isChecked) { showAni() } } @@ -587,21 +609,24 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba // 风速调节 rg_setting_windspeed.setOnCheckedChangeListener { group, checkedId -> when (checkedId) { - R.id.rb_wind_speed_low-> { - if(!rb_wind_speed_low.isPressed){ + 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){ + + 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){ + + R.id.rb_wind_speed_high -> { + if (!rb_wind_speed_high.isPressed) { return@setOnCheckedChangeListener } } + else -> {} } SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di) @@ -628,7 +653,8 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba rv_aircondition_temperature.layoutManager = pickerLayoutManager rv_aircondition_temperature.adapter = adapter HorizontalDecoration.distance = SharedPrefsMgr.getInstance(context).getInt( - HorizontalDecoration.distancekey,0) + HorizontalDecoration.distancekey, 0 + ) val space = AutoSizeUtils.dp2px(context, 15f) rv_aircondition_temperature.addItemDecoration( HorizontalDecoration( @@ -643,25 +669,25 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba val tag = view.tag if (tag is Temperature) { RxUtils.disposeSubscribe(subscribeAir) - if(tag.index==0||tag.index==adapter.data.size-1){ + if (tag.index == 0 || tag.index == adapter.data.size - 1) { subscribeAir = Observable.timer(200, TimeUnit.MILLISECONDS) .observeOn(AndroidSchedulers.mainThread()) .subscribe { - setCheckAir(adapter,tag) + setCheckAir(adapter, tag) } - }else { + } else { if (ClickUtils.isClickTooFrequent(rv_aircondition_temperature)) { return@setOnScrollStopListener } - setCheckAir(adapter,tag) + setCheckAir(adapter, tag) } } } } - if(HorizontalDecoration.distance!=0){ - rv_aircondition_temperature.scrollToPosition(data.size-1) - adapter.setCheckIndex(data.size-1) + if (HorizontalDecoration.distance != 0) { + rv_aircondition_temperature.scrollToPosition(data.size - 1) + adapter.setCheckIndex(data.size - 1) } } @@ -718,27 +744,39 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba rv_aircondition_temperature.tag = M1SoftFragment.touchTag UiThreadHandler.postDelayed({ rv_aircondition_temperature?.smoothScrollToPosition(it.index) - },500) + }, 500) } } } when (pattern) {//1: 自动模式, 2: 制冷模式, 3: 通风模式(仅送风,无温度) - 1 -> {rb_pattern_automatic.isChecked = true} - 2 -> {rb_pattern_refrigeration.isChecked = true} - 3 -> {rb_pattern_ventilate.isChecked = true} + 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) + 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) + 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) + setWind(rb_wind_speed_high, R.drawable.bus_pm1_aircondition_wind_high) } + else -> {} } } @@ -747,11 +785,13 @@ class SoftControlView : ConstraintLayout, SoftControlViewModel.SoftControlCallba heaterAirEnable(false) when (windSpeed) {//1: 1档,2: 2档 1 -> { - setWind(rb_wind_speed_middle,R.drawable.bus_pm1_warm_wind_middle) + 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) + setWind(rb_wind_speed_high, R.drawable.bus_pm1_warm_wind_high) } + else -> {} } } diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/SoftControlViewModel.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/SoftControlViewModel.kt index e1ed48616f..e7eea21b46 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/SoftControlViewModel.kt +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/SoftControlViewModel.kt @@ -14,18 +14,18 @@ import com.mogo.och.common.module.manager.devicemanage.data.LightStatus import com.mogo.och.common.module.utils.RxUtils import io.reactivex.disposables.Disposable -class SoftControlViewModel: ViewModel(), LightAirconditionDoorCallback { +class SoftControlViewModel : ViewModel(), LightAirconditionDoorCallback { private val TAG = SoftControlViewModel::class.java.simpleName - private var viewCallback:SoftControlCallback?=null + private var viewCallback: SoftControlCallback? = null - private var subscribeLightTop1: Disposable?=null - private var subscribeLightTop2: Disposable?=null - private var subscribeLightAtmosphere: Disposable?=null + private var subscribeLightTop1: Disposable? = null + private var subscribeLightTop2: Disposable? = null + private var subscribeLightAtmosphere: Disposable? = null - private var airconditionDisposable: Disposable?=null - private var heaterDisposable: Disposable?=null + private var airconditionDisposable: Disposable? = null + private var heaterDisposable: Disposable? = null init { @@ -38,7 +38,7 @@ class SoftControlViewModel: ViewModel(), LightAirconditionDoorCallback { LightAirconditionDoorStatusManager.removeListener(TAG) } - fun setViewCallback(viewCallback:SoftControlCallback){ + fun setViewCallback(viewCallback: SoftControlCallback) { this.viewCallback = viewCallback LightAirconditionDoorStatusManager.addListener(TAG, this) } @@ -46,14 +46,20 @@ class SoftControlViewModel: ViewModel(), LightAirconditionDoorCallback { /** * 空调状态变化 */ - override fun onAirconditionStatusCallback(heaterIsOpen: Boolean, airconditionStatus: AirconditionStatus, isFirst: Boolean) { - CallerLogger.d(M_BUS_P + TAG, + override fun onAirconditionStatusCallback( + heaterIsOpen: Boolean, + airconditionStatus: AirconditionStatus, + isFirst: Boolean + ) { + CallerLogger.d( + M_BUS_P + TAG, "回写--空调开关:${LightAirconditionDoorStatusManager.airconditionStatus.isOpen}、" + "空调温度:${LightAirconditionDoorStatusManager.airconditionStatus.temperature}" + "空调模式:${LightAirconditionDoorStatusManager.airconditionStatus.pattert}" + - "空调风速:${LightAirconditionDoorStatusManager.airconditionStatus.windSpeed}") + "空调风速:${LightAirconditionDoorStatusManager.airconditionStatus.windSpeed}" + ) UiThreadHandler.post { - if(airconditionStatus.isOpen){ + if (airconditionStatus.isOpen) { viewCallback?.setAirconditionHeaterView( airconditionStatus.isOpen, heaterIsOpen, @@ -61,7 +67,7 @@ class SoftControlViewModel: ViewModel(), LightAirconditionDoorCallback { airconditionStatus.pattert, airconditionStatus.windSpeed ) - }else{ + } else { viewCallback?.setAirconditionHeaterView( airconditionStatus.isOpen, heaterIsOpen, @@ -72,15 +78,22 @@ class SoftControlViewModel: ViewModel(), LightAirconditionDoorCallback { } } } + /** * 暖风机状态变化 */ - override fun onHeaterStatusCallback(airconditionIsOpen:Boolean, heaterStatue: HeaterStatue, isFirst: Boolean) { - CallerLogger.d(M_BUS_P + TAG, + override fun onHeaterStatusCallback( + airconditionIsOpen: Boolean, + heaterStatue: HeaterStatue, + isFirst: Boolean + ) { + CallerLogger.d( + M_BUS_P + TAG, "回写--暖风机开关:${heaterStatue.isOpen}、" + - "风速:${heaterStatue.windSpeed}") + "风速:${heaterStatue.windSpeed}" + ) UiThreadHandler.post { - if(heaterStatue.isOpen) { + if (heaterStatue.isOpen) { viewCallback?.setAirconditionHeaterView( airconditionIsOpen, heaterStatue.isOpen, @@ -88,7 +101,7 @@ class SoftControlViewModel: ViewModel(), LightAirconditionDoorCallback { 0, heaterStatue.windSpeed ) - }else{ + } else { viewCallback?.setAirconditionHeaterView( airconditionIsOpen, heaterStatue.isOpen, @@ -99,41 +112,50 @@ class SoftControlViewModel: ViewModel(), LightAirconditionDoorCallback { } } } + /** * 灯状态变化 */ override fun onLightTop1Callback(lightStatus: LightStatus, isFirst: Boolean) { - CallerLogger.d(M_BUS_P + TAG, + CallerLogger.d( + M_BUS_P + TAG, "回写--顶灯1开关:${lightStatus.isOpenLight1}、" + "顶灯2开关:${lightStatus.isOpenLight2}、" + - "氛围灯开关:${lightStatus.isOpenatmosphere}、") + "氛围灯开关:${lightStatus.isOpenatmosphere}、" + ) UiThreadHandler.post { - viewCallback?.setLightTop1View(lightStatus.isOpenLight1,isFirst) + viewCallback?.setLightTop1View(lightStatus.isOpenLight1, isFirst) } } + /** * 灯状态变化 */ override fun onLightTop2Callback(lightStatus: LightStatus, isFirst: Boolean) { - CallerLogger.d(M_BUS_P + TAG, + CallerLogger.d( + M_BUS_P + TAG, "回写--顶灯1开关:${lightStatus.isOpenLight1}、" + "顶灯2开关:${lightStatus.isOpenLight2}、" + - "氛围灯开关:${lightStatus.isOpenatmosphere}、") + "氛围灯开关:${lightStatus.isOpenatmosphere}、" + ) UiThreadHandler.post { - viewCallback?.setLightTop2View(lightStatus.isOpenLight2,isFirst) - viewCallback?.setLightView(lightStatus.isOpenLight1,lightStatus.isOpenLight2) + viewCallback?.setLightTop2View(lightStatus.isOpenLight2, isFirst) + viewCallback?.setLightView(lightStatus.isOpenLight1, lightStatus.isOpenLight2) } } + /** * 灯状态变化 */ override fun onLightAtmosphereCallback(lightStatus: LightStatus, isFirst: Boolean) { - CallerLogger.d(M_BUS_P + TAG, + CallerLogger.d( + M_BUS_P + TAG, "回写--顶灯1开关:${lightStatus.isOpenLight1}、" + "顶灯2开关:${lightStatus.isOpenLight2}、" + - "氛围灯开关:${lightStatus.isOpenatmosphere}、") + "氛围灯开关:${lightStatus.isOpenatmosphere}、" + ) UiThreadHandler.post { - viewCallback?.setLightAtmosphereView(lightStatus.isOpenatmosphere,isFirst) + viewCallback?.setLightAtmosphereView(lightStatus.isOpenatmosphere, isFirst) } } @@ -141,106 +163,124 @@ class SoftControlViewModel: ViewModel(), LightAirconditionDoorCallback { * 设置空调 */ fun openAndSetAircondition(modeCmd: Int, windSpeedCmd: Int, temperatureCmd: Int) { - CallerLogger.d(M_BUS_P + TAG, "" + - "打开空调,模式$modeCmd--档位${windSpeedCmd}--温度:$temperatureCmd") - CallerAutoPilotControlManager.sendRoboBusJinlvM1AirConditionerCmd(1,modeCmd,windSpeedCmd,temperatureCmd) + CallerLogger.d( + M_BUS_P + TAG, "" + + "打开空调,模式$modeCmd--档位${windSpeedCmd}--温度:$temperatureCmd" + ) + CallerAutoPilotControlManager.sendRoboBusJinlvM1AirConditionerCmd( + 1, + modeCmd, + windSpeedCmd, + temperatureCmd + ) RxUtils.disposeSubscribe(airconditionDisposable) - airconditionDisposable = RxUtils.createSubscribe(10000){ - if (!LightAirconditionDoorStatusManager.airconditionStatus.isOpen&& - LightAirconditionDoorStatusManager.airconditionStatus.windSpeed!=windSpeedCmd&& - LightAirconditionDoorStatusManager.airconditionStatus.temperature!=temperatureCmd&& - LightAirconditionDoorStatusManager.airconditionStatus.pattert!=modeCmd) { + airconditionDisposable = RxUtils.createSubscribe(10000) { + if (!LightAirconditionDoorStatusManager.airconditionStatus.isOpen && + LightAirconditionDoorStatusManager.airconditionStatus.windSpeed != windSpeedCmd && + LightAirconditionDoorStatusManager.airconditionStatus.temperature != temperatureCmd && + LightAirconditionDoorStatusManager.airconditionStatus.pattert != modeCmd + ) { ToastCharterUtils.showShort("控制系统繁忙,请稍后再试") } } } + fun closeAircondition(modeCmd: Int, windSpeedCmd: Int, temperatureCmd: Int) { CallerLogger.d(M_BUS_P + TAG, "关闭空调") - CallerAutoPilotControlManager.sendRoboBusJinlvM1AirConditionerCmd(2,modeCmd,windSpeedCmd,temperatureCmd) + CallerAutoPilotControlManager.sendRoboBusJinlvM1AirConditionerCmd( + 2, + modeCmd, + windSpeedCmd, + temperatureCmd + ) RxUtils.disposeSubscribe(airconditionDisposable) - airconditionDisposable = RxUtils.createSubscribe(10000){ + airconditionDisposable = RxUtils.createSubscribe(10000) { if (LightAirconditionDoorStatusManager.airconditionStatus.isOpen) { ToastCharterUtils.showShort("控制系统繁忙,请稍后再试") } } } + /** * 设置暖风 */ fun openAndSetHeader(windSpeedCmd: Int) { CallerLogger.d(M_BUS_P + TAG, "打开暖风机、档位${windSpeedCmd}") - CallerAutoPilotControlManager.sendRoboBusJinlvM1HeaderCmd(1,windSpeedCmd) + CallerAutoPilotControlManager.sendRoboBusJinlvM1HeaderCmd(1, windSpeedCmd) RxUtils.disposeSubscribe(heaterDisposable) - heaterDisposable = RxUtils.createSubscribe(10000){ - if (!LightAirconditionDoorStatusManager.heaterStatue.isOpen&& - LightAirconditionDoorStatusManager.heaterStatue.windSpeed!=windSpeedCmd) { + heaterDisposable = RxUtils.createSubscribe(10000) { + if (!LightAirconditionDoorStatusManager.heaterStatue.isOpen && + LightAirconditionDoorStatusManager.heaterStatue.windSpeed != windSpeedCmd + ) { ToastCharterUtils.showShort("暖风机操作未生效,请稍后重试吧~") } } } - fun closeHeader(){ + fun closeHeader() { CallerLogger.d(M_BUS_P + TAG, "关闭暖风机") - CallerAutoPilotControlManager.sendRoboBusJinlvM1HeaderCmd(2,0) + CallerAutoPilotControlManager.sendRoboBusJinlvM1HeaderCmd(2, 0) RxUtils.disposeSubscribe(heaterDisposable) - heaterDisposable = RxUtils.createSubscribe(10000){ + heaterDisposable = RxUtils.createSubscribe(10000) { if (LightAirconditionDoorStatusManager.heaterStatue.isOpen) { ToastCharterUtils.showShort("暖风机操作未生效,请稍后重试吧~")//还是开着的 } } } - fun setLightData1(leftLight: Boolean){ + fun setLightData1(leftLight: Boolean) { CallerLogger.d(M_BUS_P + TAG, "顶灯2:$leftLight") RxUtils.disposeSubscribe(subscribeLightTop1) - subscribeLightTop1 = if(leftLight){ + subscribeLightTop1 = if (leftLight) { CallerAutoPilotControlManager.sendRoboBusJinlvM1MainLamp1Cmd(1) - RxUtils.createSubscribe{ + RxUtils.createSubscribe { if (!LightAirconditionDoorStatusManager.lightStatus.isOpenLight1) { ToastCharterUtils.showShort("控制系统繁忙,请稍后再试") } } - }else{ + } else { CallerAutoPilotControlManager.sendRoboBusJinlvM1MainLamp1Cmd(2) - RxUtils.createSubscribe{ + RxUtils.createSubscribe { if (LightAirconditionDoorStatusManager.lightStatus.isOpenLight1) { ToastCharterUtils.showShort("控制系统繁忙,请稍后再试") } } } } - fun setLightData2(rightLight: Boolean){ + + fun setLightData2(rightLight: Boolean) { CallerLogger.d(M_BUS_P + TAG, "顶灯1:$rightLight") RxUtils.disposeSubscribe(subscribeLightTop2) - subscribeLightTop2 = if(rightLight){ + subscribeLightTop2 = if (rightLight) { CallerAutoPilotControlManager.sendRoboBusJinlvM1MainLamp2Cmd(1) - RxUtils.createSubscribe{ + RxUtils.createSubscribe { if (!LightAirconditionDoorStatusManager.lightStatus.isOpenLight2) { ToastCharterUtils.showShort("控制系统繁忙,请稍后再试") } } - }else{ + } else { CallerAutoPilotControlManager.sendRoboBusJinlvM1MainLamp2Cmd(2) - RxUtils.createSubscribe{ + RxUtils.createSubscribe { if (LightAirconditionDoorStatusManager.lightStatus.isOpenLight2) { ToastCharterUtils.showShort("控制系统繁忙,请稍后再试") } } } } - fun setAtmosphereLightData2(atmosphereLight: Boolean){ + + fun setAtmosphereLightData2(atmosphereLight: Boolean) { CallerLogger.d(M_BUS_P + TAG, "氛围灯:$atmosphereLight") RxUtils.disposeSubscribe(subscribeLightAtmosphere) subscribeLightAtmosphere = if (atmosphereLight) { CallerAutoPilotControlManager.sendRoboBusJinlvM1SmallLampCmd(1) - RxUtils.createSubscribe{ + RxUtils.createSubscribe { if (!LightAirconditionDoorStatusManager.lightStatus.isOpenatmosphere) { ToastCharterUtils.showShort("控制系统繁忙,请稍后再试") } } } else { CallerAutoPilotControlManager.sendRoboBusJinlvM1SmallLampCmd(2) - RxUtils.createSubscribe{ + RxUtils.createSubscribe { if (LightAirconditionDoorStatusManager.lightStatus.isOpenatmosphere) { ToastCharterUtils.showShort("控制系统繁忙,请稍后再试") } @@ -249,8 +289,7 @@ class SoftControlViewModel: ViewModel(), LightAirconditionDoorCallback { } - - interface SoftControlCallback{ + interface SoftControlCallback { /** * 根据车的状态会写页面状态 */ @@ -261,6 +300,7 @@ class SoftControlViewModel: ViewModel(), LightAirconditionDoorCallback { pattern: Int, windSpeed: Int ) + fun setLightTop1View(leftLight: Boolean, isFirst: Boolean) fun setLightTop2View(rightLight: Boolean, isFirst: Boolean) fun setLightView(leftLight: Boolean, rightLight: Boolean) diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/layoutmanage/CarouselLayoutManager.java b/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/layoutmanage/CarouselLayoutManager.java index 341a00cc13..a3b734dddd 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/layoutmanage/CarouselLayoutManager.java +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/layoutmanage/CarouselLayoutManager.java @@ -288,7 +288,7 @@ public class CarouselLayoutManager extends RecyclerView.LayoutManager implements *
* This method may do relayout work. * - * @param diff 要滚动的距离 + * @param diff 要滚动的距离 * @param recycler 回收期 * @param state Transient state of RecyclerView * @return distance that we actually scrolled by @@ -449,8 +449,8 @@ public class CarouselLayoutManager extends RecyclerView.LayoutManager implements private void detectOnItemSelectionChanged(final float currentScrollPosition, final RecyclerView.State state) { final float absCurrentScrollPosition = makeScrollPositionInRange0ToCount(currentScrollPosition, state.getItemCount()); final int centerItem = Math.round(absCurrentScrollPosition); - if(currentScrollPosition-centerItem!=0){ - new Handler(Looper.getMainLooper()).post(() -> dragDxDiff(currentScrollPosition,mCenterItemPosition)); + if (currentScrollPosition - centerItem != 0) { + new Handler(Looper.getMainLooper()).post(() -> dragDxDiff(currentScrollPosition, mCenterItemPosition)); } if (mCenterItemPosition != centerItem) { mCenterItemPosition = centerItem; @@ -468,9 +468,10 @@ public class CarouselLayoutManager extends RecyclerView.LayoutManager implements onCenterItemSelectionListener.onCenterItemChanged(centerItem); } } - private void dragDxDiff(final float centerItem,final int currentPosition) { + + private void dragDxDiff(final float centerItem, final int currentPosition) { for (final OnDargAutoDiffListener onDargAutoDiffListener : onDargAutoDiffListeners) { - onDargAutoDiffListener.onDxChanged(centerItem,currentPosition); + onDargAutoDiffListener.onDxChanged(centerItem, currentPosition); } } @@ -522,7 +523,7 @@ public class CarouselLayoutManager extends RecyclerView.LayoutManager implements view.setScaleY(transformation.mScaleY); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { view.setTransitionAlpha(transformation.mAlpha); - }else { + } else { view.setAlpha(transformation.mAlpha); } } @@ -804,7 +805,7 @@ public class CarouselLayoutManager extends RecyclerView.LayoutManager implements } public interface OnDargAutoDiffListener { - void onDxChanged(final float adapterPosition,final int currentPosition); + void onDxChanged(final float adapterPosition, final int currentPosition); } /** diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/view/DrawBitmapView.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/view/DrawBitmapView.kt index be17245bc4..a369c95154 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/view/DrawBitmapView.kt +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/softcontrol/view/DrawBitmapView.kt @@ -10,14 +10,14 @@ import android.view.View import com.mogo.och.bus.passenger.R -class DrawBitmapView @JvmOverloads constructor( +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 drawBitmapViewResource = R.drawable.bus_pm1_aircondition_wind_high private var mBitWidth = 0 private var showHeight = 0 set(value) { @@ -27,13 +27,16 @@ class DrawBitmapView @JvmOverloads constructor( 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) + drawBitmapViewResource = typedArray.getResourceId( + R.styleable.MainWindStatus_main_wind_drawable, + R.drawable.bus_pm1_aircondition_wind_high + ) typedArray.recycle() initBitmap() initPaint() } - fun setDrawableImage(bitmap: Bitmap){ + fun setDrawableImage(bitmap: Bitmap) { mBitmap = bitmap } @@ -51,7 +54,7 @@ class DrawBitmapView @JvmOverloads constructor( override fun onDraw(canvas: Canvas) { super.onDraw(canvas) canvas.clipRect(0, 0, mBitWidth, showHeight) - canvas.drawBitmap(mBitmap, (width-mBitmap.width)/2f, 0f, mBitPaint) + canvas.drawBitmap(mBitmap, (width - mBitmap.width) / 2f, 0f, mBitPaint) } } \ No newline at end of file diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/video/VideoView.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/video/VideoView.kt new file mode 100644 index 0000000000..098bb93864 --- /dev/null +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/bus/passenger/ui/video/VideoView.kt @@ -0,0 +1,167 @@ +package com.mogo.och.bus.passenger.ui.video + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.View +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.recyclerview.widget.RecyclerView +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.utilcode.kotlin.onClick +import com.mogo.och.bus.passenger.R +import com.mogo.och.bus.passenger.bean.TaxiPassengerVideoPlay +import com.mogo.och.bus.passenger.callback.IClearViewCallback +import com.mogo.och.bus.passenger.ui.softcontrol.layoutmanage.CarouselLayoutManager +import com.mogo.och.bus.passenger.ui.softcontrol.layoutmanage.CarouselZoomPostLayoutListener +import com.mogo.och.bus.passenger.ui.softcontrol.layoutmanage.CenterScrollListener +import com.mogo.och.bus.passenger.ui.video.adapter.RecyclerVideoAdapter +import com.shuyu.gsyvideoplayer.video.base.GSYVideoView +import kotlinx.android.synthetic.main.m1_video_fragment.view.rvVideoPlaylist +import kotlin.math.floor + +class VideoView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoAutopilotStatusListener { + + companion object { + const val TAG = "DebugView" + } + + private val arrayListOf = ArrayList() + + var goneViewListener: IClearViewCallback? = null + + init { + LayoutInflater.from(context).inflate(R.layout.m1_video_fragment, this, true) + onClick { + goneViewListener?.goneAllView() + } + initConsultData() + val carouselLayoutManager = CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL, true) + carouselLayoutManager.setPostLayoutListener(CarouselZoomPostLayoutListener()) + carouselLayoutManager.maxVisibleItems = 1 + rvVideoPlaylist.addOnScrollListener(object : CenterScrollListener() { + var prePlayerPosition = 0 + override fun pageSelect(recyclerView: RecyclerView?, newState: Int) { + //播放视频 + val (centerItemPosition, player) = getPlayer(carouselLayoutManager) + if (player is ConsultVideoPlayer) { + if (prePlayerPosition != centerItemPosition) { + if (player.currentState == GSYVideoView.CURRENT_STATE_PAUSE) { + player.onVideoReset() + } + val playerHolder = + carouselLayoutManager.findViewByPosition(prePlayerPosition) + val prePlayer = + playerHolder?.findViewById(R.id.video_item_player) + prePlayer?.onVideoReset() + } else { + player.onVideoResume(false) + } + } + prePlayerPosition = centerItemPosition + } + + override fun pageStop() { + val (_, player) = getPlayer(carouselLayoutManager) + if (player is ConsultVideoPlayer) { + player.onVideoPause() + } + } + + }) + carouselLayoutManager.addOnDargAutoDiffListener { adapterPosition, currentPosition -> + val fl = adapterPosition - floor(adapterPosition) + var currentIndex = currentPosition + if (fl > 0.5) { + if (currentPosition == 0) { + currentIndex = rvVideoPlaylist?.adapter!!.itemCount - 1 + } else { + currentIndex -= 1 + } + } + } + val recyclerVideoAdapter = RecyclerVideoAdapter(context, arrayListOf, rvVideoPlaylist) + recyclerVideoAdapter.setOnThumbImageClilckListener { + val (_, player) = getPlayer(carouselLayoutManager) + if (player is ConsultVideoPlayer) { + player.onVideoReset() + player.thumbImageViewLayout.visibility = View.VISIBLE + } + rvVideoPlaylist?.smoothScrollToPosition(it) + } + rvVideoPlaylist?.layoutManager = carouselLayoutManager + rvVideoPlaylist?.setHasFixedSize(true) + rvVideoPlaylist?.adapter = recyclerVideoAdapter + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + + } + + private fun getPlayer(carouselLayoutManager: CarouselLayoutManager): Pair { + val centerItemPosition: Int = carouselLayoutManager.centerItemPosition + val playerHolder = carouselLayoutManager.findViewByPosition(centerItemPosition) + val player = playerHolder?.findViewById(R.id.video_item_player) + return Pair(centerItemPosition, player) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + } + + override fun onVisibilityChanged(changedView: View, visibility: Int) { + super.onVisibilityChanged(changedView, visibility) + if (changedView != this) { + return + } + val carouselLayoutManager = rvVideoPlaylist?.layoutManager as CarouselLayoutManager + val (_, player) = getPlayer(carouselLayoutManager) + when (visibility) { + View.VISIBLE -> {} + else -> { + player?.let { + if (!player.isIfCurrentIsFullscreen) { + player.onVideoReset() + } + } + } + } + } + + private fun initConsultData() { + arrayListOf.clear() + arrayListOf.add( + TaxiPassengerVideoPlay( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v", + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png", + "蘑菇车联覆盖生活的方方面面" + ) + ) + arrayListOf.add( + TaxiPassengerVideoPlay( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v", + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png", + "蘑菇车联之红旗车队" + ) + ) + arrayListOf.add( + TaxiPassengerVideoPlay( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v", + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png", + "蘑菇车联牵手成都大运会" + ) + ) + arrayListOf.add( + TaxiPassengerVideoPlay( + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v", + "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png", + "多视角体验蘑菇车联自动驾驶" + ) + ) + } + +} \ No newline at end of file diff --git a/OCH/charter/passenger/src/main/res/layout/m1_main_fragment.xml b/OCH/charter/passenger/src/main/res/layout/m1_main_fragment.xml index 436d519d53..666a85b6b4 100644 --- a/OCH/charter/passenger/src/main/res/layout/m1_main_fragment.xml +++ b/OCH/charter/passenger/src/main/res/layout/m1_main_fragment.xml @@ -1,8 +1,8 @@ + android:layout_height="match_parent"> + app:resetDrawableMarginRight="34dp" + app:startPointDrawable="@null" + app:topPadding="100" /> + app:layout_constraintEnd_toEndOf="parent" /> - - - - - - - - - - - - + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toBottomOf="@+id/viewBusPM1MsgBoxButton" /> @@ -143,14 +98,61 @@ android:layout_marginEnd="@dimen/dp_34" android:visibility="visible" app:layout_constraintEnd_toEndOf="@+id/viewBusPM1MsgBoxButton" - app:layout_constraintTop_toBottomOf="@+id/viewBusPM1MsgBoxButton"/> + app:layout_constraintTop_toBottomOf="@+id/viewBusPM1MsgBoxButton" /> + + + + + + + + + + + + + + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/dp_47" + android:visibility="gone" + app:layout_constraintEnd_toEndOf="@+id/mapBizView" + app:layout_constraintTop_toTopOf="parent" /> \ No newline at end of file diff --git a/OCH/charter/passenger/src/main/res/layout/m1_soft_fragment.xml b/OCH/charter/passenger/src/main/res/layout/m1_soft_fragment.xml index 6cee245295..66d7eea319 100644 --- a/OCH/charter/passenger/src/main/res/layout/m1_soft_fragment.xml +++ b/OCH/charter/passenger/src/main/res/layout/m1_soft_fragment.xml @@ -2,6 +2,7 @@ @@ -9,6 +10,7 @@ android:layout_width="0dp" android:layout_height="0dp" android:clickable="true" + android:layout_marginBottom="@dimen/dp_141_5" android:background="@drawable/bus_p_function_setting_soft_b_shape" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintDimensionRatio="3:1" diff --git a/OCH/charter/passenger/src/main/res/layout/m1_video_fragment.xml b/OCH/charter/passenger/src/main/res/layout/m1_video_fragment.xml index 3dd1e32646..9ae5b83786 100644 --- a/OCH/charter/passenger/src/main/res/layout/m1_video_fragment.xml +++ b/OCH/charter/passenger/src/main/res/layout/m1_video_fragment.xml @@ -2,6 +2,7 @@ 139dp 140dp 141dp + 141.5dp 142dp 143dp 144dp