[minibus320][adas] 修复MAP版本解析异常问题
This commit is contained in:
@@ -3,6 +3,7 @@ package com.mogo.eagle.core.utilcode.util;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -33,7 +34,11 @@ public class ParseVersionUtils {
|
||||
|
||||
/**
|
||||
* 解析版本 格式 xxx.xxx.xxx(x的数量不固定)
|
||||
* 如果用于比较,仅适用于非个位数非0的字符串,例如:"12.03.04" 解析出为120304可能无法正常对比
|
||||
* 仅用于版本比较,不能用于展示
|
||||
* 例如:
|
||||
* "12.03.04" 解析结果:120304
|
||||
* "2.11.0" 解析结果:21100
|
||||
* "3.0.0" 解析结果:30000
|
||||
* 目前已用于DockerVersion和MaserVersion的解析
|
||||
*
|
||||
* @param isUseAll 是否使用全部截取数据 true:表示 12.34.56 截取之后 123456 false:表示12.34.56 截取之后 12
|
||||
@@ -48,8 +53,12 @@ public class ParseVersionUtils {
|
||||
if (matcher.find()) {
|
||||
String group = matcher.group();
|
||||
if (!TextUtils.isEmpty(group)) {
|
||||
String format = "%02d";
|
||||
if (isUseAll) {
|
||||
group = group.replace(".", "");
|
||||
String[] temp = group.split("\\.");
|
||||
group = String.format(Locale.getDefault(), format, Integer.parseInt(temp[0]));
|
||||
group += String.format(Locale.getDefault(), format, Integer.parseInt(temp[1]));
|
||||
group += String.format(Locale.getDefault(), format, Integer.parseInt(temp[2]));
|
||||
} else {
|
||||
group = group.split("\\.")[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user