[6.7.0][运营面板] 优化带编辑框的配置项的显示和缓存逻辑
This commit is contained in:
@@ -378,14 +378,12 @@ class MoGoHmiProvider : IMoGoHmiProvider {
|
||||
* 展示红绿灯
|
||||
*/
|
||||
override fun showTrafficLightView() {
|
||||
HmiBuildConfig.isShowTrafficLightView = false
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏红绿灯
|
||||
*/
|
||||
override fun hideTrafficLightView() {
|
||||
HmiBuildConfig.isShowTrafficLightView = true
|
||||
CallerTrafficLightListenerManager.disableTrafficLight()
|
||||
}
|
||||
|
||||
|
||||
@@ -1078,9 +1078,9 @@ class OperatePanelLayout : LinearLayout {
|
||||
return true
|
||||
}
|
||||
KEY_CHANGE_LANE_SPEED_THRESHOLDS -> {
|
||||
FunctionBuildConfig.detouringSpeed = preference.extras.getDouble(PreferenceWithSpeedSetting.KEY_BUNDLE_CURRENT_VALUE, FunctionBuildConfig.detouringSpeed.toDouble()).toInt()
|
||||
FunctionBuildConfig.detouringSpeed = preference.extras.getDouble(PreferenceWithSpeedSetting.KEY_BUNDLE_CURRENT_VALUE, FunctionBuildConfig.detouringSpeed.toDouble())
|
||||
hmiAction("SOP 变道绕障的目标障碍物速度阈值", FunctionBuildConfig.detouringSpeed)
|
||||
val isSuccess = CallerAutoPilotControlManager.sendDetouringSpeed(FunctionBuildConfig.detouringSpeed.toDouble())
|
||||
val isSuccess = CallerAutoPilotControlManager.sendDetouringSpeed(FunctionBuildConfig.detouringSpeed)
|
||||
if (isSuccess == true) {
|
||||
ToastUtils.showShort("变道绕障的目标障碍物速度阈值设置成功")
|
||||
hmiAction("SOP 变道绕障的目标障碍物速度阈值设置", "成功")
|
||||
@@ -1092,8 +1092,8 @@ class OperatePanelLayout : LinearLayout {
|
||||
return true
|
||||
}
|
||||
KEY_OVERTAKE_SPEED_THRESHOLDSS -> {
|
||||
FunctionBuildConfig.overTakeSpeed = preference.extras.getDouble(PreferenceWithSpeedSetting.KEY_BUNDLE_CURRENT_VALUE, FunctionBuildConfig.overTakeSpeed.toDouble()).toFloat()
|
||||
val isSuccess = CallerAutoPilotControlManager.sendOvertakeMaxSpeed(FunctionBuildConfig.overTakeSpeed.toDouble())
|
||||
FunctionBuildConfig.overTakeSpeed = preference.extras.getDouble(PreferenceWithSpeedSetting.KEY_BUNDLE_CURRENT_VALUE, FunctionBuildConfig.overTakeSpeed)
|
||||
val isSuccess = CallerAutoPilotControlManager.sendOvertakeMaxSpeed(FunctionBuildConfig.overTakeSpeed)
|
||||
if (isSuccess == true) {
|
||||
ToastUtils.showShort("SOP 超车目标障碍物速度阈值设置成功")
|
||||
hmiAction("SOP 超车目标障碍物速度阈值设置", "成功")
|
||||
|
||||
@@ -8,12 +8,15 @@ import androidx.preference.PreferenceViewHolder
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlin.math.max
|
||||
|
||||
class PreferenceWithSpeedSetting : Preference {
|
||||
|
||||
companion object {
|
||||
const val KEY_BUNDLE_CURRENT_VALUE = "key_bundle_current_val"
|
||||
private val enabled by lazy { ConcurrentHashMap<String, Boolean>() }
|
||||
private val cache by lazy { ConcurrentHashMap<String, Double>() }
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
@@ -22,7 +25,6 @@ class PreferenceWithSpeedSetting : Preference {
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
private var mSpeedData: Any? = null
|
||||
private var mFlag = true
|
||||
|
||||
override fun setDefaultValue(defaultValue: Any?) {
|
||||
super.setDefaultValue(defaultValue)
|
||||
@@ -35,10 +37,6 @@ class PreferenceWithSpeedSetting : Preference {
|
||||
notifyChanged()
|
||||
}
|
||||
|
||||
override fun onSetInitialValue(defaultValue: Any?) {
|
||||
super.onSetInitialValue(defaultValue)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||
super.onBindViewHolder(holder)
|
||||
val speedData = mSpeedData ?: return
|
||||
@@ -61,11 +59,14 @@ class PreferenceWithSpeedSetting : Preference {
|
||||
val ll = holder.findViewById(R.id.ll_speed)
|
||||
val btnOk = holder.findViewById(R.id.bt_ok)
|
||||
val speedLimit = holder.findViewById(R.id.tv_speed_limit) as? TextView
|
||||
if (speedLimit?.tag != null && speedLimit.tag is Float) {
|
||||
cur = max(cur, speedLimit.tag as Double)
|
||||
if (cache.containsKey(key)) {
|
||||
cur = max(cur, cache[key] ?: 0.0)
|
||||
}
|
||||
speedLimit?.text = cur.toString()
|
||||
val minus = holder.findViewById(R.id.iv_speed_minus)
|
||||
btnOk.isEnabled = enabled[key] ?: false
|
||||
holder.itemView.isEnabled = enabled[key] ?: false
|
||||
ll.isSelected = enabled[key] ?: false
|
||||
minus.setOnClickListener(null)
|
||||
minus.onClick {
|
||||
val minusAfter = cur - step
|
||||
@@ -76,7 +77,9 @@ class PreferenceWithSpeedSetting : Preference {
|
||||
cur = minusAfter
|
||||
btnOk.isEnabled = true
|
||||
ll.isSelected = true
|
||||
speedLimit?.tag = minusAfter
|
||||
cache[key] = cur
|
||||
enabled[key] = true
|
||||
holder.itemView.isEnabled = false
|
||||
speedLimit?.text = minusAfter.toString()
|
||||
}
|
||||
val add = holder.findViewById(R.id.iv_speed_add)
|
||||
@@ -87,19 +90,19 @@ class PreferenceWithSpeedSetting : Preference {
|
||||
ToastUtils.showShort("阈值最大可为${max}m/s")
|
||||
return@onClick
|
||||
}
|
||||
holder.itemView.isEnabled = false
|
||||
cur = addAfter
|
||||
cache[key] = cur
|
||||
ll.isSelected = true
|
||||
btnOk.isEnabled = true
|
||||
speedLimit?.tag = addAfter
|
||||
enabled[key] = true
|
||||
speedLimit?.text = addAfter.toString()
|
||||
}
|
||||
if (mFlag) {
|
||||
mFlag = false
|
||||
btnOk.isEnabled = false
|
||||
}
|
||||
btnOk.setOnClickListener(null)
|
||||
btnOk.onClick {
|
||||
onPreferenceClickListener?.also {
|
||||
enabled[key] = false
|
||||
cache.remove(key)
|
||||
extras.putDouble(KEY_BUNDLE_CURRENT_VALUE, cur)
|
||||
it.onPreferenceClick(this)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user