[8.0.0][Opt]优化决策、预测地图渲染
This commit is contained in:
@@ -16,6 +16,10 @@ interface Identify {
|
||||
|
||||
}
|
||||
|
||||
fun renderAdasRegResults(resultList: List<TrackedObject>?, mapObjList: List<String>) {
|
||||
|
||||
}
|
||||
|
||||
fun renderAiCloudResult(resultList: List<SocketDownData.CloudRoadDataProto>, mapInstance:String) {
|
||||
|
||||
}
|
||||
@@ -40,6 +44,10 @@ interface Identify {
|
||||
|
||||
}
|
||||
|
||||
fun clearOldMarkers(mapObjList:List<String>) {
|
||||
|
||||
}
|
||||
|
||||
fun clearAiMarker(mapInstance:String) {
|
||||
|
||||
}
|
||||
|
||||
@@ -33,8 +33,9 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
|
||||
// 预测
|
||||
object PreDriverIdentify {
|
||||
internal val preDataDrawer = IdentifyPredictionDataDrawer()
|
||||
// internal val preDataDrawer2 = IdentifyPredictionDataDrawer()
|
||||
internal val preDataDrawer = IdentifyOriginDataDrawer()
|
||||
|
||||
// internal val preDataDrawer2 = IdentifyPredictionDataDrawer()
|
||||
// internal val preDataDrawer3 = IdentifyPredictionDataDrawer()
|
||||
internal val preDataDrawer2 = IdentifyOriginDataDrawer()
|
||||
internal val preDataDrawer3 = IdentifyOriginDataDrawer()
|
||||
@@ -47,16 +48,19 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
|
||||
private var identify: Identify = DriverIdentify.originDataDrawer
|
||||
private var aiCloudIdentify: Identify? = null
|
||||
|
||||
// 预测
|
||||
private var preIdentify: Identify = PreDriverIdentify.preDataDrawer
|
||||
private var preIdentify2: Identify = PreDriverIdentify.preDataDrawer2
|
||||
private var preIdentify3: Identify = PreDriverIdentify.preDataDrawer3
|
||||
|
||||
// private var preIdentify2: Identify = PreDriverIdentify.preDataDrawer2
|
||||
// private var preIdentify3: Identify = PreDriverIdentify.preDataDrawer3
|
||||
// 决策
|
||||
private var desIdentify: Identify = DesDriverIdentify.desDataDrawer
|
||||
|
||||
private var startTime: Long = 0L
|
||||
private var preStartTime: Long = 0L
|
||||
private var desStartTime: Long = 0L
|
||||
|
||||
// private var preStartTime: Long = 0L
|
||||
// private var desStartTime: Long = 0L
|
||||
private var dockerVersion: String? = null
|
||||
|
||||
fun initType() {
|
||||
@@ -96,33 +100,24 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
if (internal >= 1000) {
|
||||
lostFrame(internal.toString())
|
||||
identify.clearOldMarker()
|
||||
}
|
||||
if (FunctionBuildConfig.isDrawPreIdentifyData && TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - preStartTime) >= 1000) {
|
||||
preIdentify.clearOldMarker()
|
||||
}
|
||||
if (FunctionBuildConfig.isDrawDecIdentifyData && TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - desStartTime) >= 1000) {
|
||||
desIdentify.clearOldMarker()
|
||||
preIdentify2.clearOldMarker()
|
||||
preIdentify3.clearOldMarker()
|
||||
}
|
||||
sendEmptyMessageDelayed(MSG_CHECK, 1000L)
|
||||
}
|
||||
|
||||
MSG_DATA_TRACK -> {
|
||||
if (msg.obj is List<*>) {
|
||||
val objectList = msg.obj as List<TrackedObject>?
|
||||
identify.renderAdasRecognizedResult(objectList)
|
||||
val mapInstanceList = ArrayList<String>()
|
||||
mapInstanceList.add(MogoMap.DEFAULT)
|
||||
// if (FunctionBuildConfig.isDrawDecIdentifyData) {
|
||||
// mapInstanceList.add(MogoMap.SMALL_DES_MAP)
|
||||
// }
|
||||
if (FunctionBuildConfig.isDrawPreIdentifyData) {
|
||||
mapInstanceList.add(MogoMap.SMALL_PRED_MAP)
|
||||
}
|
||||
identify.renderAdasRegResults(objectList, mapInstanceList)
|
||||
startTime = System.nanoTime()
|
||||
|
||||
if (FunctionBuildConfig.isDrawDecIdentifyData) {
|
||||
desIdentify.renderAdasRegResult(objectList, MogoMap.SMALL_DES_MAP)
|
||||
desStartTime = System.nanoTime()
|
||||
}
|
||||
if (FunctionBuildConfig.isDrawPreIdentifyData) {
|
||||
preIdentify2.renderAdasRegResult(objectList, MogoMap.SMALL_PRED_MAP2)
|
||||
preIdentify3.renderAdasRegResult(objectList, MogoMap.SMALL_PRED_MAP3)
|
||||
preStartTime = System.nanoTime()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +133,7 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
MSG_DATA_PRE_TRACK -> {
|
||||
if (msg.obj is List<*>) {
|
||||
val objectList = msg.obj as List<Prediction2025.mPredictionObjectApp>
|
||||
preIdentify.renderPredictionResult(objectList, MogoMap.SMALL_PRED_MAP)
|
||||
// preIdentify.renderPredictionResult(objectList, MogoMap.SMALL_PRED_MAP)
|
||||
// preIdentify2.renderPredictionResult(objectList, MogoMap.SMALL_PRED_MAP2)
|
||||
// preIdentify3.renderPredictionResult(objectList, MogoMap.SMALL_PRED_MAP3)
|
||||
}
|
||||
@@ -163,7 +158,10 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
}
|
||||
|
||||
MSG_DATA_CLEAR -> {
|
||||
identify.clearOldMarker()
|
||||
val mapInstanceList = ArrayList<String>()
|
||||
mapInstanceList.add(MogoMap.DEFAULT)
|
||||
mapInstanceList.add(MogoMap.SMALL_PRED_MAP)
|
||||
identify.clearOldMarkers(mapInstanceList)
|
||||
}
|
||||
|
||||
MSG_DATA_AI_CLEAR -> {
|
||||
@@ -172,8 +170,8 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
|
||||
MSG_DATA_PRE_CLEAR -> {
|
||||
preIdentify.clearPredictionMarker(MogoMap.SMALL_PRED_MAP)
|
||||
preIdentify2.clearPredictionMarker(MogoMap.SMALL_PRED_MAP2)
|
||||
preIdentify3.clearPredictionMarker(MogoMap.SMALL_PRED_MAP3)
|
||||
// preIdentify2.clearPredictionMarker(MogoMap.SMALL_PRED_MAP2)
|
||||
// preIdentify3.clearPredictionMarker(MogoMap.SMALL_PRED_MAP3)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,49 @@ class IdentifyOriginDataDrawer : Identify {
|
||||
}
|
||||
}
|
||||
|
||||
override fun renderAdasRegResults(resultList: List<TrackedObject>?, mapObjList: List<String>) {
|
||||
if (resultList.isNullOrEmpty()) {
|
||||
clearOldMarker()
|
||||
return
|
||||
}
|
||||
if (!MogoStatusManager.getInstance().isVrMode) {
|
||||
clearOldMarker()
|
||||
return
|
||||
}
|
||||
|
||||
//清除缓存
|
||||
for (data in resultList) {
|
||||
if (trafficDataUuidList.size > 0 && trafficDataUuidList.contains(data.uuid.toString())) {
|
||||
if (TrackerSourceFilterHelper.filterData(data)) {
|
||||
continue
|
||||
}
|
||||
trafficDataUuidList.remove(data.uuid.toString())
|
||||
}
|
||||
}
|
||||
|
||||
//清除缓存,删除marker
|
||||
val it: MutableIterator<*> = trafficDataUuidList.iterator()
|
||||
while (it.hasNext()) {
|
||||
val key = it.next() as String
|
||||
it.remove()
|
||||
mMarkersCaches.remove(key)
|
||||
mapObjList.forEach {
|
||||
MogoIdentifyManager.getInstance()
|
||||
.removeMarker(key, it)
|
||||
}
|
||||
TrackerSourceFilterHelper.removeBottomMarker(key)
|
||||
}
|
||||
|
||||
val filterList = filterTrafficData(resultList)
|
||||
if (filterList.size > 0) {
|
||||
// 绘制新数据
|
||||
mapObjList.forEach {
|
||||
MogoIdentifyManager.getInstance()
|
||||
.updateBatchMarkerPosition(filterList, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据过滤器
|
||||
*
|
||||
@@ -169,4 +212,16 @@ class IdentifyOriginDataDrawer : Identify {
|
||||
WarningHelper.clear()
|
||||
}
|
||||
|
||||
override fun clearOldMarkers(mapObjList: List<String>) {
|
||||
for (uuid in trafficDataUuidList) {
|
||||
mapObjList.forEach {
|
||||
MogoIdentifyManager.getInstance()
|
||||
.removeMarker(uuid, it)
|
||||
}
|
||||
TrackerSourceFilterHelper.removeBottomMarker(uuid)
|
||||
}
|
||||
trafficDataUuidList.clear()
|
||||
mMarkersCaches.clear()
|
||||
WarningHelper.clear()
|
||||
}
|
||||
}
|
||||
@@ -48,8 +48,8 @@ class IdentifyPredictionDataDrawer : Identify {
|
||||
}
|
||||
//清除缓存
|
||||
for (data in predictionObjectList) {
|
||||
if (trafficDataUuidList.size > 0 && trafficDataUuidList.contains("" + data.mNid)) {
|
||||
trafficDataUuidList.remove("" + data.mNid)
|
||||
if (trafficDataUuidList.size > 0 && trafficDataUuidList.contains("${data.mNid-800000}")) {
|
||||
trafficDataUuidList.remove("${data.mNid-800000}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class IdentifyPredictionDataDrawer : Identify {
|
||||
mFilterTrafficData.clear()
|
||||
trafficDataUuidList.clear()
|
||||
for (data in trafficData) {
|
||||
val uuid = "" + data.mNid
|
||||
val uuid = "${data.mNid-800000}"
|
||||
mMarkersCaches[uuid] = data
|
||||
trafficDataUuidList.add(uuid)
|
||||
mFilterTrafficData[uuid] = data
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mogo.eagle.core.function.business.identify
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
@@ -9,11 +10,12 @@ import com.mogo.eagle.core.function.api.datacenter.obu.IMoGoObuStatusListener
|
||||
import com.mogo.eagle.core.function.business.routeoverlay.PredictionOverlayDrawer
|
||||
import com.mogo.eagle.core.function.business.routeoverlay.PredictionOverlayDrawer2
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84
|
||||
import com.mogo.eagle.core.function.call.obu.CallerObuWarningListenerManager
|
||||
import com.mogo.eagle.core.function.utils.LocationUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.map.MogoMap
|
||||
import com.mogo.map.identify.MogoIdentifyManager
|
||||
import com.mogo.map.utils.LocationUtils
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import mogo.yycp.api.proto.SocketDownData
|
||||
@@ -69,12 +71,15 @@ class MapIdentifySubscriber private constructor() : IMoGoSubscriber,
|
||||
private var carPoiList2: List<geometry.Geometry.Point>? = null
|
||||
private var location1: MogoLocation? = null
|
||||
private var location2: MogoLocation? = null
|
||||
private var probability1: Float = 0f
|
||||
private var probability2: Float = 0f
|
||||
|
||||
override fun onPredictionObstacleTrajectory(predictionObjects: Prediction2025.mPredictionObjects) {
|
||||
if (FunctionBuildConfig.isDrawPreIdentifyData) {
|
||||
try {
|
||||
ThreadUtils.getSinglePool().execute {
|
||||
// 渲染它车
|
||||
IdentifyFactory.renderPredictionResult(predictionObjects.objsAppList)
|
||||
// // 渲染它车
|
||||
// IdentifyFactory.renderPredictionResult(predictionObjects.objsAppList)
|
||||
// 渲染自车
|
||||
predictionObjects.objsAppList.forEach { preObj ->
|
||||
if (preObj.mNid == 800000L) {
|
||||
@@ -83,18 +88,22 @@ class MapIdentifySubscriber private constructor() : IMoGoSubscriber,
|
||||
carPoiList1 = preObj.predictionTrajectoryList[0].trajectoryPointsList
|
||||
carPoiList2 = preObj.predictionTrajectoryList[1].trajectoryPointsList
|
||||
val largeType: Int
|
||||
location1 = LocationUtils.generateLocation(carPoiList1!![0].x, carPoiList1!![0].y, carPoiList1!![1].x, carPoiList1!![1].y)
|
||||
location2 = LocationUtils.generateLocation(carPoiList2!![0].x, carPoiList2!![0].y, carPoiList2!![1].x, carPoiList2!![1].y)
|
||||
val heading = getChassisLocationWGS84().heading
|
||||
location1 = LocationUtils.generateLocation(carPoiList1!![0].x, carPoiList1!![0].y, heading)
|
||||
location2 = LocationUtils.generateLocation(carPoiList2!![0].x, carPoiList2!![0].y, heading)
|
||||
if (location1 == null || location2 == null) return@forEach
|
||||
if (preObj.predictionTrajectoryList[0].predictionProbability >= preObj.predictionTrajectoryList[1].predictionProbability) {
|
||||
probability1 = preObj.predictionTrajectoryList[0].predictionProbability
|
||||
probability2 = preObj.predictionTrajectoryList[1].predictionProbability
|
||||
CallerAutopilotIdentifyListenerManager.invokeProbabilityChanged(probability1, probability2)
|
||||
if (probability1 >= probability2) {
|
||||
MogoIdentifyManager.getInstance().updateGps(location1!!, MogoMap.SMALL_PRED_MAP)
|
||||
largeType = 2
|
||||
} else {
|
||||
MogoIdentifyManager.getInstance().updateGps(location2!!, MogoMap.SMALL_PRED_MAP)
|
||||
largeType = 3
|
||||
}
|
||||
PredictionOverlayDrawer.getInstance().drawPredictionList(carPoiList1, location1!!.heading, false, 2, largeType)
|
||||
PredictionOverlayDrawer2.getInstance().drawPredictionList(carPoiList2, location2!!.heading, false, 3, largeType)
|
||||
PredictionOverlayDrawer.getInstance().drawPredictionList(carPoiList1, heading, false, 2, largeType)
|
||||
PredictionOverlayDrawer2.getInstance().drawPredictionList(carPoiList2, heading, false, 3, largeType)
|
||||
MogoIdentifyManager.getInstance().updateGps(location1!!, MogoMap.SMALL_PRED_MAP2)
|
||||
MogoIdentifyManager.getInstance().updateGps(location2!!, MogoMap.SMALL_PRED_MAP3)
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ public class PredictionOverlayDrawer {
|
||||
|
||||
Polyline.Options.Builder builder;
|
||||
if (mPolylineOptions == null) {
|
||||
builder = new Polyline.Options.Builder("router_overlay", Level.GUIDE_ROUTE_LINE)
|
||||
builder = new Polyline.Options.Builder("prediction_overlay" + preViewType, Level.GUIDE_ROUTE_LINE)
|
||||
.setUseGps(true)
|
||||
.setWidth(20)
|
||||
.setIsGradient(true);
|
||||
@@ -280,9 +280,6 @@ public class PredictionOverlayDrawer {
|
||||
} else if (preViewType == 3) {
|
||||
overlayManager.showOrUpdateLine(options, SMALL_PRED_MAP3);
|
||||
}
|
||||
if (preViewType == largeType) {
|
||||
overlayManager.showOrUpdateLine(options, SMALL_PRED_MAP);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
isExcept = true;
|
||||
@@ -311,11 +308,10 @@ public class PredictionOverlayDrawer {
|
||||
}
|
||||
|
||||
private volatile RenderTask mPreRenderTask;
|
||||
private volatile RenderTask mPreRenderTask2;
|
||||
|
||||
public void drawPredictionList(List<geometry.Geometry.Point> dataList, double bearing, boolean hasGreenWave, int preType, int largeType) {
|
||||
IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(DEFAULT);
|
||||
double[] arr = null;
|
||||
double[] arr;
|
||||
if (mogoOverlayManager != null && iMogoMap != null) {
|
||||
if (mPreRenderTask == null) {
|
||||
mPreRenderTask = new RenderTask();
|
||||
@@ -335,28 +331,6 @@ public class PredictionOverlayDrawer {
|
||||
}
|
||||
}
|
||||
|
||||
public void drawPredictionList2(List<geometry.Geometry.Point> dataList, double bearing, boolean hasGreenWave, int preType, int largeType) {
|
||||
IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(DEFAULT);
|
||||
double[] arr = null;
|
||||
if (mogoOverlayManager != null) {
|
||||
if (mPreRenderTask2 == null) {
|
||||
mPreRenderTask2 = new RenderTask();
|
||||
}
|
||||
List<MogoLatLng> latLngList = new ArrayList<>();
|
||||
for (geometry.Geometry.Point point : dataList) {
|
||||
arr = iMogoMap.switchData(point.getX(), point.getY(), false);
|
||||
if (arr == null || arr.length < 2) continue;
|
||||
latLngList.add(new MogoLatLng(arr[0], arr[1]));
|
||||
}
|
||||
if (latLngList.isEmpty()) return;
|
||||
mPreRenderTask2.setPreData(latLngList, bearing, hasGreenWave, preType, largeType);
|
||||
if (mRenderHandler != null) {
|
||||
mRenderHandler.removeCallbacks(mPreRenderTask2);
|
||||
mRenderHandler.post(mPreRenderTask2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisible(boolean isVisible) {
|
||||
if (mogoOverlayManager != null) {
|
||||
if (isVisible) {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PredictionOverlayDrawer2 {
|
||||
mogoOverlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (mogoOverlayManager != null) {
|
||||
// 线条粗细,渐变,渐变色值
|
||||
HandlerThread renderTask = new HandlerThread("prediction_render") {
|
||||
HandlerThread renderTask = new HandlerThread("prediction_render2") {
|
||||
@Override
|
||||
protected void onLooperPrepared() {
|
||||
super.onLooperPrepared();
|
||||
@@ -232,7 +232,7 @@ public class PredictionOverlayDrawer2 {
|
||||
|
||||
Polyline.Options.Builder builder;
|
||||
if (mPolylineOptions == null) {
|
||||
builder = new Polyline.Options.Builder("router_overlay", Level.GUIDE_ROUTE_LINE)
|
||||
builder = new Polyline.Options.Builder("prediction_overlay" + preViewType, Level.GUIDE_ROUTE_LINE)
|
||||
.setUseGps(true)
|
||||
.setWidth(20)
|
||||
.setIsGradient(true);
|
||||
@@ -278,9 +278,6 @@ public class PredictionOverlayDrawer2 {
|
||||
} else if (preViewType == 3) {
|
||||
overlayManager.showOrUpdateLine(options, SMALL_PRED_MAP3);
|
||||
}
|
||||
if (preViewType == largeType) {
|
||||
overlayManager.showOrUpdateLine(options, SMALL_PRED_MAP);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
isExcept = true;
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.mogo.eagle.core.function.utils
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.map.MogoMap
|
||||
import com.mogo.map.MogoMap.Companion.mapInstance
|
||||
|
||||
object LocationUtils {
|
||||
/**
|
||||
* 必须先根据定位计算度带,即调用switchData(gnssInfo.longitude, gnssInfo.latitude, true)
|
||||
*/
|
||||
fun generateLocation(x: Double, y: Double, heading: Double): MogoLocation? {
|
||||
val mogoMap = mapInstance.getMogoMap(MogoMap.DEFAULT)
|
||||
if (mogoMap != null) {
|
||||
val lonLat = mogoMap.switchData(x, y, false)
|
||||
if (lonLat == null || lonLat.size < 2) return null
|
||||
val location = MogoLocation()
|
||||
location.longitude = lonLat[0]
|
||||
location.latitude = lonLat[1]
|
||||
location.heading = heading
|
||||
return location
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同上,必须先根据定位计算度带
|
||||
*/
|
||||
fun generateLocation(x: Double, y: Double, preX: Double, preY: Double): MogoLocation? {
|
||||
val mogoMap = mapInstance.getMogoMap(MogoMap.DEFAULT)
|
||||
if (mogoMap != null) {
|
||||
val lonLat = mogoMap.switchData(x, y, false)
|
||||
val preLonLat = mogoMap.switchData(preX, preY, false)
|
||||
if (lonLat == null || lonLat.size < 2 || preLonLat == null || preLonLat.size < 2) return null
|
||||
val location = MogoLocation()
|
||||
location.longitude = lonLat[0]
|
||||
location.latitude = lonLat[1]
|
||||
location.heading = DrivingDirectionUtils.getLineAngle(lonLat[0], lonLat[1], preLonLat[0], preLonLat[1])
|
||||
return location
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,41 @@
|
||||
package com.mogo.eagle.core.function.view
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
import com.mogo.eagle.core.function.map.R
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import kotlinx.android.synthetic.main.layout_decision_container.view.decMapView
|
||||
import kotlinx.android.synthetic.main.layout_decision_container.view.preDetailView2
|
||||
import kotlinx.android.synthetic.main.layout_decision_container.view.preDetailView3
|
||||
import kotlinx.android.synthetic.main.layout_decision_container.view.tvPre1
|
||||
import kotlinx.android.synthetic.main.layout_decision_container.view.tvPre2
|
||||
import kotlinx.android.synthetic.main.layout_decision_container.view.tvPre3
|
||||
|
||||
class DecisionLayout @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
) : ConstraintLayout(context, attrs) {
|
||||
) : ConstraintLayout(context, attrs), IMoGoAutopilotIdentifyListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "DecisionLayout"
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var lastTime = 0L
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.layout_decision_container, this, true)
|
||||
initView()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
|
||||
CallerAutopilotIdentifyListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -41,6 +56,30 @@ class DecisionLayout @JvmOverloads constructor(
|
||||
preDetailView3.onResume()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onPredictionProbabilityChanged(pro1: Float, pro2: Float) {
|
||||
if (System.currentTimeMillis() - lastTime >= 1000) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
val prob1: Int
|
||||
val prob2: Int
|
||||
val prob3: Int
|
||||
if (pro1 + pro2 < 50) {
|
||||
prob1= (pro1*100).toInt()
|
||||
prob3= (pro2*100).toInt()
|
||||
prob2 = 100 - prob1 - prob3
|
||||
} else {
|
||||
prob1 = 15 * (pro1 / (pro1 + pro2)).toInt()
|
||||
prob3 = 15 * (pro2 / (pro1 + pro2)).toInt()
|
||||
prob2 = 100 - prob1 - prob3
|
||||
}
|
||||
tvPre1.text = "${prob1}%"
|
||||
tvPre3.text = "${prob3}%"
|
||||
tvPre2.text = "${prob2}%"
|
||||
}
|
||||
lastTime = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
|
||||
fun onLowMemory() {
|
||||
decMapView.onLowMemory()
|
||||
preDetailView2.onLowMemory()
|
||||
|
||||
Reference in New Issue
Block a user