[8.3.0] FM发送定位初始化失败时进行弹窗
This commit is contained in:
@@ -58,6 +58,7 @@ import com.mogo.eagle.core.function.hmi.ui.setting.CameraLiveView.Companion.came
|
||||
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.FMDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.ModifyBindingCarDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.OTADownloadStatusDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.OTAPowerOffFinishDialog
|
||||
@@ -682,6 +683,7 @@ class MoGoHmiProvider : IMoGoHmiProvider {
|
||||
private var otaDownloadStatusDialog: OTADownloadStatusDialog ?= null
|
||||
private var otaUpgradeResultDialog: OTAUpgradeResultDialog ?= null
|
||||
private var otaPowerOffFinishDialog: OTAPowerOffFinishDialog ?= null
|
||||
private var fMDialog: FMDialog ?= null
|
||||
|
||||
/**
|
||||
* 展示OTA升级弹窗
|
||||
@@ -816,4 +818,20 @@ class MoGoHmiProvider : IMoGoHmiProvider {
|
||||
}
|
||||
}
|
||||
|
||||
override fun showFMDialog(errorMsg: String) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
context?.let {
|
||||
if (fMDialog == null) {
|
||||
fMDialog = FMDialog(it).apply {
|
||||
// 设置回调,当弹窗消失(无论是手动还是自动)时置空
|
||||
onDialogDestroyListener = {
|
||||
Log.i("FMDialog","回调销毁")
|
||||
fMDialog = null
|
||||
}
|
||||
}
|
||||
}
|
||||
fMDialog?.showMsg(errorMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.tools
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.dialog.BaseFloatDialog
|
||||
import kotlinx.android.synthetic.main.dialog_fm_data_show.tvResultClose
|
||||
import kotlinx.android.synthetic.main.dialog_fm_data_show.tvResultContent
|
||||
|
||||
/**
|
||||
* FM 提示窗
|
||||
*/
|
||||
class FMDialog(context: Context) :
|
||||
BaseFloatDialog(context, TAG) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "FMDialog"
|
||||
private const val AUTO_DISMISS_DELAY = 2000L // 2秒持续无消息则关闭
|
||||
private const val SHOW_INTERVAL = 2000L // 关闭后如果还有事件最短展示时间间隔
|
||||
}
|
||||
|
||||
// 用于自动关闭的 Handler
|
||||
private val mHandler = Handler(Looper.getMainLooper())
|
||||
private var dismissTime = System.currentTimeMillis() - SHOW_INTERVAL //初始化时间必须大于 2秒
|
||||
|
||||
// 自动关闭的任务
|
||||
private val mDismissRunnable = Runnable {
|
||||
dismiss(true)
|
||||
}
|
||||
|
||||
// 提供给外部的回调,用于清理引用或状态复位
|
||||
var onDialogDestroyListener: (() -> Unit)? = null
|
||||
|
||||
init {
|
||||
setContentView(R.layout.dialog_fm_data_show)
|
||||
setCanceledOnTouchOutside(false)
|
||||
tvResultClose.setOnClickListener {
|
||||
dismiss(false)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示/更新定位故障信息
|
||||
* @param msg 故障描述
|
||||
*/
|
||||
fun showMsg(msg: String) {
|
||||
if (System.currentTimeMillis() - dismissTime >= SHOW_INTERVAL) {
|
||||
// 1. 只要收到新消息,就移除之前的自动关闭任务(重置计时)
|
||||
mHandler.removeCallbacks(mDismissRunnable)
|
||||
if (!isShowing) {
|
||||
show()
|
||||
}
|
||||
if (msg.isNotEmpty()) {
|
||||
tvResultContent.text = msg
|
||||
}
|
||||
// 2. 开启/重新开启 2s 后的自动关闭任务
|
||||
mHandler.postDelayed(mDismissRunnable, AUTO_DISMISS_DELAY)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun dismiss(isDestroy: Boolean) {
|
||||
if (isShowing) {
|
||||
super.dismiss()
|
||||
}
|
||||
dismissTime = System.currentTimeMillis()
|
||||
if (isDestroy) {
|
||||
onDialogDestroyListener?.invoke()
|
||||
mHandler.removeCallbacksAndMessages(null)
|
||||
} else {
|
||||
mHandler.removeCallbacks(mDismissRunnable)
|
||||
mHandler.postDelayed(mDismissRunnable, AUTO_DISMISS_DELAY + 2000L)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="@dimen/dp_900"
|
||||
android:layout_height="@dimen/dp_620"
|
||||
android:background="@drawable/bg_bone_dialog"
|
||||
app:roundLayoutRadius="@dimen/dp_50">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivUpgradeResult"
|
||||
android:layout_width="@dimen/dp_140"
|
||||
android:layout_height="@dimen/dp_140"
|
||||
android:layout_marginTop="@dimen/dp_80"
|
||||
android:src="@drawable/icon_connection_tip"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvResultContent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_100"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
android:layout_marginEnd="@dimen/dp_100"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_45"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/ivUpgradeResult" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvResultClose"
|
||||
android:layout_width="@dimen/dp_356"
|
||||
android:layout_height="@dimen/dp_120"
|
||||
android:layout_marginBottom="@dimen/dp_58"
|
||||
android:background="@drawable/bg_dialog_btn"
|
||||
android:gravity="center"
|
||||
android:text="@string/ota_result_close"
|
||||
android:textColor="@color/color_2EACFF"
|
||||
android:textSize="@dimen/dp_40"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user