[2.13.0-arch-opt] move impl of modules from hmi to app

This commit is contained in:
zhongchao
2023-02-07 22:11:51 +08:00
parent 81a22a63cf
commit 8490801138
23 changed files with 176 additions and 150 deletions

View File

@@ -1,16 +1,17 @@
package com.mogo.eagle.core.function.business.routeoverlay
import android.animation.*
import android.graphics.*
import android.view.animation.*
import com.mogo.eagle.core.data.config.*
import com.mogo.eagle.core.utilcode.mogo.*
import android.animation.ArgbEvaluator
import android.graphics.Color
import android.view.animation.AccelerateInterpolator
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.config.HmiBuildConfig
import com.mogo.eagle.core.function.business.routeoverlay.Colors.Companion.COLOR_BLUE
import com.mogo.eagle.core.function.business.routeoverlay.Colors.Companion.COLOR_BLUE_DARK
import com.mogo.eagle.core.function.business.routeoverlay.Colors.Companion.COLOR_RED_DARK
import com.mogo.eagle.core.function.business.routeoverlay.Colors.Companion.COLOR_TRANSPARENT
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import java.util.*
import kotlin.collections.ArrayList
import kotlin.properties.Delegates
interface IStrategy {
@@ -22,26 +23,31 @@ class Colors {
companion object {
val COLOR_BLUE = Color.parseColor("#FF2ABAD9")
val COLOR_BLUE_DARK = Color.parseColor("#FF074EFF")
val COLOR_RED_DARK = Color.parseColor("#FFFF5F00")
val COLOR_TRANSPARENT = Color.parseColor("#002ABAD9")
val COLOR_RED_DARK = Color.parseColor("#FFFF5F00")
val COLOR_TRANSPARENT = Color.parseColor("#002ABAD9")
}
}
sealed class Strategy: IStrategy
sealed class Strategy : IStrategy
class DefaultStrategy(private val colors: List<Int>? = null): Strategy() {
class DefaultStrategy(private val colors: List<Int>? = null) : Strategy() {
override fun getColors(): List<Int> = colors ?: listOf(COLOR_BLUE, COLOR_TRANSPARENT)
}
class ColorfulStrategy(private val colors: List<Int> = emptyList(), var isLightOn: Boolean): Strategy() {
class ColorfulStrategy(private val colors: List<Int> = emptyList(), var isLightOn: Boolean) :
Strategy() {
override fun getColors(): List<Int> = colors
}
object RouteStrategy {
@Volatile
private var isEnable = !AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)
private var isEnable by Delegates.observable(HmiBuildConfig.isShowRouteStrategy) { _, _, newValue ->
if (!newValue) {
strategy = null
colors.clear()
}
}
private var strategy: Strategy? = null
@@ -57,14 +63,6 @@ object RouteStrategy {
private var hasLessThan0 = false
fun enable(enable: Boolean) {
isEnable = enable
if (!enable) {
strategy = null
colors.clear()
}
}
fun start() {
if (sorted.isEmpty()) {
fill()
@@ -89,7 +87,7 @@ object RouteStrategy {
}
fun check(speed: Double, acc: Double, total: Int) {
if (!isEnable){
if (!isEnable) {
return
}
if (sorted.isEmpty()) {
@@ -112,7 +110,11 @@ object RouteStrategy {
} else {
if (endEvaluator != null) {
val fraction = (index - last) * 1.0f / delta
colors += endEvaluator!!.evaluate(fraction, startColor, COLOR_TRANSPARENT) as Int
colors += endEvaluator!!.evaluate(
fraction,
startColor,
COLOR_TRANSPARENT
) as Int
}
}
} else {
@@ -156,11 +158,14 @@ object RouteStrategy {
total = endValue - startValue
while (current <= endValue) {
val fraction = (current - startValue) / total
val colorValue = evaluator.evaluate(fraction.toFloat(), COLOR_BLUE, COLOR_BLUE_DARK) as Int
val colorValue =
evaluator.evaluate(fraction.toFloat(), COLOR_BLUE, COLOR_BLUE_DARK) as Int
sorted[current] = colorValue
current += step
}
}
fun getStrategy(): Strategy = if (isEnable) { (strategy ?: DefaultStrategy()) } else DefaultStrategy()
fun getStrategy(): Strategy = if (isEnable) {
(strategy ?: DefaultStrategy())
} else DefaultStrategy()
}