diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiProvider.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiProvider.kt index 1749466cfa..9d62c65bc9 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiProvider.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiProvider.kt @@ -494,13 +494,11 @@ class MoGoHmiProvider : IMoGoHmiProvider { if (target != null && target.visibility != View.VISIBLE) { TransitionManager.beginDelayedTransition(target.parent as ViewGroup, Slide(Gravity.START).also { it.duration = 150; it.addTarget(target) }) target.visibility = View.VISIBLE - CallerHmiViewControlListenerManager.invokeOperatePanelDisplayStatus(true) } } else { if (target != null && target.visibility == View.VISIBLE) { TransitionManager.beginDelayedTransition(target.parent as ViewGroup, Slide(Gravity.START).also { it.duration = 150; it.addTarget(target) }) target.visibility = View.GONE - CallerHmiViewControlListenerManager.invokeOperatePanelDisplayStatus(false) } } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt index 9b0fbbff56..3c7bccca8f 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt @@ -332,7 +332,10 @@ class OperatePanelLayout : LinearLayout { class V2XPreferenceFragmentCompat : OperatePanelDetailBase(), IV2XListener, IMoGoAutopilotStatusListener,IViewControlListener { - + private var v2xIsShow: Boolean = false + private var operatePaneIsShow = true + private var prevIpcConnectStatus = false + private var customToast: Toast? = null companion object { private const val TAG = "V2XPreferenceFragmentCompat" private const val NDE_UPWARD_SWITCH = "nde_upward_switch" //NDE(数据上车)上行 @@ -347,6 +350,8 @@ class OperatePanelLayout : LinearLayout { private const val V2I_WEAK_TRAFFIC_PARTICIPANT = "v2i_weak_traffic_participant" //弱势交通参与者 private const val V2I_PERCEPTION_DATA_TO_PNC = "v2i_perception_data_to_pnc" //感知数据进PNC应用 private const val V2V_DOWNWARD_SWITCH = "v2v_downward_switch" //V2V下行 + + private const val WHAT_UPDATE_ENABLE = 0x00//更新按钮状态 } override fun onCreateView(inflater: LayoutInflater, @@ -361,25 +366,31 @@ class OperatePanelLayout : LinearLayout { //车辆图像上传行云大模型状态查询 CallerAutoPilotControlManager.sendImgUploadCloudStatusQuery() } + prevIpcConnectStatus = AppConfigInfo.isConnectAutopilot CallerAutoPilotStatusListenerManager.addListener(TAG, this) CallerHmiViewControlListenerManager.addListener(TAG,this) return super.onCreateView(inflater, container, savedInstanceState) } override fun onDestroyView() { + super.onDestroyView() CallerV2XManager.removeListener(TAG) CallerAutoPilotStatusListenerManager.removeListener(TAG) - super.onDestroyView() + CallerHmiViewControlListenerManager.removeListener(TAG) + handler.removeCallbacksAndMessages(null) } override fun operatePanelDisplayStatus(isShow: Boolean) { super.operatePanelDisplayStatus(isShow) - if(isShow){ - CallerAutoPilotStatusListenerManager.addListener(TAG, this) - FunctionBuildConfig.v2xIsShow = true - }else{ - CallerAutoPilotStatusListenerManager.removeListener(TAG) - FunctionBuildConfig.v2xIsShow = false + operatePaneIsShow = isShow + if (isShow) { + if (v2xIsShow) { + handler.sendEmptyMessage(WHAT_UPDATE_ENABLE) + } + } else { + handler.removeMessages(WHAT_UPDATE_ENABLE) + customToast?.cancel() + customToast = null } } @@ -442,95 +453,70 @@ class OperatePanelLayout : LinearLayout { } override fun onResume() { - FunctionBuildConfig.v2xIsShow = true - if(AppConfigInfo.isConnectAutopilot){ - FunctionBuildConfig.currentStatus = true - handler.removeMessages(2) - handler.sendEmptyMessage(1) - }else{ - FunctionBuildConfig.currentStatus = false - handler.removeMessages(1) - handler.sendEmptyMessage(2) - } super.onResume() + prevIpcConnectStatus = AppConfigInfo.isConnectAutopilot + v2xIsShow = true + handler.sendEmptyMessage(WHAT_UPDATE_ENABLE) } + override fun onPause() { - FunctionBuildConfig.v2xIsShow = false - handler.removeMessages(1) - handler.removeMessages(2) super.onPause() + v2xIsShow = false + handler.removeMessages(WHAT_UPDATE_ENABLE) + customToast?.cancel() + customToast = null } - private val handler =object : Handler(Looper.getMainLooper()){ - override fun handleMessage(msg: Message){ + private val handler = object : Handler(Looper.getMainLooper()) { + override fun handleMessage(msg: Message) { super.handleMessage(msg) - //与域控连接正常 - if(msg.what == 1){ - Log.i(TAG,"与域控连接正常 handler操作1") - setEnableStatus(true) - FunctionBuildConfig.currentStatus = true - this.removeMessages(2) - } - //与域控断连 - else if(msg.what == 2){ - Log.i(TAG,"与域控断连 handler操作2 ="+FunctionBuildConfig.v2xIsShow) - if(FunctionBuildConfig.v2xIsShow){ - Log.i(TAG,"currentStatus = "+FunctionBuildConfig.currentStatus) - if(FunctionBuildConfig.currentStatus){ - return - } - Log.i(TAG,"执行断连UI操作") - setEnableStatus(false) + if (msg.what == WHAT_UPDATE_ENABLE) { + if (this.hasMessages(WHAT_UPDATE_ENABLE)) { + this.removeMessages(WHAT_UPDATE_ENABLE) + } + setEnableStatus(AppConfigInfo.isConnectAutopilot) + if (AppConfigInfo.isConnectAutopilot) { + customToast?.cancel() + customToast = null + } else { showConnectToast() - this.removeMessages(2) - this.sendEmptyMessageDelayed(2,5000) + this.sendEmptyMessageDelayed(WHAT_UPDATE_ENABLE, 5000) } } } } - private var lastToastTime: Long = 0L - private fun showConnectToast(){ - if(System.currentTimeMillis() - lastToastTime > 4500){ - try { - AppStateManager.currentActivity()?.let { - val customToastView = it.layoutInflater.inflate(R.layout.view_ipc_connect_status_toast,null) - val customToast = Toast(MainMoGoApplication.getApp().applicationContext) - customToast.duration = Toast.LENGTH_SHORT - customToast.view = customToastView - customToast.setGravity(Gravity.START,AutoSizeUtils.dp2px(MainMoGoApplication.getApp().applicationContext, 280f),0) - customToast.show() - } - }catch (_: Exception){} - lastToastTime = System.currentTimeMillis() + private fun showConnectToast() { + try { + AppStateManager.currentActivity()?.let { + val customToastView = + it.layoutInflater.inflate(R.layout.view_ipc_connect_status_toast, null) + customToast = Toast(MainMoGoApplication.getApp().applicationContext) + customToast!!.duration = Toast.LENGTH_SHORT + customToast!!.view = customToastView + customToast!!.setGravity( + Gravity.START, + AutoSizeUtils.dp2px(MainMoGoApplication.getApp().applicationContext, 280f), + 0 + ) + customToast!!.show() + } + } catch (_: Exception) { } } override fun onAutopilotIpcConnectStatusChanged( status: AdasConstants.IpcConnectionStatus, reason: String? - ){ - ThreadUtils.runOnUiThread{ - if(status == AdasConstants.IpcConnectionStatus.CONNECTED){ - //域控连接成功,恢复正常状态 - Log.i(TAG,"域控连接成功") -// handler.sendEmptyMessage(1) -// handler.removeMessages(2) -// if(!currentStatus){ -// currentStatus = true -// } - this.onResume() - }else{ - //断连中,持续提示:请等待与域控恢复连接后操作;并且将所有开关置为不可用状态 - Log.i(TAG,"请等待与域控恢复连接后操作"+FunctionBuildConfig.currentStatus) - FunctionBuildConfig.currentStatus = false - handler.removeMessages(1) - handler.sendEmptyMessage(2) - this.onResume() + ) { + if (prevIpcConnectStatus != AppConfigInfo.isConnectAutopilot) { + if (operatePaneIsShow && v2xIsShow) { + handler.sendEmptyMessage(WHAT_UPDATE_ENABLE) } } + prevIpcConnectStatus = AppConfigInfo.isConnectAutopilot } private fun setEnableStatus(isEnable: Boolean){ @@ -1964,4 +1950,9 @@ class OperatePanelLayout : LinearLayout { } isClickable = true } + + override fun onVisibilityChanged(changedView: View, visibility: Int) { + super.onVisibilityChanged(changedView, visibility) + CallerHmiViewControlListenerManager.invokeOperatePanelDisplayStatus(visibility == View.VISIBLE) + } } \ No newline at end of file diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/config/FunctionBuildConfig.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/config/FunctionBuildConfig.kt index 6fc91ea5ce..fa4cff15a6 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/config/FunctionBuildConfig.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/config/FunctionBuildConfig.kt @@ -531,11 +531,5 @@ object FunctionBuildConfig { @JvmField var isDriveSeatVideoStream: Boolean = false - @Volatile - @JvmField - var v2xIsShow: Boolean = false //运营面板V2X页面是否是显示状态 - @Volatile - @JvmField - var currentStatus: Boolean = false //当前工控机连接状态连接状态 } \ No newline at end of file