From fb81bd01b4163471abce2ddae7f269d720bda057 Mon Sep 17 00:00:00 2001 From: renwj Date: Wed, 3 Aug 2022 16:17:40 +0800 Subject: [PATCH] =?UTF-8?q?[RouteOpt]=E4=BC=98=E5=8C=96=E5=BC=95=E5=AF=BC?= =?UTF-8?q?=E7=BA=BF=E4=BB=A3=E7=A0=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/service/routeoverlay/RouteStrategy.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteStrategy.kt b/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteStrategy.kt index da1b089fd5..a47263cc02 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteStrategy.kt +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteStrategy.kt @@ -40,6 +40,7 @@ class ColorfulStrategy(private val colors: List = emptyList(), var isLightO object RouteStrategy { + @Volatile private var isEnable = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) && !AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) private var strategy: Strategy? = null @@ -65,6 +66,9 @@ object RouteStrategy { } fun start() { + if (sorted.isEmpty()) { + fill() + } strategy = null index = 0 startColor = Int.MAX_VALUE @@ -89,10 +93,7 @@ object RouteStrategy { return } if (sorted.isEmpty()) { - fill() - } - if (sorted.isEmpty()) { - throw AssertionError("sorted map must not be null.") + return } if (acc < 0) { hasLessThan0 = true @@ -122,6 +123,9 @@ object RouteStrategy { } fun remove(acc: Double): List { + if (!isEnable) { + return emptyList() + } if (sorted.isEmpty()) { throw AssertionError("sorted map must not be null.") }