diff --git a/OCH/mogo-och-taxi-passenger/src/main/aidl/com/mogo/och/taxi/passenger/mulprocess/ILeftMenuService.aidl b/OCH/mogo-och-taxi-passenger/src/main/aidl/com/mogo/och/taxi/passenger/mulprocess/ILeftMenuService.aidl index 0e0aa676e9..ab9159d363 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/aidl/com/mogo/och/taxi/passenger/mulprocess/ILeftMenuService.aidl +++ b/OCH/mogo-och-taxi-passenger/src/main/aidl/com/mogo/och/taxi/passenger/mulprocess/ILeftMenuService.aidl @@ -8,7 +8,7 @@ import com.mogo.och.taxi.passenger.mulprocess.ICallback; interface ILeftMenuService { /** - * 向主进程传选中的item + * Pass the selected item to the main process */ void transmissionIndex(int index); diff --git a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/model/TaxiPassengerModel.java b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/model/TaxiPassengerModel.java index aa06fd8dae..37c153bc23 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/model/TaxiPassengerModel.java +++ b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/model/TaxiPassengerModel.java @@ -24,6 +24,7 @@ import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; import com.mogo.eagle.core.data.config.FunctionBuildConfig; import com.mogo.eagle.core.data.map.MogoLocation; +import com.mogo.eagle.core.data.msgbox.MsgBoxBean; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener; @@ -611,6 +612,26 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback }; private final IMsgBoxEventListener iMsgBoxEventListener = new IMsgBoxEventListener() { + @Override + public void onBubbleReportClickEvent(@NonNull MsgBoxBean msgBoxBean) { + + } + + @Override + public void onBubbleV2XClickEvent(@NonNull MsgBoxBean msgBoxBean) { + + } + + @Override + public void onBubbleOperationClickEvent(@NonNull MsgBoxBean msgBoxBean) { + + } + + @Override + public void onUpdateTipEvent(boolean isShow) { + + } + @Override public void onSummaryClickEvent() { if (mCurrentOCHOrder == null){ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt index b30ccde589..66e286e578 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt @@ -73,6 +73,8 @@ import com.mogo.eagle.core.function.hmi.ui.bindingcar.ToBindingCarDialog import com.mogo.eagle.core.function.hmi.ui.bindingcar.UpgradeAppDialog import com.mogo.eagle.core.function.hmi.ui.camera.CameraListView import com.mogo.eagle.core.function.hmi.ui.camera.RoadVideoDialog +import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxButtonView +import com.mogo.eagle.core.function.hmi.ui.msgbox.PassengerMsgBoxButtonView import com.mogo.eagle.core.function.hmi.ui.notice.NoticeCheckDialog import com.mogo.eagle.core.function.hmi.ui.notice.NoticeTrafficDialog import com.mogo.eagle.core.function.hmi.ui.setting.DebugSettingView @@ -253,41 +255,45 @@ class MoGoHmiFragment : MvpFragment(), } } } - - cbMsgBoxDriver.setOnCheckedChangeListener { _, isChecked -> - if(isChecked){ - viewDriverMsgBoxList.visibility = View.VISIBLE - viewDriverMsgBoxList.notifyData() - viewDriverMsgBoxBubble.visibility = View.GONE - viewDriverMsgBoxBubble.isShowData(false) - CallerHmiManager.updateDriverMsgBoxTipView(false) - }else{ - viewDriverMsgBoxList.visibility = View.GONE - viewDriverMsgBoxBubble.visibility = View.VISIBLE - viewDriverMsgBoxBubble.isShowData(true) + //消息盒子 + viewDriverMsgBoxButton.setClickListener(object: DriverMsgBoxButtonView.ClickListener{ + override fun showMsgBoxList(show: Boolean) { + if(show){ + viewDriverMsgBoxList.visibility = View.VISIBLE + viewDriverMsgBoxList.notifyData() + viewDriverMsgBoxBubble.visibility = View.GONE + viewDriverMsgBoxBubble.isShowData(false) + }else{ + viewDriverMsgBoxList.visibility = View.GONE + viewDriverMsgBoxBubble.visibility = View.VISIBLE + viewDriverMsgBoxBubble.isShowData(true) + } } - } - cbMsgBoxPassenger.setOnCheckedChangeListener { _, isChecked -> - if(isChecked){ - viewPassengerMsgBoxList.visibility = View.VISIBLE - viewPassengerMsgBoxBubble.visibility = View.GONE - viewPassengerMsgBoxBubble.isShowData(false) - CallerHmiManager.updatePassengerMsgBoxTipView(false) - }else{ - viewPassengerMsgBoxList.visibility = View.GONE - viewPassengerMsgBoxBubble.visibility = View.VISIBLE - viewPassengerMsgBoxBubble.isShowData(true) + }) + + viewPassengerMsgBoxButton.setClickListener(object: PassengerMsgBoxButtonView.ClickListener{ + override fun showMsgBoxList(show: Boolean) { + if(show){ + viewPassengerMsgBoxList.visibility = View.VISIBLE + viewPassengerMsgBoxBubble.visibility = View.GONE + viewPassengerMsgBoxBubble.isShowData(false) + }else{ + viewPassengerMsgBoxList.visibility = View.GONE + viewPassengerMsgBoxBubble.visibility = View.VISIBLE + viewPassengerMsgBoxBubble.isShowData(true) + } } - } + + }) if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){ - cbMsgBoxDriver.visibility = View.VISIBLE + viewDriverMsgBoxButton.visibility = View.VISIBLE viewDriverMsgBoxBubble.visibility = View.VISIBLE } if(AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)){ - cbMsgBoxPassenger.visibility = View.VISIBLE + viewPassengerMsgBoxButton.visibility = View.VISIBLE viewPassengerMsgBoxBubble.visibility = View.VISIBLE } } @@ -469,22 +475,6 @@ class MoGoHmiFragment : MvpFragment(), statusBarView?.updateMfStatus(tag, status) } - override fun updateDriverMsgBoxTipView(show: Boolean) { - if(show){ - MsgBoxTipView?.visibility = View.VISIBLE - }else{ - MsgBoxTipView?.visibility = View.GONE - } - } - - override fun updatePassengerMsgBoxTipView(show: Boolean) { - if(show){ - MsgBoxPTipView?.visibility = View.VISIBLE - }else{ - MsgBoxPTipView?.visibility = View.GONE - } - } - /** * 设置 红绿灯 代理View */ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxBubbleView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxBubbleView.kt index fb8fabb4a4..e30cd5c3fa 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxBubbleView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxBubbleView.kt @@ -13,6 +13,7 @@ import com.mogo.eagle.core.data.msgbox.MsgCategory import com.mogo.eagle.core.function.api.msgbox.IMsgBoxListener import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager import com.mogo.eagle.core.function.call.hmi.CallerHmiManager +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxEventListenerManager import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxListenerManager import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.function.hmi.ui.msgbox.adapter.DriverMsgBoxBubbleAdapter @@ -83,7 +84,7 @@ class DriverMsgBoxBubbleView @JvmOverloads constructor( } } if(isShowData){ - CallerHmiManager.updateDriverMsgBoxTipView(true) + CallerMsgBoxEventListenerManager.invokeUpdateTipListener(true) if(category == MsgCategory.RECORD_BAG){ //弹出被动录包弹窗 CallerDevaToolsManager.onReceiveBadCaseRecord(msgBoxBean,context as Activity,true) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxButtonView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxButtonView.kt new file mode 100644 index 0000000000..3d1bf00d43 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxButtonView.kt @@ -0,0 +1,96 @@ +package com.mogo.eagle.core.function.hmi.ui.msgbox + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.View +import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.msgbox.MsgBoxBean +import com.mogo.eagle.core.function.api.msgbox.IMsgBoxEventListener +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxEventListenerManager +import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import kotlinx.android.synthetic.main.view_driver_msg_box_button.view.* + +/** + * @author XuXinChao + * @description 消息盒子司机端视图切换按钮 + * @since: 2023/1/31 + */ +class DriverMsgBoxButtonView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +):ConstraintLayout(context, attrs, defStyleAttr), IMsgBoxEventListener { + + companion object { + const val TAG = "DriverMsgBoxButtonView" + } + + private var clickListener: ClickListener? = null + + init{ + LayoutInflater.from(context).inflate(R.layout.view_driver_msg_box_button, this, true) + initView() + } + + private fun initView(){ + cbMsgBoxDriver.setOnCheckedChangeListener { _, isChecked -> + clickListener?.showMsgBoxList(isChecked) + msgBoxTipView.visibility = View.GONE + } + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){ + CallerMsgBoxEventListenerManager.addListener(TAG,this) + } + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){ + CallerMsgBoxEventListenerManager.removeListener(TAG) + } + } + + override fun onSummaryClickEvent() { + + } + + /** + * 更新新消息提醒红点 + * @param isShow true:展示;false:不展示 + */ + override fun onUpdateTipEvent(isShow: Boolean) { + if(isShow){ + msgBoxTipView.visibility = View.VISIBLE + }else{ + msgBoxTipView.visibility = View.GONE + } + } + + override fun onBubbleOperationClickEvent(msgBoxBean: MsgBoxBean) { + cbMsgBoxDriver.performClick() + } + + override fun onBubbleV2XClickEvent(msgBoxBean: MsgBoxBean) { + cbMsgBoxDriver.performClick() + } + + override fun onBubbleReportClickEvent(msgBoxBean: MsgBoxBean) { + cbMsgBoxDriver.performClick() + } + + fun setClickListener(clickListener: ClickListener) { + this.clickListener = clickListener + } + + interface ClickListener{ + fun showMsgBoxList(show: Boolean) + } + + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxListView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxListView.kt index 547b6c8719..76c87a28ab 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxListView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/DriverMsgBoxListView.kt @@ -10,7 +10,9 @@ import androidx.recyclerview.widget.LinearLayoutManager import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.msgbox.MsgBoxBean import com.mogo.eagle.core.data.msgbox.MsgCategory +import com.mogo.eagle.core.function.api.msgbox.IMsgBoxEventListener import com.mogo.eagle.core.function.api.msgbox.IMsgBoxListener +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxEventListenerManager import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxListenerManager import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager import com.mogo.eagle.core.function.hmi.R @@ -32,7 +34,7 @@ class DriverMsgBoxListView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : ConstraintLayout(context, attrs, defStyleAttr) , IMsgBoxListener { +) : ConstraintLayout(context, attrs, defStyleAttr) , IMsgBoxListener, IMsgBoxEventListener { init { LayoutInflater.from(context).inflate(R.layout.layout_driver_msg_box_list, this, true) @@ -43,11 +45,13 @@ class DriverMsgBoxListView @JvmOverloads constructor( private var ipcReportList: ArrayList ?= null private var badCaseList: ArrayList ?= null private var driverMsgBoxListAdapter: DriverMsgBoxListAdapter ?=null + private var linearLayoutManager: LinearLayoutManager ?= null private fun initView() { driverMsgBoxListAdapter= DriverMsgBoxListAdapter(context as Activity) rvMsgBoxList.adapter = driverMsgBoxListAdapter - rvMsgBoxList.layoutManager = LinearLayoutManager(context) + linearLayoutManager = LinearLayoutManager(context) + rvMsgBoxList.layoutManager = linearLayoutManager //获取通知消息列表 noticeList= CallerMsgBoxManager.getCachedNotifyData() as ArrayList? @@ -195,6 +199,7 @@ class DriverMsgBoxListView @JvmOverloads constructor( super.onAttachedToWindow() if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){ CallerMsgBoxListenerManager.addListener(TAG,this) + CallerMsgBoxEventListenerManager.addListener(TAG,this) EventBus.getDefault().register(this) } } @@ -203,6 +208,7 @@ class DriverMsgBoxListView @JvmOverloads constructor( super.onDetachedFromWindow() if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){ CallerMsgBoxListenerManager.removeListener(TAG) + CallerMsgBoxEventListenerManager.removeListener(TAG) EventBus.getDefault().unregister(this) } } @@ -214,4 +220,36 @@ class DriverMsgBoxListView @JvmOverloads constructor( it.remove(msgBoxList) } } + + override fun onSummaryClickEvent() { + + } + + override fun onUpdateTipEvent(isShow: Boolean) { + + } + + override fun onBubbleOperationClickEvent(msgBoxBean: MsgBoxBean) { + MsgBoxConfig.setUserRecord(0) + notifyData() + noticeList?.let { + rvMsgBoxList?.scrollToPosition(it.indexOf(msgBoxBean)) + } + } + + override fun onBubbleV2XClickEvent(msgBoxBean: MsgBoxBean) { + MsgBoxConfig.setUserRecord(0) + notifyData() + noticeList?.let { + rvMsgBoxList?.scrollToPosition(it.indexOf(msgBoxBean)) + } + } + + override fun onBubbleReportClickEvent(msgBoxBean: MsgBoxBean) { + MsgBoxConfig.setUserRecord(1) + notifyData() + ipcReportList?.let { + linearLayoutManager?.scrollToPositionWithOffset(it.indexOf(msgBoxBean),0) + } + } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/PassengerMsgBoxBubbleView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/PassengerMsgBoxBubbleView.kt index edd8a0688b..feda00428a 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/PassengerMsgBoxBubbleView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/PassengerMsgBoxBubbleView.kt @@ -12,6 +12,7 @@ import com.mogo.eagle.core.data.msgbox.MsgBoxType import com.mogo.eagle.core.data.msgbox.MsgCategory import com.mogo.eagle.core.function.api.msgbox.IMsgBoxListener import com.mogo.eagle.core.function.call.hmi.CallerHmiManager +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxEventListenerManager import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxListenerManager import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.function.hmi.ui.msgbox.adapter.PassengerMsgBoxBubbleAdapter @@ -64,7 +65,7 @@ class PassengerMsgBoxBubbleView @JvmOverloads constructor( || msgBoxList.type == MsgBoxType.OBU){ MsgBoxConfig.noticeList.add(msgBoxList) if(isShowData){ - CallerHmiManager.updatePassengerMsgBoxTipView(true) + CallerMsgBoxEventListenerManager.invokeUpdateTipListener(true) dataList.add(msgBoxList) passengerMsgBoxBubbleAdapter?.setData(dataList) } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/PassengerMsgBoxButtonView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/PassengerMsgBoxButtonView.kt new file mode 100644 index 0000000000..8026b86070 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/PassengerMsgBoxButtonView.kt @@ -0,0 +1,97 @@ +package com.mogo.eagle.core.function.hmi.ui.msgbox + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.View +import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.msgbox.MsgBoxBean +import com.mogo.eagle.core.function.api.msgbox.IMsgBoxEventListener +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxEventListenerManager +import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import kotlinx.android.synthetic.main.view_passenger_msg_box_button.view.* + +/** + * @author XuXinChao + * @description 消息盒子乘客端视图切换按钮 + * @since: 2023/1/31 + */ +class PassengerMsgBoxButtonView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +): ConstraintLayout(context, attrs, defStyleAttr), IMsgBoxEventListener { + + companion object { + const val TAG = "PassengerMsgBoxButtonView" + } + + private var clickListener: ClickListener? = null + + init{ + LayoutInflater.from(context).inflate(R.layout.view_passenger_msg_box_button, this, true) + initView() + } + + private fun initView(){ + cbMsgBoxPassenger.setOnCheckedChangeListener { _, isChecked -> + clickListener?.showMsgBoxList(isChecked) + msgBoxPTipView.visibility = View.GONE + } + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + if(AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode) && + AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)){ + CallerMsgBoxEventListenerManager.addListener(TAG,this) + } + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + if(AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode) && + AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)){ + CallerMsgBoxEventListenerManager.removeListener(TAG) + } + } + + override fun onSummaryClickEvent() { + + } + + /** + * 更新新消息提醒红点 + * @param isShow true:展示;false:不展示 + */ + override fun onUpdateTipEvent(isShow: Boolean) { + if(isShow){ + msgBoxPTipView.visibility = View.VISIBLE + }else{ + msgBoxPTipView.visibility = View.GONE + } + } + + override fun onBubbleOperationClickEvent(msgBoxBean: MsgBoxBean) { + cbMsgBoxPassenger.performClick() + } + + override fun onBubbleV2XClickEvent(msgBoxBean: MsgBoxBean) { + cbMsgBoxPassenger.performClick() + } + + override fun onBubbleReportClickEvent(msgBoxBean: MsgBoxBean) { + cbMsgBoxPassenger.performClick() + } + + fun setClickListener(clickListener: ClickListener) { + this.clickListener = clickListener + } + + interface ClickListener{ + fun showMsgBoxList(show: Boolean) + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/PassengerMsgBoxListView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/PassengerMsgBoxListView.kt index f0720f387c..1c5bdd33d7 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/PassengerMsgBoxListView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/PassengerMsgBoxListView.kt @@ -11,7 +11,9 @@ import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.msgbox.MsgBoxBean import com.mogo.eagle.core.data.msgbox.MsgBoxType import com.mogo.eagle.core.data.msgbox.MsgCategory +import com.mogo.eagle.core.function.api.msgbox.IMsgBoxEventListener import com.mogo.eagle.core.function.api.msgbox.IMsgBoxListener +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxEventListenerManager import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxListenerManager import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager import com.mogo.eagle.core.function.hmi.R @@ -30,7 +32,7 @@ class PassengerMsgBoxListView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : ConstraintLayout(context, attrs, defStyleAttr), IMsgBoxListener { +) : ConstraintLayout(context, attrs, defStyleAttr), IMsgBoxListener, IMsgBoxEventListener { private val TAG = "PassengerMsgBoxListView" var passengerMsgBoxListAdapter: PassengerMsgBoxListAdapter ?= null @@ -78,6 +80,7 @@ class PassengerMsgBoxListView @JvmOverloads constructor( if(AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)){ CallerMsgBoxListenerManager.addListener(TAG,this) + CallerMsgBoxEventListenerManager.addListener(TAG,this) } } @@ -86,7 +89,30 @@ class PassengerMsgBoxListView @JvmOverloads constructor( if(AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)){ CallerMsgBoxListenerManager.removeListener(TAG) + CallerMsgBoxEventListenerManager.removeListener(TAG) } } + override fun onSummaryClickEvent() { + + } + + override fun onUpdateTipEvent(isShow: Boolean) { + + } + + override fun onBubbleOperationClickEvent(msgBoxBean: MsgBoxBean) { + + } + + override fun onBubbleV2XClickEvent(msgBoxBean: MsgBoxBean) { + noticeList?.let { + rvPassengerList.scrollToPosition(it.indexOf(msgBoxBean)) + } + } + + override fun onBubbleReportClickEvent(msgBoxBean: MsgBoxBean) { + + } + } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxBubbleAdapter.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxBubbleAdapter.kt index 1f656db107..de4a40a628 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxBubbleAdapter.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxBubbleAdapter.kt @@ -13,12 +13,14 @@ import com.mogo.eagle.core.data.msgbox.* import com.mogo.eagle.core.data.report.ReportEntity import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager import com.mogo.eagle.core.function.call.hmi.CallerHmiManager +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxEventListenerManager import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp import com.mogo.eagle.core.utilcode.mogo.glide.transform.GlideRoundedCornersTransform import com.mogo.eagle.core.utilcode.util.TimeUtils import com.mogo.eagle.core.utilcode.util.TimeUtils.getHourMinFormat +import com.mogo.eagle.core.widget.RoundCanClickConstraintLayout /** * @author XuXinChao @@ -75,14 +77,19 @@ class DriverMsgBoxBubbleAdapter(private val activity: Activity) : RecyclerView.A when (holder) { is BubbleOperationHolder -> { data?.let { - val operationMsg = it[position].bean as OperationMsg + val msgBoxBean = it[position] + val operationMsg = msgBoxBean.bean as OperationMsg holder.tvBubbleOperationTime.text = TimeUtils.millis2String(it[position].timestamp,getHourMinFormat()) holder.tvBubbleOperationContent.text = operationMsg.content + holder.clBubbleOperationLayout.setOnClickListener { + CallerMsgBoxEventListenerManager.invokeBubbleOperationListener(msgBoxBean) + } } } is BubbleReportHolder -> { data?.let { - val reportEntity = it[position].bean as ReportEntity + val msgBoxBean = it[position] + val reportEntity = msgBoxBean.bean as ReportEntity holder.tvBubbleReportTime.text = "时间:${TimeUtils.millis2String(it[position].timestamp)}" holder.tvBubbleReceiveTime.text = TimeUtils.millis2String(it[position].timestamp,getHourMinFormat()) var resultStr = "类型:" @@ -90,6 +97,9 @@ class DriverMsgBoxBubbleAdapter(private val activity: Activity) : RecyclerView.A resultStr = "${resultStr}${CallerAutoPilotManager.getReportResultDesc(result)}" } holder.tvBubbleReportType.text = resultStr + holder.clReportLayout.setOnClickListener { + CallerMsgBoxEventListenerManager.invokeBubbleReportListener(msgBoxBean) + } } } is BubbleNoticeHolder -> { @@ -139,6 +149,9 @@ class DriverMsgBoxBubbleAdapter(private val activity: Activity) : RecyclerView.A holder.tvV2XContent.text = v2XMsg.content holder.ivV2XImage.setImageDrawable(activity.resources.getDrawable( EventTypeEnumNew.getUpdateIconRes(v2XMsg.type))) + holder.clV2XLayout.setOnClickListener { + CallerMsgBoxEventListenerManager.invokeBubbleV2XListener(msgBoxBean) + } } } is BubbleSummaryHolder -> { @@ -190,12 +203,14 @@ class DriverMsgBoxBubbleAdapter(private val activity: Activity) : RecyclerView.A var tvBubbleReportTime: TextView = itemView.findViewById(R.id.tvBubbleReportTime) var tvBubbleReportType: TextView = itemView.findViewById(R.id.tvBubbleReportType) var tvBubbleReceiveTime: TextView = itemView.findViewById(R.id.tvBubbleReceiveTime) + var clReportLayout: RoundCanClickConstraintLayout = itemView.findViewById(R.id.clReportLayout) } //运营平台 class BubbleOperationHolder(itemView: View): RecyclerView.ViewHolder(itemView){ var tvBubbleOperationTime: TextView = itemView.findViewById(R.id.tvBubbleOperationTime) var tvBubbleOperationContent: TextView = itemView.findViewById(R.id.tvBubbleOperationContent) + var clBubbleOperationLayout: RoundCanClickConstraintLayout = itemView.findViewById(R.id.clBubbleOperationLayout) } //Notice @@ -212,6 +227,7 @@ class DriverMsgBoxBubbleAdapter(private val activity: Activity) : RecyclerView.A var ivV2XImage: ImageView = itemView.findViewById(R.id.ivV2XImage) var tvV2XTime: TextView = itemView.findViewById(R.id.tvV2XTime) var tvV2XContent: TextView = itemView.findViewById(R.id.tvV2XContent) + var clV2XLayout: RoundCanClickConstraintLayout = itemView.findViewById(R.id.clV2XLayout) } //汇总消息 diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/PassengerMsgBoxBubbleAdapter.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/PassengerMsgBoxBubbleAdapter.kt index db78cd9935..2edcd6acc1 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/PassengerMsgBoxBubbleAdapter.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/PassengerMsgBoxBubbleAdapter.kt @@ -18,6 +18,7 @@ import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.utilcode.mogo.glide.transform.GlideRoundedCornersTransform import com.mogo.eagle.core.utilcode.util.TimeUtils import com.mogo.eagle.core.utilcode.util.TimeUtils.getHourMinFormat +import com.mogo.eagle.core.widget.RoundCanClickConstraintLayout /** * @author XuXinChao @@ -104,6 +105,9 @@ class PassengerMsgBoxBubbleAdapter(private val activity: Activity): RecyclerView holder.tvPassengerV2XContent.text = v2XMsg.content holder.ivPassengerV2XImage.setImageDrawable(activity.resources.getDrawable( EventTypeEnumNew.getUpdateIconRes(v2XMsg.type))) + holder.clPassengerVeXLayout.setOnClickListener { + CallerMsgBoxEventListenerManager.invokeBubbleV2XListener(msgBoxBean) + } } } is BubbleSummaryHolder -> { @@ -114,7 +118,7 @@ class PassengerMsgBoxBubbleAdapter(private val activity: Activity): RecyclerView holder.tvPassengerSummaryCheck.setOnClickListener { //跳转全览模式 // CallerHmiManager.showSmallFragment() - CallerMsgBoxEventListenerManager.invokeListener() + CallerMsgBoxEventListenerManager.invokeSummaryListener() } } } @@ -163,6 +167,7 @@ class PassengerMsgBoxBubbleAdapter(private val activity: Activity): RecyclerView var ivPassengerV2XImage: ImageView = itemView.findViewById(R.id.ivPassengerV2XImage) var tvPassengerV2XTime: TextView = itemView.findViewById(R.id.tvPassengerV2XTime) var tvPassengerV2XContent: TextView = itemView.findViewById(R.id.tvPassengerV2XContent) + var clPassengerVeXLayout: RoundCanClickConstraintLayout = itemView.findViewById(R.id.clPassengerVeXLayout) } //汇总消息 diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/PassengerMsgBoxListAdapter.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/PassengerMsgBoxListAdapter.kt index 8bb23e0ed6..c183783d1d 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/PassengerMsgBoxListAdapter.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/PassengerMsgBoxListAdapter.kt @@ -106,7 +106,7 @@ class PassengerMsgBoxListAdapter(private val activity: Activity): RecyclerView.A holder.tvPassengerSummaryCheck.setOnClickListener { //跳转全览模式 // CallerHmiManager.showSmallFragment() - CallerMsgBoxEventListenerManager.invokeListener() + CallerMsgBoxEventListenerManager.invokeSummaryListener() } } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml index 21d86a2dc9..67a6cfcdd7 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml @@ -198,57 +198,26 @@ app:layout_constraintTop_toBottomOf="@+id/viewLimitingVelocity" /> - - - - - - - @@ -256,7 +225,7 @@ android:id="@+id/viewDriverMsgBoxList" android:layout_width="864dp" android:layout_height="746dp" - app:layout_constraintTop_toBottomOf="@id/cbMsgBoxDriver" + app:layout_constraintTop_toBottomOf="@id/viewDriverMsgBoxButton" app:layout_constraintRight_toRightOf="parent" android:layout_marginEnd="40dp" android:visibility="gone" @@ -266,7 +235,7 @@ android:id="@+id/viewDriverMsgBoxBubble" android:layout_width="864dp" android:layout_height="wrap_content" - app:layout_constraintTop_toBottomOf="@id/cbMsgBoxDriver" + app:layout_constraintTop_toBottomOf="@id/viewDriverMsgBoxButton" app:layout_constraintRight_toRightOf="parent" android:layout_marginEnd="40dp" android:visibility="gone" @@ -276,9 +245,9 @@ android:id="@+id/viewPassengerMsgBoxBubble" android:layout_width="650dp" android:layout_height="wrap_content" - app:layout_constraintBottom_toTopOf="@id/cbMsgBoxPassenger" - app:layout_constraintLeft_toLeftOf="@id/cbMsgBoxPassenger" - app:layout_constraintRight_toRightOf="@id/cbMsgBoxPassenger" + app:layout_constraintBottom_toTopOf="@id/viewPassengerMsgBoxButton" + app:layout_constraintLeft_toLeftOf="@id/viewPassengerMsgBoxButton" + app:layout_constraintRight_toRightOf="@id/viewPassengerMsgBoxButton" android:layout_marginBottom="20dp" android:visibility="gone" /> @@ -287,9 +256,9 @@ android:id="@+id/viewPassengerMsgBoxList" android:layout_width="650dp" android:layout_height="750dp" - app:layout_constraintBottom_toTopOf="@id/cbMsgBoxPassenger" - app:layout_constraintLeft_toLeftOf="@id/cbMsgBoxPassenger" - app:layout_constraintRight_toRightOf="@id/cbMsgBoxPassenger" + app:layout_constraintBottom_toTopOf="@id/viewPassengerMsgBoxButton" + app:layout_constraintLeft_toLeftOf="@id/viewPassengerMsgBoxButton" + app:layout_constraintRight_toRightOf="@id/viewPassengerMsgBoxButton" android:layout_marginBottom="20dp" android:visibility="gone" /> diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_operation.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_operation.xml index af25aec755..f488699d48 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_operation.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_operation.xml @@ -1,5 +1,6 @@ - + android:layout_marginBottom="7dp" + > - \ No newline at end of file + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_report.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_report.xml index ac287b1ca2..7bc6c8e3a8 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_report.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_report.xml @@ -1,5 +1,6 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_v2x.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_v2x.xml index 8c1cb8475d..9888e42f87 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_v2x.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_v2x.xml @@ -1,5 +1,6 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_passenger_msg_box_v2x.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_passenger_msg_box_v2x.xml index d7096b95b6..fbe95e1a36 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_passenger_msg_box_v2x.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_passenger_msg_box_v2x.xml @@ -1,5 +1,6 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_driver_msg_box_button.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_driver_msg_box_button.xml new file mode 100644 index 0000000000..4d6aeebadb --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_driver_msg_box_button.xml @@ -0,0 +1,34 @@ + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_passenger_msg_box_button.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_passenger_msg_box_button.xml new file mode 100644 index 0000000000..8b2935a3f6 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_passenger_msg_box_button.xml @@ -0,0 +1,31 @@ + + + + + + + + + + \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt index 6927c467f3..eb8e799ed2 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt @@ -302,16 +302,6 @@ interface IMoGoWaringProvider : IMoGoHmiViewProxy { */ fun updateStatusBarLeftView(insert: Boolean, tag: String, viewGroup: ViewGroup) - /** - * 设置司机端消息盒子是否展示 - */ - fun updateDriverMsgBoxTipView(show: Boolean) - - /** - * 设置乘客端消息盒子是否展示 - */ - fun updatePassengerMsgBoxTipView(show: Boolean) - /** * 更新(添加/删除)下载进度 */ diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/msgbox/IMsgBoxEventListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/msgbox/IMsgBoxEventListener.kt index cebfca9d9b..8cd6469ae6 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/msgbox/IMsgBoxEventListener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/msgbox/IMsgBoxEventListener.kt @@ -1,9 +1,25 @@ package com.mogo.eagle.core.function.api.msgbox + +import com.mogo.eagle.core.data.msgbox.MsgBoxBean + /** * @author XuXinChao * @date 2023/1/16 * 消息盒子事件监听回调 */ interface IMsgBoxEventListener { + //汇总事件点击监听 fun onSummaryClickEvent() + + //更新提示红点视图 + fun onUpdateTipEvent(isShow: Boolean) + + //气泡态运营平台事件点击监听 + fun onBubbleOperationClickEvent(msgBoxBean: MsgBoxBean) + + //气泡态V2X消息事件点击监听 + fun onBubbleV2XClickEvent(msgBoxBean: MsgBoxBean) + + //气泡态上报消息事件点击监听 + fun onBubbleReportClickEvent(msgBoxBean: MsgBoxBean) } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt index e256ba1691..1c8aa2182e 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt @@ -484,20 +484,6 @@ object CallerHmiManager : CallerBase() { waringProviderApi?.updateStatusBarLeftView(insert, tag, viewGroup) } - /** - * 设置司机端消息盒子是否展示 - */ - fun updateDriverMsgBoxTipView(show: Boolean = false){ - waringProviderApi?.updateDriverMsgBoxTipView(show) - } - - /** - * 设置乘客端消息盒子是否展示 - */ - fun updatePassengerMsgBoxTipView(show: Boolean = false){ - waringProviderApi?.updatePassengerMsgBoxTipView(show) - } - /** * 更新(添加/删除)状态栏右侧元素 */ diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/msgbox/CallerMsgBoxEventListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/msgbox/CallerMsgBoxEventListenerManager.kt index 3696e0f471..3860afa41f 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/msgbox/CallerMsgBoxEventListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/msgbox/CallerMsgBoxEventListenerManager.kt @@ -1,6 +1,7 @@ package com.mogo.eagle.core.function.call.msgbox import androidx.annotation.Nullable +import com.mogo.eagle.core.data.msgbox.MsgBoxBean import com.mogo.eagle.core.function.api.msgbox.IMsgBoxEventListener import com.mogo.eagle.core.function.call.base.CallerBase import java.util.concurrent.ConcurrentHashMap @@ -56,9 +57,9 @@ object CallerMsgBoxEventListenerManager: CallerBase() { } /** - * 触发监听 + * 触发汇总报告点击事件监听 */ - fun invokeListener(){ + fun invokeSummaryListener(){ statusListeners.forEach { val tag = it.key val listener = it.value @@ -66,5 +67,49 @@ object CallerMsgBoxEventListenerManager: CallerBase() { } } + /** + * 更新消息提示View展示状态 + */ + fun invokeUpdateTipListener(isShow: Boolean){ + statusListeners.forEach { + val tag = it.key + val listener = it.value + listener.onUpdateTipEvent(isShow) + } + } + + /** + * 气泡态运营平台事件点击监听 + **/ + fun invokeBubbleOperationListener(msgBoxBean: MsgBoxBean){ + statusListeners.forEach{ + val tag = it.key + val listener = it.value + listener.onBubbleOperationClickEvent(msgBoxBean) + } + } + + /** + * 气泡态V2X消息事件点击监听 + */ + fun invokeBubbleV2XListener(msgBoxBean: MsgBoxBean){ + statusListeners.forEach{ + val tag = it.key + val listener = it.value + listener.onBubbleV2XClickEvent(msgBoxBean) + } + } + + /** + * 气泡态上报消息事件点击监听 + */ + fun invokeBubbleReportListener(msgBoxBean: MsgBoxBean){ + statusListeners.forEach{ + val tag = it.key + val listener = it.value + listener.onBubbleReportClickEvent(msgBoxBean) + } + } + } \ No newline at end of file diff --git a/core/mogo-core-res/src/main/java/com/mogo/eagle/core/widget/RoundCanClickConstraintLayout.java b/core/mogo-core-res/src/main/java/com/mogo/eagle/core/widget/RoundCanClickConstraintLayout.java new file mode 100644 index 0000000000..86f6939aa0 --- /dev/null +++ b/core/mogo-core-res/src/main/java/com/mogo/eagle/core/widget/RoundCanClickConstraintLayout.java @@ -0,0 +1,70 @@ +package com.mogo.eagle.core.widget; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.Path; +import android.graphics.RectF; +import android.util.AttributeSet; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.constraintlayout.widget.ConstraintLayout; + +public class RoundCanClickConstraintLayout extends ConstraintLayout { + + private float roundLayoutRadius = 14f; + private Path roundPath; + private RectF rectF; + + public RoundCanClickConstraintLayout(@NonNull Context context) { + super(context); + } + + public RoundCanClickConstraintLayout(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RoundLayout); + roundLayoutRadius = typedArray.getDimensionPixelSize(R.styleable.RoundLayout_roundLayoutRadius, (int) roundLayoutRadius); + typedArray.recycle(); + + init(); + } + + public RoundCanClickConstraintLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + private void init() { + setWillNotDraw(false);//如果你继承的是ViewGroup,注意此行,否则draw方法是不会回调的; + roundPath = new Path(); + rectF = new RectF(); + } + + private void setRoundPath() { + //添加一个圆角矩形到path中, 如果要实现任意形状的View, 只需要手动添加path就行 + roundPath.reset(); + roundPath.addRoundRect(rectF, roundLayoutRadius, roundLayoutRadius, Path.Direction.CW); + } + + public void setRoundLayoutRadius(float roundLayoutRadius) { + this.roundLayoutRadius = roundLayoutRadius; + setRoundPath(); + postInvalidate(); + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + rectF.set(0f, 0f, getMeasuredWidth(), getMeasuredHeight()); + setRoundPath(); + } + + @Override + public void draw(Canvas canvas) { + if (roundLayoutRadius > 0f) { + canvas.clipPath(roundPath); + } + super.draw(canvas); + } + +}