[3.3.0][Feat]新增状态监控汇总功能
This commit is contained in:
@@ -41,6 +41,7 @@ class WarningFloat {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 浮窗的属性构建类,支持链式调用
|
||||
*/
|
||||
@@ -136,6 +137,10 @@ class WarningFloat {
|
||||
config.immersionStatusBar = immersionStatusBar
|
||||
}
|
||||
|
||||
fun slideDel(status: Boolean) = apply {
|
||||
this.config.defaultSlideDel = status
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置浮窗的出入动画
|
||||
* @param floatAnimator 浮窗的出入动画,为空时不执行动画
|
||||
@@ -194,7 +199,10 @@ class WarningFloat {
|
||||
content?.let {
|
||||
config.layoutId = null
|
||||
config.layoutView = it
|
||||
Reminder.enqueue(getLifecycleOwner(activity), WarningFloatReminder(activity, config, it))
|
||||
Reminder.enqueue(
|
||||
getLifecycleOwner(activity),
|
||||
WarningFloatReminder(activity, config, it)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
WarningFloatWindowManager.create(activity, config)
|
||||
@@ -214,7 +222,11 @@ class WarningFloat {
|
||||
}
|
||||
|
||||
|
||||
internal class WarningFloatReminder(private val activity: Context, private val config: WarningNotificationConfig, content: View): ViewReminder(content) {
|
||||
internal class WarningFloatReminder(
|
||||
private val activity: Context,
|
||||
private val config: WarningNotificationConfig,
|
||||
content: View
|
||||
) : ViewReminder(content) {
|
||||
|
||||
private var hasShow = false
|
||||
|
||||
@@ -235,7 +247,8 @@ class WarningFloat {
|
||||
}
|
||||
}
|
||||
|
||||
fun isShow(): Boolean = WarningFloatWindowManager.getHelper(config.floatTag)?.isShow() ?: false
|
||||
fun isShow(): Boolean =
|
||||
WarningFloatWindowManager.getHelper(config.floatTag)?.isShow() ?: false
|
||||
|
||||
fun resetExpireTime(expireTime: Long) {
|
||||
if (!isShow()) {
|
||||
|
||||
@@ -128,7 +128,9 @@ internal class WarningFloatWindowHelper(
|
||||
|
||||
// 设置触摸监听,直接关掉弹窗
|
||||
frameLayout?.setOnTouchListener { _, _ ->
|
||||
exitAnim()
|
||||
if(config.defaultSlideDel){
|
||||
exitAnim()
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,10 @@ data class WarningNotificationConfig(
|
||||
var width: Int = WindowManager.LayoutParams.WRAP_CONTENT,
|
||||
|
||||
// 窗口高度
|
||||
var height: Int = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
var height: Int = WindowManager.LayoutParams.WRAP_CONTENT,
|
||||
|
||||
// 默认滑动删除
|
||||
var defaultSlideDel :Boolean = true
|
||||
) {
|
||||
var isEnqueue: Boolean = false
|
||||
var isOverride: Boolean = true
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.mogo.eagle.core.data.enums.WarningDirectionEnum
|
||||
import com.mogo.eagle.core.data.map.Infrastructure
|
||||
import com.mogo.eagle.core.data.biz.notice.NoticeNormalData
|
||||
import com.mogo.eagle.core.data.biz.notice.NoticeTrafficStylePushData
|
||||
import com.mogo.eagle.core.data.status.StatusSummaryEntity
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoHmiProvider
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
import com.mogo.eagle.core.function.call.hmi.*
|
||||
@@ -33,6 +34,7 @@ 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.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
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.ModifyBindingCarDialog
|
||||
@@ -357,4 +359,7 @@ class MoGoHmiProvider : IMoGoHmiProvider {
|
||||
override fun is360LookAroundShowing(): Boolean {
|
||||
return lookAround.get()?.isShowing() ?: false
|
||||
}
|
||||
override fun showStatusSummaryDialog() {
|
||||
context?.let { StatusView.statusView.toggle(it) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.setting
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.eagle.core.data.status.StatusSummaryEntity
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
|
||||
class StatusSummaryAdapter(private val ctx: Context, var data: ArrayList<StatusSummaryEntity>): RecyclerView.Adapter<StatusSummaryAdapter.StatusViewHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = StatusViewHolder(
|
||||
LayoutInflater.from(ctx).inflate(R.layout.item_status_summary_layout, parent, false))
|
||||
|
||||
override fun getItemCount(): Int = data.size
|
||||
|
||||
override fun onBindViewHolder(holder: StatusViewHolder, position: Int) {
|
||||
holder.bind(data[position])
|
||||
}
|
||||
|
||||
class StatusViewHolder(item: View) : RecyclerView.ViewHolder(item) {
|
||||
private val ivFuncView: ImageView by lazy {
|
||||
itemView.findViewById(R.id.ivFuncView)
|
||||
}
|
||||
|
||||
private val tvStatusDesc: TextView by lazy {
|
||||
itemView.findViewById(R.id.tvStatusDesc)
|
||||
}
|
||||
|
||||
fun bind(entity: StatusSummaryEntity) {
|
||||
when(entity.type) {
|
||||
0 -> {
|
||||
ivFuncView.setImageResource(R.drawable.driver_server)
|
||||
}
|
||||
1 -> {
|
||||
ivFuncView.setImageResource(R.drawable.gps)
|
||||
}
|
||||
2 -> {
|
||||
ivFuncView.setImageResource(R.drawable.cloud_socket)
|
||||
}
|
||||
3 -> {
|
||||
ivFuncView.setImageResource(R.drawable.tracing)
|
||||
}
|
||||
}
|
||||
if (entity.isException) {
|
||||
tvStatusDesc.setTextColor(Color.parseColor("#FF4444"))
|
||||
} else {
|
||||
tvStatusDesc.setTextColor(Color.parseColor("#FFFFFF"))
|
||||
}
|
||||
tvStatusDesc.text = entity.desc
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.setting
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.FrameLayout
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.commons.module.status.IMogoStatusChangedListener
|
||||
import com.mogo.commons.module.status.MogoStatusManager
|
||||
import com.mogo.commons.module.status.StatusDescriptor
|
||||
import com.mogo.eagle.core.data.status.StatusSummaryEntity
|
||||
import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsListener
|
||||
import com.mogo.eagle.core.function.api.telematic.IConnectStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsListenerManager
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicStatusListenerManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.kotlin.PX
|
||||
import com.mogo.eagle.core.utilcode.rv.divider.CommonDividerItemDecoration
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
|
||||
/**
|
||||
* 状态汇总View控件
|
||||
*/
|
||||
class StatusSummaryView@JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : FrameLayout(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
), IConnectStatusListener, IMogoStatusChangedListener,
|
||||
IMoGoDevaToolsListener {
|
||||
companion object{
|
||||
private const val TAG = "SummaryStatusView"
|
||||
}
|
||||
|
||||
private var clickListener: ClickListener? = null
|
||||
private var rvStatusView: RecyclerView? = null
|
||||
private var adapter: StatusSummaryAdapter? = null
|
||||
private val data by lazy {
|
||||
ArrayList<StatusSummaryEntity>().also {
|
||||
it.add(StatusSummaryEntity(0))
|
||||
it.add(StatusSummaryEntity(1))
|
||||
it.add(StatusSummaryEntity(2))
|
||||
it.add(StatusSummaryEntity(3))
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_status_summary_layout, this, true)
|
||||
initView()
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
CallerDevaToolsListenerManager.addListener(TAG, this)
|
||||
// 司机屏Server服务是否开启的状态
|
||||
CallerTelematicStatusListenerManager.addListener(TAG, this)
|
||||
// 云socket连接状态
|
||||
MogoStatusManager.getInstance()
|
||||
.registerStatusChangedListener(TAG, StatusDescriptor.CLOUD_SOCKET, this)
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
rvStatusView = findViewById(R.id.rvStatusView)
|
||||
rvStatusView?.let {
|
||||
it.itemAnimator?.apply {
|
||||
changeDuration = 0
|
||||
addDuration = 0
|
||||
moveDuration = 0
|
||||
removeDuration = 0
|
||||
}
|
||||
it.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
|
||||
it.addItemDecoration(
|
||||
CommonDividerItemDecoration.Builder()
|
||||
.spanCountTBCare(false)
|
||||
.horizontalInnerSpace(10.PX)
|
||||
.build())
|
||||
StatusSummaryAdapter(context, data).apply {
|
||||
adapter = this
|
||||
it.adapter = this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setClickListener(clickListener: ClickListener) {
|
||||
this.clickListener = clickListener
|
||||
}
|
||||
|
||||
interface ClickListener {
|
||||
fun showWindow(show: Boolean)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
// 司机屏Server服务是否开启的状态
|
||||
CallerTelematicStatusListenerManager.removeListener(TAG)
|
||||
CallerDevaToolsListenerManager.removeListener(TAG)
|
||||
// 云socket连接状态
|
||||
MogoStatusManager.getInstance()
|
||||
.unregisterStatusChangedListener(TAG, StatusDescriptor.CLOUD_SOCKET, this)
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
/**
|
||||
* 司机屏服务是否启动的状态
|
||||
*/
|
||||
override fun onServerStatusChanged(isStarted: Boolean) {
|
||||
super.onServerStatusChanged(isStarted)
|
||||
UiThreadHandler.post({
|
||||
if (data.size < 1) return@post
|
||||
data[0].desc = "司机屏Server启动${if (isStarted) "正常" else "异常"}"
|
||||
data[0].isException = !isStarted
|
||||
adapter?.notifyItemChanged(0)
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
override fun gpsStatus(status: Boolean) {
|
||||
super.gpsStatus(status)
|
||||
UiThreadHandler.post({
|
||||
if (data.size < 2) return@post
|
||||
data[1].desc = "GPS${if (status) "正常" else "异常"}"
|
||||
data[1].isException = !status
|
||||
adapter?.notifyItemChanged(1)
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
/**
|
||||
* 云Socket
|
||||
*/
|
||||
override fun onStatusChanged(descriptor: StatusDescriptor?, isTrue: Boolean) {
|
||||
if (StatusDescriptor.CLOUD_SOCKET == descriptor) {
|
||||
UiThreadHandler.post({
|
||||
if (data.size < 3) return@post
|
||||
data[2].desc = "云Socket连接${if (isTrue) "正常" else "异常"}"
|
||||
data[2].isException = !isTrue
|
||||
adapter?.notifyItemChanged(2)
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
}
|
||||
|
||||
override fun tracingStatus(status: Boolean) {
|
||||
super.tracingStatus(status)
|
||||
// 发送事件前限制了频率
|
||||
UiThreadHandler.post({
|
||||
if (data.size < 4) return@post
|
||||
data[3].desc = "寻迹算路${if (status) "正常" else "异常"}"
|
||||
data[3].isException = !status
|
||||
adapter?.notifyItemChanged(3)
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.setting
|
||||
|
||||
import android.animation.Animator
|
||||
import android.content.Context
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.view.animation.OvershootInterpolator
|
||||
import com.mogo.eagle.core.data.enums.SidePattern
|
||||
import com.mogo.eagle.core.data.status.StatusSummaryEntity
|
||||
import com.mogo.eagle.core.function.hmi.notification.WarningFloat
|
||||
import com.mogo.eagle.core.function.hmi.notification.anim.DefaultAnimator
|
||||
import com.mogo.eagle.core.utilcode.util.BarUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ScreenUtils
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
|
||||
/**
|
||||
* 汇总状态View的管理类
|
||||
*/
|
||||
class StatusView private constructor() {
|
||||
|
||||
private var mStatusSummaryViewFloat: WarningFloat.Builder? = null
|
||||
private var mStatusSummaryView: StatusSummaryView? = null
|
||||
|
||||
companion object {
|
||||
val statusView by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
StatusView()
|
||||
}
|
||||
}
|
||||
|
||||
fun toggle(context: Context, gravity: Int = Gravity.RIGHT, sidePattern: SidePattern = SidePattern.RIGHT) {
|
||||
if (mStatusSummaryViewFloat != null) {
|
||||
dismiss()
|
||||
} else {
|
||||
if (mStatusSummaryView == null) {
|
||||
mStatusSummaryView = StatusSummaryView(context)
|
||||
mStatusSummaryView?.setClickListener(object : StatusSummaryView.ClickListener {
|
||||
override fun showWindow(show: Boolean) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
val height = AutoSizeUtils.dp2px(context, 1100f)
|
||||
val maxHeight = ScreenUtils.getScreenHeight() - BarUtils.getStatusBarHeight()
|
||||
val currentHeight = if(height>maxHeight) maxHeight else height
|
||||
mStatusSummaryViewFloat = WarningFloat.with(context)
|
||||
.setTag("StatusSummaryView")
|
||||
.setLayout(mStatusSummaryView!!)
|
||||
.setSidePattern(sidePattern)
|
||||
.setGravity(gravity, offsetY = 70)
|
||||
.setImmersionStatusBar(true)
|
||||
.slideDel(false)
|
||||
.setWindowHeight(currentHeight)
|
||||
.setWindowWidth(AutoSizeUtils.dp2px(context, 600f))
|
||||
.setAnimator(object : DefaultAnimator() {
|
||||
override fun enterAnim(
|
||||
view: View,
|
||||
params: WindowManager.LayoutParams,
|
||||
windowManager: WindowManager,
|
||||
sidePattern: SidePattern
|
||||
): Animator? =
|
||||
super.enterAnim(view, params, windowManager, sidePattern)
|
||||
?.apply {
|
||||
interpolator = OvershootInterpolator()
|
||||
}
|
||||
|
||||
override fun exitAnim(
|
||||
view: View,
|
||||
params: WindowManager.LayoutParams,
|
||||
windowManager: WindowManager,
|
||||
sidePattern: SidePattern
|
||||
): Animator? =
|
||||
super.exitAnim(view, params, windowManager, sidePattern)
|
||||
?.setDuration(200)
|
||||
})
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
fun dismiss() {
|
||||
mStatusSummaryViewFloat?.let {
|
||||
WarningFloat.dismiss(it.config.floatTag, false)
|
||||
mStatusSummaryViewFloat = null
|
||||
mStatusSummaryView = null
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 480 B |
Binary file not shown.
|
After Width: | Height: | Size: 425 B |
Binary file not shown.
|
After Width: | Height: | Size: 487 B |
Binary file not shown.
|
After Width: | Height: | Size: 319 B |
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.mogo.eagle.core.widget.RoundConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="@dimen/dp_600"
|
||||
android:layout_height="@dimen/dp_80"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
app:roundLayoutRadius="@dimen/dp_16"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:layout_marginBottom="@dimen/dp_12"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivFuncView"
|
||||
android:layout_width="@dimen/dp_64"
|
||||
android:layout_height="@dimen/dp_64"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_marginStart="12dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvStatusDesc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="已连接xxxxxxxxxxxxxxxx"
|
||||
android:textSize="@dimen/dp_20"
|
||||
android:layout_marginStart="@dimen/dp_10"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_marginEnd="10dp"
|
||||
/>
|
||||
|
||||
</com.mogo.eagle.core.widget.RoundConstraintLayout>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="@dimen/dp_600"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/notice_dialog_check_background"
|
||||
tools:ignore="MissingDefaultResource">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:text="状态汇总:"
|
||||
android:textSize="@dimen/dp_32"
|
||||
android:textColor="#FFFFFF"
|
||||
/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rvStatusView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvTitle"
|
||||
android:layout_marginTop="12dp"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user