[8.0.0]
[fix] [三联屏和二联屏]
This commit is contained in:
@@ -3,12 +3,15 @@ package com.mogo.och.bridge
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OCHCOMMON
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.och.bridge.autopilot.location.OchLocationManager
|
||||
import com.mogo.och.bridge.distance.TrajectoryAndDistanceManager
|
||||
import com.mogo.och.bridge.bridge.OchBridgeManager
|
||||
import com.mogo.och.common.module.biz.birdge.BridgeService
|
||||
import com.mogo.och.common.module.biz.birdge.BridgeListener
|
||||
import com.mogo.och.common.module.constant.OchCommonConst
|
||||
|
||||
|
||||
@@ -16,12 +19,18 @@ import com.mogo.och.common.module.constant.OchCommonConst
|
||||
* eye 桥
|
||||
*/
|
||||
@Route(path = OchCommonConst.BIZ_Bridge)
|
||||
class BridgeProvider : BridgeService {
|
||||
class BridgeProvider : BridgeService, CallerBase<BridgeListener>() {
|
||||
|
||||
private var context: Context? = null
|
||||
|
||||
private val tag = M_OCHCOMMON + "BridgeProvider"
|
||||
|
||||
|
||||
override fun init(context: Context?) {
|
||||
this.context = context
|
||||
OchBridgeManager.load()
|
||||
}
|
||||
|
||||
override fun setDistanceStation(startLocation: MogoLocation?, endLocation: MogoLocation?, lineId: Long?) {
|
||||
CallerLogger.d(tag,"distance 设置起始站点的定位")
|
||||
TrajectoryAndDistanceManager.setStationPoint(startLocation,endLocation,lineId)
|
||||
@@ -38,9 +47,25 @@ class BridgeProvider : BridgeService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun init(context: Context?) {
|
||||
this.context = context
|
||||
override fun addBridgeListener(tag: String, listener: BridgeListener) {
|
||||
addListener(tag,listener)
|
||||
}
|
||||
|
||||
override fun removeBridgeListener(tag: String) {
|
||||
removeListener(tag)
|
||||
}
|
||||
|
||||
fun invokeTrajectoryHaveDataListener(haveTrajectoryInfos:Boolean){
|
||||
M_LISTENERS.forEach{
|
||||
it.value.onTrajectoryHaveData(haveTrajectoryInfos)
|
||||
}
|
||||
}
|
||||
|
||||
fun invokePredictionHavaData(havePredictionInfos: Boolean) {
|
||||
M_LISTENERS.forEach{
|
||||
it.value.onPredictionHavaData(havePredictionInfos)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.mogo.och.bridge
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OCHCOMMON
|
||||
import com.mogo.och.common.module.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.manager.loop.BizLoopManager
|
||||
import com.mogo.och.common.module.manager.loop.LoopInfo
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
object BridgeServiceManager {
|
||||
|
||||
private const val TAG = M_OCHCOMMON+"BridgeManager"
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private var bridgeService: BridgeProvider? =
|
||||
ARouter.getInstance().build(OchCommonConst.BIZ_Bridge).navigation() as BridgeProvider
|
||||
|
||||
private var trajectoryTime = 0L
|
||||
private var predictionTime = 0L
|
||||
|
||||
init {
|
||||
BizLoopManager.setLoopFunction(TAG,
|
||||
LoopInfo(2, ::checkTimeout, immediately = false, scheduler = Schedulers.io())
|
||||
)
|
||||
}
|
||||
|
||||
// 是否有车前引导线
|
||||
private var haveTrajectoryInfo: Boolean by Delegates.observable(false) { _, oldValue, newValue ->
|
||||
if (oldValue != newValue) {
|
||||
bridgeService?.invokeTrajectoryHaveDataListener(newValue)
|
||||
}
|
||||
trajectoryTime = System.currentTimeMillis()
|
||||
|
||||
}
|
||||
|
||||
// 是否有预测数据
|
||||
private var havePredictionInfo: Boolean by Delegates.observable(false) { _, oldValue, newValue ->
|
||||
if (oldValue != newValue) {
|
||||
bridgeService?.invokePredictionHavaData(newValue)
|
||||
}
|
||||
predictionTime = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
fun checkTimeout(){
|
||||
if(System.currentTimeMillis() - trajectoryTime>1_000){
|
||||
haveTrajectoryInfo = false
|
||||
}
|
||||
if(System.currentTimeMillis() - trajectoryTime>1_000){
|
||||
havePredictionInfo = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun invokePlanningListener(haveTrajectoryInfos:Boolean){
|
||||
this.haveTrajectoryInfo = haveTrajectoryInfos
|
||||
}
|
||||
|
||||
fun invokePredictionHaveData(havePredictionInfos:Boolean){
|
||||
this.havePredictionInfo = havePredictionInfos
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.mogo.och.bridge.bridge
|
||||
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningTrajectoryListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningTrajectoryListenerManager
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OCHCOMMON
|
||||
import com.mogo.och.bridge.BridgeServiceManager
|
||||
import prediction2025.Prediction2025
|
||||
import mogo.telematics.pad.MessagePad
|
||||
|
||||
object OchBridgeManager: CallerBase<IMoGoPlanningTrajectoryListener>(),
|
||||
IMoGoPlanningTrajectoryListener, IMoGoAutopilotIdentifyListener {
|
||||
private val TAG = "${M_OCHCOMMON}OchPlanningListenerManager"
|
||||
|
||||
fun load(){
|
||||
CallerPlanningTrajectoryListenerManager.addListener(TAG,this)
|
||||
CallerAutopilotIdentifyListenerManager.addListener(TAG,this)
|
||||
}
|
||||
|
||||
fun release(){
|
||||
CallerPlanningTrajectoryListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
/**
|
||||
* 引导线轨迹
|
||||
*/
|
||||
override fun onAutopilotTrajectory(trajectoryInfos: MutableList<MessagePad.TrajectoryPoint>) {
|
||||
if(trajectoryInfos.isEmpty()){
|
||||
BridgeServiceManager.invokePlanningListener(false)
|
||||
}else{
|
||||
BridgeServiceManager.invokePlanningListener(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPredictionObstacleTrajectory(predictionObjects: Prediction2025.mPredictionObjects) {
|
||||
if (predictionObjects.objsAppList==null||predictionObjects.objsAppCount<=0) {
|
||||
BridgeServiceManager.invokePredictionHaveData(false)
|
||||
}else{
|
||||
BridgeServiceManager.invokePredictionHaveData(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mogo.och.common.module.biz.birdge
|
||||
|
||||
interface BridgeListener {
|
||||
/**
|
||||
* 是否有引导线
|
||||
*/
|
||||
fun onTrajectoryHaveData(haveTrajectoryInfos: Boolean)
|
||||
|
||||
fun onPredictionHavaData(havePredictionInfos: Boolean)
|
||||
|
||||
}
|
||||
@@ -27,4 +27,12 @@ object BridgeManager {
|
||||
return bridgeService?.distance2Point(gcjLat,gcjLon)?:0f
|
||||
}
|
||||
|
||||
fun addBridgeListener(tag:String, listener: BridgeListener){
|
||||
bridgeService?.addBridgeListener(tag,listener)
|
||||
}
|
||||
|
||||
fun removeBridgeListener(tag: String){
|
||||
bridgeService?.removeBridgeListener(tag)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,4 +10,7 @@ interface BridgeService : IProvider {
|
||||
|
||||
fun distance2Point(gcjLat: Double, gcjLon: Double): Float
|
||||
|
||||
fun addBridgeListener(tag:String, listener:BridgeListener)
|
||||
|
||||
fun removeBridgeListener(tag: String)
|
||||
}
|
||||
@@ -9,8 +9,12 @@ import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
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.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.och.bridge.autopilot.location.OchLocationManager
|
||||
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.decContainer
|
||||
@@ -28,7 +32,7 @@ class HomeView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr){
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), HomeViewModel.HomeCallback {
|
||||
|
||||
|
||||
private var isAMapShow = true
|
||||
@@ -38,6 +42,9 @@ class HomeView @JvmOverloads constructor(
|
||||
|
||||
private var TAG = "HomeView"
|
||||
|
||||
private var viewModel: HomeViewModel?=null
|
||||
|
||||
|
||||
|
||||
private fun initView() {
|
||||
LayoutInflater.from(context).inflate(R.layout.taxi_p_home, this, true)
|
||||
@@ -49,10 +56,10 @@ class HomeView @JvmOverloads constructor(
|
||||
lbv_go2_center.setOrderIdCallback(object : LeftBarView.LeftBarCallback{
|
||||
override fun setGo2CenterClick() {
|
||||
//切换到地图中间
|
||||
// mapBizView.getUI()?.let {
|
||||
// val wgs02Location = OchLocationManager.getWgs02Location()
|
||||
// it.moveToCenter(MogoLatLng(wgs02Location.latitude,wgs02Location.longitude))
|
||||
// }
|
||||
hdMapView.getUI()?.let {
|
||||
val wgs02Location = OchLocationManager.getWgs02Location()
|
||||
it.moveToCenter(MogoLatLng(wgs02Location.latitude, wgs02Location.longitude))
|
||||
}
|
||||
//overMapView.displayCustomOverView()
|
||||
}
|
||||
|
||||
@@ -67,7 +74,7 @@ class HomeView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun showHdMap(){
|
||||
updateViewState(true,false,true)
|
||||
updateViewState(true,false,false)
|
||||
}
|
||||
|
||||
fun showAmapAndHdMap(){
|
||||
@@ -110,6 +117,14 @@ class HomeView @JvmOverloads constructor(
|
||||
decContainer.onDestroy()
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
viewModel = findViewTreeViewModelStoreOwner()?.let {
|
||||
ViewModelProvider(it).get(HomeViewModel::class.java)
|
||||
}
|
||||
viewModel?.setViewCallback(this)
|
||||
}
|
||||
|
||||
|
||||
private fun updateViewState(
|
||||
showHDMapView: Boolean,
|
||||
@@ -224,4 +239,12 @@ class HomeView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun showTwoScreen() {
|
||||
showHdMap()
|
||||
}
|
||||
|
||||
override fun showThreeScreen() {
|
||||
showAmapAndHdMap()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.mogo.och.unmanned.passenger.ui.homepage
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.mogo.och.common.module.biz.birdge.BridgeListener
|
||||
import com.mogo.och.common.module.biz.birdge.BridgeManager
|
||||
import com.mogo.och.common.module.manager.loop.BizLoopManager
|
||||
import com.mogo.och.data.taxi.BaseOrderBean
|
||||
import com.mogo.och.unmanned.taxi.utils.order.OrderListener
|
||||
import com.mogo.och.unmanned.taxi.utils.order.OrderModel
|
||||
|
||||
class HomeViewModel : ViewModel(), BridgeListener, OrderListener {
|
||||
|
||||
private val TAG = HomeViewModel::class.java.simpleName
|
||||
|
||||
private val orderShowEvaluate = "SHOWEVALUATE"
|
||||
|
||||
private var viewCallback: HomeCallback? = null
|
||||
|
||||
private var order:BaseOrderBean?=null
|
||||
private var haveTrajectoryInfos:Boolean = false
|
||||
private var havePredictionInfos:Boolean = false
|
||||
|
||||
fun setViewCallback(viewCallback: HomeCallback) {
|
||||
this.viewCallback = viewCallback
|
||||
BridgeManager.addBridgeListener(TAG,this)
|
||||
OrderModel.setOrderStatusCallback(TAG,this)
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
this.viewCallback = null
|
||||
BridgeManager.removeBridgeListener(TAG)
|
||||
}
|
||||
|
||||
interface HomeCallback {
|
||||
fun showTwoScreen()
|
||||
fun showThreeScreen()
|
||||
}
|
||||
|
||||
override fun onTrajectoryHaveData(haveTrajectoryInfos: Boolean) {
|
||||
this.haveTrajectoryInfos = haveTrajectoryInfos
|
||||
checkScreenChange()
|
||||
}
|
||||
|
||||
override fun onPredictionHavaData(havePredictionInfos: Boolean) {
|
||||
this.havePredictionInfos = havePredictionInfos
|
||||
checkScreenChange()
|
||||
}
|
||||
|
||||
override fun onCurrentOrderStatusChanged(order: BaseOrderBean?) {
|
||||
this.order = order
|
||||
checkScreenChange()
|
||||
}
|
||||
|
||||
fun checkScreenChange(){
|
||||
if(order!=null&&havePredictionInfos&&havePredictionInfos){
|
||||
// 展示三联屏
|
||||
BizLoopManager.runInMainThread{
|
||||
this.viewCallback?.showThreeScreen()
|
||||
}
|
||||
}else{
|
||||
// 展示二联屏幕
|
||||
BizLoopManager.runInMainThread{
|
||||
this.viewCallback?.showTwoScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user