[6.7.0][工具箱] feat: 增驾工具箱item 默认数据;
feat: 增驾注册监听item 点击事件的方法供och 调用;
@@ -3,14 +3,20 @@ package com.mogo.eagle.core.function.hmi.bone.tab
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.findViewTreeViewModelStoreOwner
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.bone.toolkit.ToolKitBean
|
||||
import com.mogo.eagle.core.function.hmi.bone.toolkit.ToolKitDataManager
|
||||
import com.mogo.eagle.core.function.hmi.bone.toolkit.ToolKitDefaultItemView
|
||||
import com.mogo.eagle.core.function.hmi.bone.toolkit.ToolKitListAdapter
|
||||
import com.mogo.eagle.core.function.hmi.bone.toolkit.ToolKitViewModel
|
||||
import com.mogo.eagle.core.utilcode.mogo.view.GridSpacingItemDecoration
|
||||
import kotlinx.android.synthetic.main.view_tool_kit_tab.view.recyclerView
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
@@ -24,24 +30,15 @@ class ToolKitTabView @JvmOverloads constructor(
|
||||
private const val TAG = "ToolKitTabView"
|
||||
}
|
||||
|
||||
val toolKitList = ArrayList<ToolKitBean>()?.also {
|
||||
List(20) { index ->
|
||||
it += ToolKitBean(
|
||||
ToolKitDefaultItemView(context).apply {
|
||||
setData("标题标题标题标题标题$index", R.drawable.icon_toolkit_item_tiaoshi)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private var viewModel: ToolKitViewModel? = null
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_tool_kit_tab, this, true)
|
||||
initView()
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
initView()
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
@@ -51,8 +48,9 @@ class ToolKitTabView @JvmOverloads constructor(
|
||||
private fun initView() {
|
||||
// 设置布局管理器为GridLayoutManager,每行3列
|
||||
recyclerView.layoutManager = GridLayoutManager(context, 3)
|
||||
val adapter = ToolKitListAdapter(ToolKitDataManager.toolList)
|
||||
// 设置适配器
|
||||
recyclerView.adapter = ToolKitListAdapter(toolKitList)
|
||||
recyclerView.adapter = adapter
|
||||
recyclerView.addItemDecoration(
|
||||
GridSpacingItemDecoration(
|
||||
3,
|
||||
@@ -61,6 +59,12 @@ class ToolKitTabView @JvmOverloads constructor(
|
||||
false
|
||||
)
|
||||
)
|
||||
viewModel = findViewTreeViewModelStoreOwner()?.let {
|
||||
ViewModelProvider(it).get(ToolKitViewModel::class.java)
|
||||
}
|
||||
viewModel?.toolKitList?.observeForever { data ->
|
||||
adapter.items = data
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,4 +2,4 @@ package com.mogo.eagle.core.function.hmi.bone.toolkit
|
||||
|
||||
import android.view.View
|
||||
|
||||
data class ToolKitBean(val itemView: View)
|
||||
data class ToolKitBean(val toolTag: String, val itemView: View)
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.mogo.eagle.core.function.hmi.bone.toolkit
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.function.api.och.IToolKitItemClickListener
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
object ToolKitDataManager : IToolKitItemClickListener {
|
||||
const val TAG = "ToolKitDataManager"
|
||||
|
||||
|
||||
enum class ToolTypeEnum {
|
||||
DEBUG_PANEL, //调试面板
|
||||
OPERATION_PANEL, //运营面板
|
||||
TAKE_OVER_HISTORY, //接管记录
|
||||
KILL_APP, //杀死 APP
|
||||
RESTART_SYSTEM, //重启系统
|
||||
STOP_SERVICE //停止服务
|
||||
}
|
||||
|
||||
private val listeners by lazy { ConcurrentHashMap<String, IToolKitItemClickListener>() }
|
||||
|
||||
val toolList = ArrayList<ToolKitBean>()
|
||||
|
||||
fun addListener(tag: String, listener: IToolKitItemClickListener) {
|
||||
if (listeners.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
listeners[tag] = listener
|
||||
}
|
||||
|
||||
fun removeListener(tag: String) {
|
||||
listeners.remove(tag)
|
||||
}
|
||||
|
||||
fun invokeItemClick(toolTag: String) {
|
||||
listeners.values.forEach { itx ->
|
||||
itx.onItemClick(toolTag)
|
||||
}
|
||||
}
|
||||
|
||||
fun init(ctx: Context) {
|
||||
if (!AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
return
|
||||
}
|
||||
// 添加默认的工具箱items
|
||||
toolList.also {
|
||||
it += ToolKitBean(
|
||||
ToolTypeEnum.DEBUG_PANEL.name,
|
||||
getDefaultItemView(ctx, "调试面板", R.drawable.icon_toolkit_item_debug_panel)
|
||||
)
|
||||
it += ToolKitBean(
|
||||
ToolTypeEnum.OPERATION_PANEL.name,
|
||||
getDefaultItemView(ctx, "运营面板", R.drawable.icon_toolkit_item_operation_panel)
|
||||
)
|
||||
it += ToolKitBean(
|
||||
ToolTypeEnum.TAKE_OVER_HISTORY.name,
|
||||
getDefaultItemView(ctx, "接管记录", R.drawable.icon_toolkit_item_take_over_history)
|
||||
)
|
||||
it += ToolKitBean(
|
||||
ToolTypeEnum.KILL_APP.name,
|
||||
getDefaultItemView(ctx, "杀死APP", R.drawable.icon_toolkit_item_kill_app)
|
||||
)
|
||||
it += ToolKitBean(
|
||||
ToolTypeEnum.RESTART_SYSTEM.name,
|
||||
getDefaultItemView(ctx, "重启系统", R.drawable.icon_toolkit_item_restart_system)
|
||||
)
|
||||
it += ToolKitBean(
|
||||
ToolTypeEnum.STOP_SERVICE.name,
|
||||
getDefaultItemView(ctx, "停止服务", R.drawable.icon_toolkit_item_stop_service)
|
||||
)
|
||||
}
|
||||
addListener(TAG, this)
|
||||
}
|
||||
|
||||
fun unInit() {
|
||||
if (!AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
return
|
||||
}
|
||||
removeListener(TAG)
|
||||
toolList.clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成默认风格的工具item view(上面icon, 下面名称)
|
||||
*/
|
||||
private fun getDefaultItemView(context: Context, toolName: String, drawableId: Int): View {
|
||||
return ToolKitDefaultItemView(context).apply {
|
||||
setData(toolName, drawableId)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onItemClick(toolTag: String) {
|
||||
ToastUtils.showShort(toolTag)
|
||||
when (toolTag) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import android.widget.FrameLayout
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
|
||||
class ToolKitListAdapter(private val items: List<ToolKitBean>) :
|
||||
class ToolKitListAdapter(var items: List<ToolKitBean>) :
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
class ToolKitListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
@@ -31,6 +31,9 @@ class ToolKitListAdapter(private val items: List<ToolKitBean>) :
|
||||
(it.parent as ViewGroup).removeView(it)
|
||||
}
|
||||
holder.containerView.addView(it)
|
||||
it.setOnClickListener {
|
||||
ToolKitDataManager.invokeItemClick(data.toolTag)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,8 +41,4 @@ class ToolKitListAdapter(private val items: List<ToolKitBean>) :
|
||||
}
|
||||
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
override fun onViewRecycled(holder: RecyclerView.ViewHolder) {
|
||||
super.onViewRecycled(holder)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mogo.eagle.core.function.hmi.bone.toolkit
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
|
||||
class ToolKitViewModel : ViewModel() {
|
||||
val toolKitList: MutableLiveData<ArrayList<ToolKitBean>> = MutableLiveData()
|
||||
|
||||
init {
|
||||
toolKitList.value = ToolKitDataManager.toolList
|
||||
}
|
||||
|
||||
fun updateToolKitData(newData: ArrayList<ToolKitBean>) {
|
||||
toolKitList.value = newData
|
||||
}
|
||||
}
|
||||
@@ -26,16 +26,18 @@ import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
import com.mogo.eagle.core.function.api.hmi.xiaozhi.event.Event
|
||||
import com.mogo.eagle.core.function.api.hmi.xiaozhi.listener.OnXiaoZhiStateChangeListener
|
||||
import com.mogo.eagle.core.function.api.hmi.xiaozhi.state.State
|
||||
import com.mogo.eagle.core.function.api.och.IToolKitItemClickListener
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiViewControlListenerManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerTurnLightListenerManager
|
||||
import com.mogo.eagle.core.function.hmi.bone.status.fsm.FSMStatusDetailWindowManager
|
||||
import com.mogo.eagle.core.function.hmi.bone.toolkit.ToolKitDataManager
|
||||
import com.mogo.eagle.core.function.hmi.ui.camera.RoadVideoDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.lookaround.M1LookAroundView
|
||||
import com.mogo.eagle.core.function.hmi.ui.notice.DispatchDialogManager
|
||||
import com.mogo.eagle.core.function.hmi.ui.notice.NoticeCheckDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.notice.traffic.NoticeTrafficDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.setting.CameraLiveView.Companion.cameraLiveView
|
||||
import com.mogo.eagle.core.function.hmi.bone.status.fsm.FSMStatusDetailWindowManager
|
||||
import com.mogo.eagle.core.function.hmi.ui.setting.StatusView
|
||||
import com.mogo.eagle.core.function.hmi.ui.setting.ToolsView.Companion.toolsView
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.AdUpgradeDialog
|
||||
@@ -430,4 +432,8 @@ class MoGoHmiProvider : IMoGoHmiProvider {
|
||||
override fun dismissGreenWave() {
|
||||
CallerHmiViewControlListenerManager.invokeGreenWaveDismiss()
|
||||
}
|
||||
|
||||
override fun registerToolKitDefaultItemClickListener(tag: String, listener: IToolKitItemClickListener) {
|
||||
ToolKitDataManager.addListener(TAG, listener)
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ import com.mogo.eagle.core.function.call.och.CallerOchCustomViewManager
|
||||
import com.mogo.eagle.core.function.call.setting.CallerRequestActivityHandleManager
|
||||
import com.mogo.eagle.core.function.call.startup.CallerStartUpManager.initStageTwo
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.bone.toolkit.ToolKitDataManager
|
||||
import com.mogo.eagle.core.function.main.modules.MogoModulesManager
|
||||
import com.mogo.eagle.core.function.main.windowview.FloatingViewHandler
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppLaunchTimeUtils
|
||||
@@ -82,6 +83,7 @@ open class MainActivity : MvpActivity<MainView?, MainPresenter?>(), MainView,
|
||||
initConnectInfoRV()
|
||||
CallerHmiManager.init(this)
|
||||
CallerOchCustomViewManager.init(this)
|
||||
ToolKitDataManager.init(this)
|
||||
|
||||
// 检查是否有悬浮窗权限
|
||||
if (Settings.canDrawOverlays(this)) {
|
||||
@@ -322,6 +324,7 @@ open class MainActivity : MvpActivity<MainView?, MainPresenter?>(), MainView,
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
ToolKitDataManager.unInit()
|
||||
val properties = java.util.HashMap<String, Any>()
|
||||
properties["app_destroy_time"] = System.currentTimeMillis()
|
||||
MogoAnalyticUtils.track("app_lifecycle_destroy", properties)
|
||||
|
||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 22 KiB |
@@ -32,9 +32,9 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginLeft="@dimen/dp_56"
|
||||
android:layout_marginRight="@dimen/dp_56"
|
||||
android:layout_marginBottom="@dimen/dp_200"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="@dimen/dp_62"
|
||||
android:paddingBottom="@dimen/dp_200"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.mogo.eagle.core.data.map.Infrastructure
|
||||
import com.mogo.eagle.core.function.api.hmi.xiaozhi.event.Event
|
||||
import com.mogo.eagle.core.function.api.hmi.xiaozhi.listener.OnXiaoZhiStateChangeListener
|
||||
import com.mogo.eagle.core.function.api.hmi.xiaozhi.state.State
|
||||
import com.mogo.eagle.core.function.api.och.IToolKitItemClickListener
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -240,4 +241,9 @@ interface IMoGoHmiProvider :IProvider{
|
||||
* 隐藏绿波通弹窗
|
||||
*/
|
||||
fun dismissGreenWave()
|
||||
|
||||
/**
|
||||
* 注册 工具箱 item点击事件监听 (默认样式item的点击事件监听,自定义样式的item的点击交给view自己处理)
|
||||
*/
|
||||
fun registerToolKitDefaultItemClickListener( tag: String, listener: IToolKitItemClickListener)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.eagle.core.function.api.och
|
||||
|
||||
/**
|
||||
* 定义给 Och 业务层调用的接口
|
||||
*/
|
||||
interface IOchFunctionCall {
|
||||
|
||||
/**
|
||||
* 注册 工具箱 item点击事件监听 (默认样式item的点击事件监听,自定义样式的item的点击交给view自己处理)
|
||||
*/
|
||||
fun registerToolKitDefaultItemClickListener(tag: String, listener: IToolKitItemClickListener) {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mogo.eagle.core.function.api.och
|
||||
|
||||
/**
|
||||
* 工具箱-item点击事件监听
|
||||
*/
|
||||
interface IToolKitItemClickListener {
|
||||
fun onItemClick(toolTag: String)
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
import com.mogo.eagle.core.function.api.hmi.xiaozhi.event.Event
|
||||
import com.mogo.eagle.core.function.api.hmi.xiaozhi.listener.OnXiaoZhiStateChangeListener
|
||||
import com.mogo.eagle.core.function.api.hmi.xiaozhi.state.State
|
||||
import com.mogo.eagle.core.function.api.och.IToolKitItemClickListener
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -352,4 +353,11 @@ object CallerHmiManager {
|
||||
fun dismissGreenWave() {
|
||||
hmiProviderApi?.dismissGreenWave()
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册 工具箱 item点击事件监听 (默认样式item的点击事件监听,自定义样式的item的点击交给view自己处理)
|
||||
*/
|
||||
fun registerToolKitDefaultItemClickListener(tag: String, listener: IToolKitItemClickListener) {
|
||||
hmiProviderApi?.registerToolKitDefaultItemClickListener(tag, listener)
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ object CallerOchCustomViewManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 自动自动驾驶 自定义 View
|
||||
* 创建 启动自动驾驶 自定义 View
|
||||
*/
|
||||
fun getStartAutopilotView(context: Context?): View? {
|
||||
return ochCustomViewProviderApi?.createStartAutopilotView(context)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mogo.eagle.core.function.call.och
|
||||
|
||||
import com.mogo.eagle.core.function.api.och.IOchFunctionCall
|
||||
import com.mogo.eagle.core.function.api.och.IToolKitItemClickListener
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
|
||||
/**
|
||||
* 实现给 Och 业务层调用的接口
|
||||
*/
|
||||
object CallerOchFunctionCallManager : IOchFunctionCall {
|
||||
const val TAG = "CallerOchFunctionCallManager"
|
||||
|
||||
/**
|
||||
* 注册 工具箱 item点击事件监听 (默认样式item的点击事件监听,自定义样式的item的点击交给view自己处理)
|
||||
*/
|
||||
override fun registerToolKitDefaultItemClickListener(
|
||||
tag: String,
|
||||
listener: IToolKitItemClickListener
|
||||
) {
|
||||
CallerHmiManager.registerToolKitDefaultItemClickListener(tag, listener)
|
||||
}
|
||||
|
||||
}
|
||||