[6.8.0]冷启动三期进度条
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.TransitionDrawable
|
||||
import android.os.CountDownTimer
|
||||
import android.text.TextUtils
|
||||
@@ -14,8 +13,10 @@ import androidx.core.content.ContextCompat
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoColdStartStateListener
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerColdStartStateListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiViewControlListenerManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.util.FrameAnimatorContainerUtils
|
||||
@@ -45,6 +46,8 @@ class ColdStartProcessView @JvmOverloads constructor(
|
||||
const val TAG = "ColdStartProcessView"
|
||||
const val LOAD_SSM_WAITING_TIME = 180000L //SSM加载超时等待时间
|
||||
const val COLD_START_WAITING_TIME = 600000L //冷启动超时等待时间
|
||||
const val COLD_START_SUCCESS_SHOW_TIME = 3000L //冷启动成功视图展示时长
|
||||
const val COLD_START_SUCCESS_TICK_TIME = 500L //冷启动成功视图呼吸时长
|
||||
}
|
||||
|
||||
private var ipcConnectStatus = false //连接域控状态,默认是未连接
|
||||
@@ -62,6 +65,9 @@ class ColdStartProcessView @JvmOverloads constructor(
|
||||
private var coldStartProcessNormalAnim: FrameAnimatorContainerUtils ?= null
|
||||
private var coldStartProcessAbnormalAnim: FrameAnimatorContainerUtils ?= null
|
||||
|
||||
private var transition: TransitionDrawable ?= null
|
||||
private var coldStartSuccessTimer: CountDownTimer?= null //冷启动成功动画倒计时
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_cold_start_process, this, true)
|
||||
initView()
|
||||
@@ -72,37 +78,17 @@ class ColdStartProcessView @JvmOverloads constructor(
|
||||
coldStartProcessAbnormalAnim = FrameAnimatorContainerUtils(R.array.cold_start_process_abnormal,40,ivColdStartProcess)
|
||||
|
||||
|
||||
val transition = TransitionDrawable(
|
||||
transition = TransitionDrawable(
|
||||
arrayOf(
|
||||
ContextCompat.getDrawable(context, R.drawable.icon_cold_start_success_01), // 当前图片
|
||||
ContextCompat.getDrawable(context, R.drawable.icon_cold_start_success_02) // 要渐变到的图片
|
||||
)
|
||||
)
|
||||
ivColdStartProcess.setImageDrawable(transition)
|
||||
transition.isCrossFadeEnabled = true
|
||||
var tag = true
|
||||
val testTimer = object: CountDownTimer(30000,500){
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
tag = if(tag){
|
||||
transition.startTransition(500)
|
||||
false
|
||||
}else{
|
||||
transition.reverseTransition(500)
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
transition?.isCrossFadeEnabled = true
|
||||
|
||||
override fun onFinish() {
|
||||
ThreadUtils.runOnUiThread {
|
||||
this@ColdStartProcessView.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
ivColdStartProcess.setOnClickListener {
|
||||
testTimer.start()
|
||||
CallerHmiManager.showColdStartWindow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,17 +124,10 @@ class ColdStartProcessView @JvmOverloads constructor(
|
||||
) {
|
||||
if(status == AdasConstants.IpcConnectionStatus.CONNECTED){
|
||||
//域控连接成功
|
||||
if(coldStartProcessAbnormalAnim?.isPlaying() == true){
|
||||
coldStartProcessAbnormalAnim?.stop()
|
||||
}
|
||||
coldStartProcessNormalAnim?.start()
|
||||
|
||||
coldStartNormalView()
|
||||
}else{
|
||||
//域控连接失败
|
||||
if(coldStartProcessNormalAnim?.isPlaying() == true){
|
||||
coldStartProcessNormalAnim?.stop()
|
||||
}
|
||||
coldStartProcessAbnormalAnim?.start()
|
||||
coldStartAbnormalView()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,16 +137,14 @@ class ColdStartProcessView @JvmOverloads constructor(
|
||||
* HQ、M1 MAP350开始弃用,其他车型MAP360开始弃用
|
||||
*/
|
||||
override fun onAutopilotStatusRespByQuery(status: SystemStatusInfo.StatusInfo){
|
||||
ThreadUtils.runOnUiThread{
|
||||
//SSM连接成功
|
||||
connectSSMSuccess()
|
||||
//通过autoPilotReady判断冷启动是否成功
|
||||
if(status.hasAutoPilotReady() && status.autoPilotReady && !coldStartStatus){
|
||||
coldStartStatus = true
|
||||
showColdStartSuccessView()
|
||||
//记录冷启动成功时间
|
||||
ColdStartConfig.setColdStartSuccessTime(System.currentTimeMillis())
|
||||
}
|
||||
//SSM连接成功
|
||||
coldStartNormalView()
|
||||
//通过autoPilotReady判断冷启动是否成功
|
||||
if(status.hasAutoPilotReady() && status.autoPilotReady && !coldStartStatus){
|
||||
coldStartStatus = true
|
||||
showColdStartSuccessView()
|
||||
//记录冷启动成功时间
|
||||
ColdStartConfig.setColdStartSuccessTime(System.currentTimeMillis())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,11 +155,35 @@ class ColdStartProcessView @JvmOverloads constructor(
|
||||
* @param statusInf 数据
|
||||
*/
|
||||
override fun onSystemStatus(statusInf: SsmInfo.SsmStatusInf){
|
||||
|
||||
//SSM连接成功
|
||||
coldStartNormalView()
|
||||
//版本兼容
|
||||
if(parseVersion(true, statusInf.masterVersion) > 40600){
|
||||
//主动查询冷启动状态
|
||||
if(!newColdStart){
|
||||
newColdStart = true
|
||||
CallerAutoPilotControlManager.sendSsmFuncQueryColdStartState()
|
||||
}
|
||||
}else{
|
||||
newColdStart = false
|
||||
//通过autoPilotReady判断冷启动是否成功
|
||||
Log.i(TAG,"statusInf.autoPilotReady="+statusInf.autoPilotReady)
|
||||
if(statusInf.hasAutoPilotReady() && statusInf.autoPilotReady && !coldStartStatus){
|
||||
coldStartStatus = true
|
||||
showColdStartSuccessView()
|
||||
//记录冷启动成功时间
|
||||
ColdStartConfig.setColdStartSuccessTime(System.currentTimeMillis())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 冷启动状态
|
||||
* 冷启动状态变更上报以及查询状态
|
||||
*
|
||||
* @param token 唯一消息ID
|
||||
* @param timestamp 消息发送时间 单位:毫秒
|
||||
* @param isQuery 是否是查询 ture:查询相应的结果 false:表示状态变动域控主动推送
|
||||
* @param coldStartState 数据 null表示 PadSsmMsg中的消息体为null
|
||||
*/
|
||||
override fun onColdStartState(
|
||||
token: Long,
|
||||
@@ -190,15 +191,93 @@ class ColdStartProcessView @JvmOverloads constructor(
|
||||
isQuery: Boolean,
|
||||
coldStartState: SsmInfo.ColdStartState?
|
||||
) {
|
||||
|
||||
if(newColdStart){
|
||||
coldStartState?.let{
|
||||
Log.i(TAG,"节点自上报冷启动状态="+it.eventStatus)
|
||||
ThreadUtils.runOnUiThread{
|
||||
if(it.eventStatus == SsmInfo.CSState.COLD_START_READY){
|
||||
if(!coldStartStatus){
|
||||
//冷启动就绪
|
||||
coldStartStatus = true
|
||||
showColdStartSuccessView()
|
||||
}
|
||||
//记录冷启动成功时间
|
||||
ColdStartConfig.setColdStartSuccessTime(System.currentTimeMillis())
|
||||
}
|
||||
if(it.eventStatus == SsmInfo.CSState.COLD_START_UNREADY || it.eventStatus == SsmInfo.CSState.COLD_START_TIMEOUT){
|
||||
//展示冷启动失败视图
|
||||
showColdStartFailView()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun connectSSMSuccess(){
|
||||
|
||||
/**
|
||||
* 冷启动进行中,不存在异常项
|
||||
*/
|
||||
private fun coldStartNormalView(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
if(coldStartProcessAbnormalAnim?.isPlaying() == true){
|
||||
coldStartProcessAbnormalAnim?.stop()
|
||||
}
|
||||
if(coldStartProcessNormalAnim?.isPlaying() == false){
|
||||
coldStartProcessNormalAnim?.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 冷启动进行中,存在异常项
|
||||
*/
|
||||
private fun coldStartAbnormalView(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
if(coldStartProcessNormalAnim?.isPlaying() == true){
|
||||
coldStartProcessNormalAnim?.stop()
|
||||
}
|
||||
if(coldStartProcessAbnormalAnim?.isPlaying() == false){
|
||||
coldStartProcessAbnormalAnim?.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 冷启动成功视图
|
||||
*/
|
||||
private fun showColdStartSuccessView(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
var label = true
|
||||
coldStartSuccessTimer = object: CountDownTimer(COLD_START_SUCCESS_SHOW_TIME,COLD_START_SUCCESS_TICK_TIME){
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
label = if(label){
|
||||
transition?.startTransition(500)
|
||||
false
|
||||
}else{
|
||||
transition?.reverseTransition(500)
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
ThreadUtils.runOnUiThread {
|
||||
this@ColdStartProcessView.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
coldStartSuccessTimer?.start()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 冷启动失败视图
|
||||
*/
|
||||
private fun showColdStartFailView(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private val pattern = Pattern.compile("\\d+\\.\\d+\\.\\d+")
|
||||
|
||||
Reference in New Issue
Block a user