修改工控机升级帮助类
1、去掉无用引用 2、添加@JvmStatic注解 3、优化代码
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
package com.mogo.eagle.core.data.autopilot
|
||||
|
||||
import android.util.Log
|
||||
import java.util.logging.Logger
|
||||
|
||||
/**
|
||||
* @author XuXinChao
|
||||
* @description 工控机升级状态实体类
|
||||
@@ -32,6 +29,7 @@ class AdUpgradeStateHelper {
|
||||
* @param downloadStatus 下载状态
|
||||
* @param upgradeStatus 升级状态
|
||||
*/
|
||||
@JvmStatic
|
||||
fun showUpgradeTips(downloadStatus: Int,upgradeStatus: Int) : Boolean{
|
||||
return isDownloading(downloadStatus) || isDownloadFinish(downloadStatus,upgradeStatus) || getUpgradeStatus() || isUpgradeFailed(upgradeStatus)
|
||||
}
|
||||
@@ -41,6 +39,7 @@ class AdUpgradeStateHelper {
|
||||
* @param downloadStatus 下载状态
|
||||
* @param upgradeStatus 升级状态
|
||||
*/
|
||||
@JvmStatic
|
||||
fun showCannotReboot(downloadStatus: Int,upgradeStatus: Int): Boolean{
|
||||
return isDownloading(downloadStatus)|| isDownloadFinish(downloadStatus,upgradeStatus) || getUpgradeStatus()
|
||||
}
|
||||
@@ -49,6 +48,7 @@ class AdUpgradeStateHelper {
|
||||
* 工控机是否处于“下载中”状态
|
||||
* @param downloadStatus 下载状态
|
||||
*/
|
||||
@JvmStatic
|
||||
fun isDownloading(downloadStatus: Int) : Boolean{
|
||||
return downloadStatus == DOWNLOAD_START
|
||||
}
|
||||
@@ -58,6 +58,7 @@ class AdUpgradeStateHelper {
|
||||
* @param downloadStatus 下载状态
|
||||
* @param upgradeStatus 升级状态
|
||||
*/
|
||||
@JvmStatic
|
||||
fun isDownloadFinish(downloadStatus: Int,upgradeStatus: Int) : Boolean{
|
||||
return downloadStatus == DOWNLOAD_FINISH && upgradeStatus == USER_AFFIRM
|
||||
}
|
||||
@@ -66,6 +67,7 @@ class AdUpgradeStateHelper {
|
||||
* 工控机是否处于“下载失败”状态
|
||||
* @param downloadStatus 下载状态
|
||||
*/
|
||||
@JvmStatic
|
||||
fun isDownloadFailed(downloadStatus: Int) : Boolean{
|
||||
return downloadStatus == DOWNLOAD_FAILED
|
||||
}
|
||||
@@ -74,6 +76,7 @@ class AdUpgradeStateHelper {
|
||||
* 工控机是否处于“升级成功”状态
|
||||
* @param upgradeStatus 升级状态
|
||||
*/
|
||||
@JvmStatic
|
||||
fun isUpgradeSuccess(upgradeStatus: Int) : Boolean{
|
||||
return upgradeStatus == UPGRADE_SUCCEED
|
||||
}
|
||||
@@ -82,6 +85,7 @@ class AdUpgradeStateHelper {
|
||||
* 工控机是否处于“升级失败”状态
|
||||
* @param upgradeStatus 升级状态
|
||||
*/
|
||||
@JvmStatic
|
||||
fun isUpgradeFailed(upgradeStatus: Int) : Boolean{
|
||||
return upgradeStatus == UPGRADE_FAILED
|
||||
}
|
||||
@@ -91,6 +95,7 @@ class AdUpgradeStateHelper {
|
||||
* @param currentProgress 当前已下载包体大小
|
||||
* @param totalProgress 包体总大小
|
||||
*/
|
||||
@JvmStatic
|
||||
fun downloadProgress(currentProgress: Int,totalProgress: Int) : Int{
|
||||
return (currentProgress.toDouble()/totalProgress.toDouble()*100).toInt()
|
||||
}
|
||||
@@ -99,6 +104,7 @@ class AdUpgradeStateHelper {
|
||||
* 工控机升级模式是否是静默升级
|
||||
* @param upgradeMode 升级模式
|
||||
*/
|
||||
@JvmStatic
|
||||
fun isQuietUpgradeMode(upgradeMode: Int) : Boolean{
|
||||
return upgradeMode == UPGRADE_QUIET
|
||||
}
|
||||
@@ -107,6 +113,7 @@ class AdUpgradeStateHelper {
|
||||
* 工控机升级模式是否是提示升级
|
||||
* @param upgradeMode 升级模式
|
||||
*/
|
||||
@JvmStatic
|
||||
fun isHintUpgradeMode(upgradeMode: Int) : Boolean{
|
||||
return upgradeMode == UPGRADE_HINT
|
||||
}
|
||||
@@ -114,6 +121,7 @@ class AdUpgradeStateHelper {
|
||||
/**
|
||||
* 获取是否处于“升级中”状态
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getUpgradeStatus() : Boolean{
|
||||
return UPGRADING
|
||||
}
|
||||
@@ -122,6 +130,7 @@ class AdUpgradeStateHelper {
|
||||
* 设置是否处于“升级中”状态
|
||||
* @param upgrading 是否是升级中
|
||||
*/
|
||||
@JvmStatic
|
||||
fun setUpgradeStatus(upgrading: Boolean){
|
||||
UPGRADING = upgrading
|
||||
}
|
||||
@@ -129,6 +138,7 @@ class AdUpgradeStateHelper {
|
||||
/**
|
||||
* 获取工控机包体下载剩余时间
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getRemainingTime(totalProgress: Int,previousProgress: Int,currentProgress: Int) : String{
|
||||
//剩余包体大小
|
||||
val remainingSize = totalProgress - currentProgress
|
||||
@@ -139,14 +149,14 @@ class AdUpgradeStateHelper {
|
||||
//转换为分秒格式返回
|
||||
val minute = time/60
|
||||
val second = time%60
|
||||
if(minute>0 && second>0){
|
||||
return minute.toString()+"分钟"+second+"秒"
|
||||
return if(minute>0 && second>0){
|
||||
minute.toString()+"分钟"+second+"秒"
|
||||
}else if(minute>0){
|
||||
return minute.toString()+"分钟"
|
||||
minute.toString()+"分钟"
|
||||
}else if(second>0){
|
||||
return second.toString()+"秒"
|
||||
second.toString()+"秒"
|
||||
}else{
|
||||
return ""
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user