[8.0.0][Fix]解决地图不渲染前车引导线的问题

This commit is contained in:
chenfufeng
2025-05-20 10:31:48 +08:00
parent 86798e322f
commit 8d762c3178
3 changed files with 44 additions and 139 deletions

View File

@@ -12,24 +12,20 @@ import androidx.constraintlayout.widget.Guideline
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.findViewTreeViewModelStoreOwner
import com.mogo.eagle.core.data.map.MogoLatLng
import com.mogo.eagle.core.function.view.DecisionLayout
import com.mogo.eagle.core.function.view.PredictionLayout
import com.mogo.eagle.core.utilcode.kotlin.onClick
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.och.bridge.autopilot.location.OchLocationManager
import com.mogo.och.common.module.utils.RxUtils
import com.mogo.och.unmanned.passenger.ui.bar.LeftBarView
import com.mogo.och.unmanned.taxi.passenger.R
import kotlinx.android.synthetic.main.taxi_p_home.view.acbtn_show_all
import kotlinx.android.synthetic.main.taxi_p_home.view.acbtn_show_hdmap_create
import kotlinx.android.synthetic.main.taxi_p_home.view.acbtn_show_hdmap_destory
import kotlinx.android.synthetic.main.taxi_p_home.view.acbtn_show_hdmap
import kotlinx.android.synthetic.main.taxi_p_home.view.decContainer
import kotlinx.android.synthetic.main.taxi_p_home.view.hdMapView
import kotlinx.android.synthetic.main.taxi_p_home.view.preContainer
import kotlinx.android.synthetic.main.taxi_p_home.view.lbv_go2_center
import kotlinx.android.synthetic.main.taxi_p_home.view.leftEndGuideline
import kotlinx.android.synthetic.main.taxi_p_home.view.midContainer
import kotlinx.android.synthetic.main.taxi_p_home.view.midStartGuideline
import kotlinx.android.synthetic.main.taxi_p_home.view.preContainer
class HomeView @JvmOverloads constructor(
context: Context,
@@ -47,9 +43,6 @@ class HomeView @JvmOverloads constructor(
private var viewModel: HomeViewModel?=null
private var predictionLayout: PredictionLayout? = null
private var decisionLayout: DecisionLayout? = null
private fun initView() {
@@ -61,21 +54,18 @@ class HomeView @JvmOverloads constructor(
private fun initlistener() {
lbv_go2_center.setOrderIdCallback(object : LeftBarView.LeftBarCallback{
override fun setGo2CenterClick() {
//切换到地图中间
//切换到地图中间
hdMapView.getUI()?.let {
val wgs02Location = OchLocationManager.getWgs02Location()
it.moveToCenter(MogoLatLng(wgs02Location.latitude, wgs02Location.longitude))
}
//overMapView.displayCustomOverView()
//overMapView.displayCustomOverView()
}
})
acbtn_show_hdmap_create.onClick {
showHdMap(false)
}
acbtn_show_hdmap_destory.onClick {
showHdMap(true)
acbtn_show_hdmap.onClick {
showHdMap()
}
acbtn_show_all.onClick {
showAmapAndHdMap()
@@ -86,82 +76,51 @@ class HomeView @JvmOverloads constructor(
/**
* 展示两屏幕
*/
fun showHdMap(destoryMap: Boolean){
CallerLogger.d(TAG,"展示高德 不展示高精")
if(destoryMap){
leftEndGuideline.setGuidelinePercent(0.666f)
lbv_go2_center.visibility = VISIBLE
midContainer.visibility = GONE
destoryMaps()
}else{
if(predictionLayout==null||decisionLayout==null){
createMaps()
leftEndGuideline.setGuidelinePercent(0.666f)
lbv_go2_center.visibility = VISIBLE
midContainer.visibility = GONE
}else {
leftEndGuideline.setGuidelinePercent(0.666f)
lbv_go2_center.visibility = VISIBLE
midContainer.visibility = GONE
}
}
fun showHdMap(){
updateViewState(true,false,false)
}
/**
* 展示3屏
*/
fun showAmapAndHdMap(){
// 展示预测地图和高精地图
CallerLogger.d(TAG,"展示高德地图和高精地图")
if(predictionLayout==null||decisionLayout==null){
createMaps()
midStartGuideline.setGuidelinePercent(0.333f)
leftEndGuideline.setGuidelinePercent(0.333f)
lbv_go2_center.visibility = GONE
midContainer.visibility = VISIBLE
}else {
midStartGuideline.setGuidelinePercent(0.333f)
leftEndGuideline.setGuidelinePercent(0.333f)
lbv_go2_center.visibility = GONE
midContainer.visibility = VISIBLE
}
updateViewState(true,true,false)
}
fun onCreate(savedInstanceState: Bundle?) {
hdMapView.onCreate(savedInstanceState)
predictionLayout?.onCreate(savedInstanceState)
decisionLayout?.onCreate(savedInstanceState)
preContainer.onCreate(savedInstanceState)
decContainer.onCreate(savedInstanceState)
}
fun onSaveInstanceState(outState: Bundle) {
hdMapView.onSaveInstanceState(outState)
predictionLayout?.onSaveInstanceState(outState)
decisionLayout?.onSaveInstanceState(outState)
preContainer.onSaveInstanceState(outState)
decContainer.onSaveInstanceState(outState)
}
fun onResume() {
hdMapView.onResume()
predictionLayout?.onResume()
decisionLayout?.onResume()
preContainer.onResume()
decContainer.onResume()
}
fun onLowMemory() {
hdMapView.onLowMemory()
predictionLayout?.onLowMemory()
decisionLayout?.onLowMemory()
preContainer.onLowMemory()
decContainer.onLowMemory()
}
fun onPause() {
hdMapView.onPause()
predictionLayout?.onPause()
decisionLayout?.onPause()
preContainer.onPause()
decContainer.onPause()
}
fun onDestroy() {
hdMapView.onDestroy()
predictionLayout?.onDestroy()
decisionLayout?.onDestroy()
preContainer.onDestroy()
decContainer.onDestroy()
}
override fun onAttachedToWindow() {
@@ -290,40 +249,12 @@ class HomeView @JvmOverloads constructor(
}
}
override fun showTwoScreen(destoryMap:Boolean) {
showHdMap(destoryMap)
override fun showTwoScreen() {
showHdMap()
}
override fun showThreeScreen() {
showAmapAndHdMap()
}
private fun createMaps(){
if(predictionLayout == null){
predictionLayout = PredictionLayout(context)
predictionLayout?.id = R.id.prediction_layout_id
preContainer.addView(predictionLayout)
predictionLayout?.onCreate(null)
predictionLayout?.onResume()
}
if(decisionLayout == null){
decisionLayout = DecisionLayout(context)
decisionLayout?.id = R.id.decision_layout_id
decContainer.addView(decisionLayout)
decisionLayout?.onCreate(null)
decisionLayout?.onResume()
}
}
private fun destoryMaps() {
predictionLayout?.onDestroy()
decisionLayout?.onDestroy()
RxUtils.createSubscribe(50) {
preContainer.removeView(predictionLayout)
decContainer.removeView(decisionLayout)
predictionLayout = null
decisionLayout = null
}
}
}

View File

@@ -35,7 +35,7 @@ class HomeViewModel : ViewModel(), BridgeListener, OrderListener {
}
interface HomeCallback {
fun showTwoScreen(destoryMap:Boolean)
fun showTwoScreen()
fun showThreeScreen()
}
@@ -56,31 +56,19 @@ class HomeViewModel : ViewModel(), BridgeListener, OrderListener {
fun checkScreenChange(){
CallerLogger.d(TAG,"havePredictionInfos:${havePredictionInfos}--haveTrajectoryInfos:${haveTrajectoryInfos}--order:${order}")
if(order==null){
// 进入双屏 需要销毁创建4张地图
if(order!=null&&havePredictionInfos&&havePredictionInfos){
FunctionBuildConfig.isDrawDecIdentifyData = true
FunctionBuildConfig.isDrawPreIdentifyData = true
// 展示三联屏
BizLoopManager.runInMainThread{
this.viewCallback?.showThreeScreen()
}
}else{
FunctionBuildConfig.isDrawDecIdentifyData = false
FunctionBuildConfig.isDrawPreIdentifyData = false
// 展示二联屏幕
BizLoopManager.runInMainThread{
this.viewCallback?.showTwoScreen(true)
}
}else{
if(havePredictionInfos&&haveTrajectoryInfos){
// 进入三屏幕
FunctionBuildConfig.isDrawDecIdentifyData = true
FunctionBuildConfig.isDrawPreIdentifyData = true
// 展示三联屏
BizLoopManager.runInMainThread{
this.viewCallback?.showThreeScreen()
}
}else{
// 进入双屏 需要隐藏
FunctionBuildConfig.isDrawDecIdentifyData = false
FunctionBuildConfig.isDrawPreIdentifyData = false
BizLoopManager.runInMainThread{
this.viewCallback?.showTwoScreen(false)
}
this.viewCallback?.showTwoScreen()
}
}
}

View File

@@ -34,25 +34,25 @@
app:layout_constraintStart_toEndOf="@+id/midStartGuideline"
app:layout_constraintEnd_toStartOf="@id/rightStartGuideline">
<FrameLayout
<com.mogo.eagle.core.function.view.PredictionLayout
android:id="@+id/preContainer"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:background="@drawable/taxi_p_home_middle_top_bg"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_676"/>
android:layout_height="@dimen/dp_676" />
<FrameLayout
<com.mogo.eagle.core.function.view.DecisionLayout
android:id="@+id/decContainer"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:background="@drawable/taxi_p_home_middle_bottom_bg"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_676"/>
android:layout_height="@dimen/dp_676"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -148,33 +148,19 @@
<androidx.appcompat.widget.AppCompatButton
android:elevation="6dp"
android:id="@+id/acbtn_show_hdmap_create"
android:text="展示二屏幕_创建view"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<androidx.appcompat.widget.AppCompatButton
android:elevation="6dp"
android:id="@+id/acbtn_show_hdmap_destory"
app:layout_constraintTop_toBottomOf="@+id/acbtn_show_hdmap_create"
app:layout_constraintStart_toStartOf="parent"
android:text="展示二屏幕_删除view"
android:id="@+id/acbtn_show_hdmap"
android:text="展示高精"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<androidx.appcompat.widget.AppCompatButton
app:layout_constraintTop_toBottomOf="@+id/acbtn_show_hdmap"
android:id="@+id/acbtn_show_all"
app:layout_constraintTop_toBottomOf="@+id/acbtn_show_hdmap_destory"
app:layout_constraintStart_toStartOf="parent"
android:elevation="6dp"
android:text="都展示"
android:visibility="gone"
android:text="展示三屏幕"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</merge>