From dc2dbf4ebd7749034df6cd12127374e4aeeef30f Mon Sep 17 00:00:00 2001 From: donghongyu Date: Tue, 10 Jan 2023 17:30:22 +0800 Subject: [PATCH 1/2] Rename .java to .kt Signed-off-by: donghongyu --- .../eagle/core/function/map/{MapFragment.java => MapFragment.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/{MapFragment.java => MapFragment.kt} (100%) diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt similarity index 100% rename from core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.java rename to core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt From 5a56e1ba5019be00fbe3bace9a8ea909a0b40dec Mon Sep 17 00:00:00 2001 From: donghongyu Date: Tue, 10 Jan 2023 17:30:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[dev=5Farch=5Fopt=5F3.0]=20[Change]=20[1?= =?UTF-8?q?=E3=80=81=E5=B0=86=E4=B8=8E=E9=AB=98=E7=B2=BE=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=9A=84=E8=BD=A6=E8=BE=86=E8=BD=AC=E5=90=91?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E5=88=B0=E5=9C=B0=E5=9B=BE=E5=B1=82=E7=AE=A1?= =?UTF-8?q?=E7=90=86]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donghongyu --- .../adapter/MoGoHandAdasMsgManager.java | 90 +--- .../receiver/BindingcarBroadcastReceiver.kt | 2 - .../core/function/hmi/ui/MoGoHmiFragment.kt | 29 - .../eagle/core/function/map/MapFragment.kt | 499 ++++++++++-------- .../IMoGoChassisLamplightListener.kt | 4 +- .../com/mogo/commons/mvp/BaseFragment.java | 6 - .../com/mogo/map/MogoMapUIController.java | 2 +- 7 files changed, 285 insertions(+), 347 deletions(-) diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoHandAdasMsgManager.java b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoHandAdasMsgManager.java index e2053a621e..aa4450a6b0 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoHandAdasMsgManager.java +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoHandAdasMsgManager.java @@ -1,36 +1,22 @@ package com.mogo.eagle.core.function.datacenter.autopilot.adapter; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_DEVA; - import android.content.Context; import android.text.TextUtils; import android.util.Log; -import androidx.annotation.Nullable; - import com.mogo.cloud.passport.MoGoAiCloudClientConfig; -import com.mogo.eagle.core.data.constants.MoGoConfig; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener; -import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssInfoListener; -import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager; import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager; -import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssInfoListenerManager; -import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager; import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager; -import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; -import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr; +import com.mogo.eagle.core.utilcode.util.UiThreadHandler; import org.jetbrains.annotations.NotNull; -import chassis.Chassis; import mogo.telematics.pad.MessagePad; public class MoGoHandAdasMsgManager implements - IMoGoAutopilotCarConfigListener, - IMoGoChassisGnssInfoListener, - IMoGoChassisLamplightListener { + IMoGoAutopilotCarConfigListener{ private final String TAG = "AdasEventManager"; @@ -39,8 +25,6 @@ public class MoGoHandAdasMsgManager implements private MoGoHandAdasMsgManager(Context context) { CallerAutopilotCarConfigListenerManager.INSTANCE.addListener(TAG, this); - CallerChassisGnssInfoListenerManager.INSTANCE.addListener(TAG, this); - CallerChassisLamplightListenerManager.INSTANCE.addListener(TAG, this); mContext = context; } @@ -55,13 +39,6 @@ public class MoGoHandAdasMsgManager implements return moGoHandAdasMsgManager; } - private int turnLightTimes = 0; - private boolean isOnTurnLight = false; - private int turnLight = 0; - private volatile boolean isShowTurnLight = false; - private int brakeLight = -1; - - public void getConfig() { com.elegant.utils.UiThreadHandler.postDelayed(new Runnable() { @Override @@ -71,51 +48,6 @@ public class MoGoHandAdasMsgManager implements }, 0); } - private int setTurnLightState(int turn_light) { - if (turn_light == 0) { - if (isOnTurnLight) { - if (turnLightTimes >= 10) { - isOnTurnLight = false; - turnLight = 0; - } - turnLightTimes++; - } - } else if (turn_light == 1) { - turnLightTimes = 0; - isOnTurnLight = true; - turnLight = 1; - } else if (turn_light == 2) { - turnLightTimes = 0; - isOnTurnLight = true; - turnLight = 2; - } - return turnLight; - } - - @Override - public void onAutopilotLightSwitchData(Chassis.LightSwitch lightSwitch) { - // TODO @李小鹏 这里需要修改为:由HMI 监听数据变换来更新UI,而不是由数据驱动UI - //can数据转发 转向灯状态 0是正常 1是左转 2是右转 -// if (!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //小巴不展示 - if (lightSwitch != null) { - int state = setTurnLightState(lightSwitch.getNumber()); - CallerLogger.INSTANCE.d(M_DEVA + "TurnLight", "---onAutopilotLightSwitchData ---state = " + state + "---lightSwitch.getNumber() = " + lightSwitch.getNumber()); - if (state == 1 || state == 2) { - isShowTurnLight = true; - CallerHmiManager.INSTANCE.showBrakeLight(0); - } else { - isShowTurnLight = false; - } - CallerHmiManager.INSTANCE.showTurnLight(state); - } -// } - - } - - @Override - public void onAutopilotBrakeLightData(boolean brakeLight) { - } - @Override public void onAutopilotCarConfig(@NotNull MessagePad.CarConfigResp carConfigResp) { if (carConfigResp != null && !TextUtils.isEmpty(carConfigResp.getMacAddress())) { @@ -124,23 +56,5 @@ public class MoGoHandAdasMsgManager implements } } - @Override - public void onAutopilotCarStateData(@Nullable MessagePad.GnssInfo gnssInfo) { - //根据加速度判断 是否刹车 -// if (!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //小巴不展示 - if (gnssInfo != null) { - //设置刹车信息 - if (gnssInfo.getAcceleration() < SharedPrefsMgr.getInstance(mContext).getFloat(MoGoConfig.BRAKE_ACCELERATION_THRESHOLD, -2.5F)) { - brakeLight = 1; - } else { - brakeLight = 0; - } - CallerLogger.INSTANCE.d(M_DEVA + "BrakeLight", "---onAutopilotLightSwitchData ---Acceleration = " + gnssInfo.getAcceleration() + "-- brakeLight = " + brakeLight); - if (!isShowTurnLight) { - CallerHmiManager.INSTANCE.showBrakeLight(brakeLight); - } -// } - } - } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/receiver/BindingcarBroadcastReceiver.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/receiver/BindingcarBroadcastReceiver.kt index 2a672a5411..235488a705 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/receiver/BindingcarBroadcastReceiver.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/receiver/BindingcarBroadcastReceiver.kt @@ -4,9 +4,7 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showBindingcarDialog -import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showBrakeLight import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showModifyBindingcarDialog -import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showTurnLight /** * 绑定车辆 diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt index 939a871dfd..00af87100b 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt @@ -1453,39 +1453,10 @@ class MoGoHmiFragment : MvpFragment(), } } - private var isBrake: Boolean = false - /** * 显示刹车效果 */ override fun showBrakeLight(light: Int) { - if (HmiBuildConfig.isShowBrakeLightView) { - ThreadUtils.runOnUiThread { - if (light == 1) { //刹车灯亮 - if (!isBrake) { - isBrake = true - CallerLogger.d( - "${SceneConstant.M_DEVA}${"BrakeLight"}", - " showBrakeLight light = 1 " - ) - CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(0, 500) - } - } else { - if (isBrake) {//默认 不亮灯 - isBrake = false - CallerLogger.d( - "${SceneConstant.M_DEVA}${"BrakeLight"}", - " showBrakeLight light != 1 " - ) - CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(3, 500) - } - } - -// brakeView?.let { -// brakeView.setBrakeLight(light) -// } - } - } } private var modifyBindingCarDialog: ModifyBindingCarDialog? = null diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt index ecf63b3f07..7423afe1ef 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt @@ -1,201 +1,214 @@ -package com.mogo.eagle.core.function.map; +package com.mogo.eagle.core.function.map -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_MAP; - -import android.content.Context; -import android.os.Bundle; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import com.alibaba.android.arouter.facade.annotation.Route; -import com.mogo.commons.mvp.MvpFragment; -import com.mogo.eagle.core.data.constants.MoGoFragmentPaths; -import com.mogo.eagle.core.data.map.CenterLine; -import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener; -import com.mogo.eagle.core.function.api.map.hd.IMoGoMapFragmentProvider; -import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener; -import com.mogo.eagle.core.function.business.MapPointCloudSubscriber; -import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber; -import com.mogo.eagle.core.function.business.routeoverlay.MogoRouteOverlayManager; -import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager; -import com.mogo.eagle.core.function.call.map.CallerHDMapManager; -import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager; -import com.mogo.eagle.core.function.overview.InfStructureManager; -import com.mogo.eagle.core.function.overview.ViewModelExtKt; -import com.mogo.eagle.core.function.overview.vm.OverViewModel; -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; -import com.mogo.eagle.core.utilcode.util.UiThreadHandler; -import com.mogo.map.IMogoMap; -import com.mogo.map.IMogoUiSettings; -import com.mogo.map.MogoMapView; -import com.mogo.map.uicontroller.IMogoMapUIController; -import com.zhidaoauto.map.sdk.open.MapAutoApi; -import com.zhidaoauto.map.sdk.open.business.PointCloudHelper; - -import mogo.telematics.pad.MessagePad; +import android.content.Context +import android.os.Bundle +import android.view.View +import chassis.Chassis +import com.alibaba.android.arouter.facade.annotation.Route +import com.mogo.commons.mvp.MvpFragment +import com.mogo.eagle.core.data.constants.MoGoConfig +import com.mogo.eagle.core.data.constants.MoGoFragmentPaths +import com.mogo.eagle.core.data.map.CenterLine +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssInfoListener +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener +import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener +import com.mogo.eagle.core.function.api.map.hd.IMoGoMapFragmentProvider +import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener +import com.mogo.eagle.core.function.business.MapPointCloudSubscriber +import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber +import com.mogo.eagle.core.function.business.routeoverlay.MogoRouteOverlayManager +import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssInfoListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager +import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showBrakeLight +import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showTurnLight +import com.mogo.eagle.core.function.call.map.CallerHDMapManager +import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager +import com.mogo.eagle.core.function.overview.InfStructureManager +import com.mogo.eagle.core.function.overview.InfStructureManager.savePlanningData +import com.mogo.eagle.core.function.overview.obtainViewModel +import com.mogo.eagle.core.function.overview.vm.OverViewModel +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.eagle.core.utilcode.util.Utils +import com.mogo.map.IMogoMap +import com.mogo.map.MogoMapView +import com.mogo.map.uicontroller.IMogoMapUIController +import com.zhidaoauto.map.sdk.open.MapAutoApi +import com.zhidaoauto.map.sdk.open.business.PointCloudHelper +import mogo.telematics.pad.MessagePad /** * @author donghongyu * @since 2021-11-09 * 高精度地图层UI - *

+ * + * * 地图图层,地图操作都在这个图层完成 */ @Route(path = MoGoFragmentPaths.PATH_FRAGMENT_MAP) -public class MapFragment extends MvpFragment - implements MapView, IMoGoMapFragmentProvider, IMoGoSkinModeChangeListener { +class MapFragment : MvpFragment(), + MapView, + IMoGoMapFragmentProvider, + IMoGoSkinModeChangeListener, + IMoGoChassisGnssInfoListener, + IMoGoPlanningRottingListener, + IMoGoChassisLamplightListener { - private static final String TAG = "MapFragment"; + private var mMogoMapView: MogoMapView? = null + private var mMogoMap: IMogoMap? = null + private val mIsControllerByOthersStatus = false - private MogoMapView mMogoMapView; - private IMogoMap mMogoMap; + companion object { + val functionName = "MapFragment" - private final boolean mIsControllerByOthersStatus = false; - - @Override - protected int getLayoutId() { - return R.layout.module_map_fragment_map; + /** + * sight mode + * + * @param mode + */ + const val SIGHT_MODE_NORMAL = 0 + const val SIGHT_MODE_TOP = 1 + const val SIGHT_MODE_BACK = 2 + const val SIGHT_MODE_CROSS = 3 + const val SIGHT_MODE_FAR = 4 } - @Override - public String getTagName() { - return TAG; + + override fun getLayoutId(): Int { + return R.layout.module_map_fragment_map } - @Override - protected void initViews() { + override fun getTagName(): String { + return Companion.functionName } - @Override - public void stepInVrMode(boolean isDayMode) { + override fun initViews() { + + } + + override fun stepInVrMode(isDayMode: Boolean) { try { - if (mMogoMapView != null - && mMogoMapView.getMap() != null - && mMogoMapView.getMap().getUIController() != null) { - mMogoMapView.getMap().getUIController().stepInVrMode(isDayMode); + if (mMogoMapView != null && mMogoMapView!!.map != null && mMogoMapView!!.map.uiController != null) { + mMogoMapView!!.map.uiController.stepInVrMode(isDayMode) } - } catch (Exception e) { - e.printStackTrace(); + } catch (e: Exception) { + e.printStackTrace() } } - @Override - public void init(Context context) { + override fun init(context: Context) { // do not implement } - @Override - protected void initViews(Bundle savedInstanceState) { - super.initViews(savedInstanceState); - mMogoMapView = findViewById(R.id.module_map_id_map); - mMogoMapView.onCreate(savedInstanceState); - mMogoMap = mMogoMapView.getMap(); + override fun initViews(savedInstanceState: Bundle?) { + super.initViews(savedInstanceState) + mMogoMapView = findViewById(R.id.module_map_id_map) + mMogoMapView!!.onCreate(savedInstanceState) + mMogoMap = mMogoMapView!!.map if (mMogoMap != null) { - mMogoMap.getUIController().showMyLocation(true); + mMogoMap!!.uiController.showMyLocation(true) } // 添加换肤监听 - CallerSkinModeListenerManager.INSTANCE.addListener(TAG, this); - CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener); + CallerSkinModeListenerManager.addListener(Companion.functionName, this) + CallerPlanningRottingListenerManager.addListener(Companion.functionName, this) + CallerChassisGnssInfoListenerManager.addListener(Companion.functionName, this) + CallerChassisLamplightListenerManager.addListener(Companion.functionName, this) } - @NonNull - @Override - protected MapPresenter createPresenter() { - return new MapPresenter(this); + override fun createPresenter(): MapPresenter { + return MapPresenter(this) } - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - initMapView(); - queryInfStructure(); + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + initMapView() + queryInfStructure() } - @Override - public void onSaveInstanceState(@NonNull Bundle outState) { - super.onSaveInstanceState(outState); + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) if (mMogoMapView != null) { - mMogoMapView.onSaveInstanceState(outState); + mMogoMapView!!.onSaveInstanceState(outState) } else { - CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null"); + e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null") } } - @Override - public void onPause() { - super.onPause(); + override fun onPause() { + super.onPause() if (mIsControllerByOthersStatus) { - return; + return } if (mMogoMapView != null) { - mMogoMapView.onPause(); + mMogoMapView!!.onPause() } else { - CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null"); + e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null") } } - @Override - public void onResume() { - super.onResume(); + override fun onResume() { + super.onResume() if (mIsControllerByOthersStatus) { - return; + return } if (mMogoMapView != null) { - mMogoMapView.onResume(); + mMogoMapView!!.onResume() } else { - CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null"); + e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null") } } - @Override - public void onLowMemory() { - super.onLowMemory(); + override fun onLowMemory() { + super.onLowMemory() if (mMogoMapView != null) { - mMogoMapView.onLowMemory(); + mMogoMapView!!.onLowMemory() } else { - CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null"); + e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null") } } - private void initMapView() { - mMogoMap = mMogoMapView.getMap(); + private fun initMapView() { + mMogoMap = mMogoMapView!!.map if (mMogoMap == null) { - return; + return } - IMogoUiSettings uiSettings = mMogoMap.getUiSettings(); + val uiSettings = mMogoMap!!.uiSettings if (uiSettings != null) { //设置所有手势是否可用 - uiSettings.setAllGesturesEnabled(true); + uiSettings.setAllGesturesEnabled(true) //设置指南针是否可见。 - uiSettings.setCompassEnabled(false); + uiSettings.setCompassEnabled(false) //设置室内地图楼层切换控件是否可见。 - uiSettings.setIndoorSwitchEnabled(true); + uiSettings.setIndoorSwitchEnabled(true) //设置定位按钮是否可见。 - uiSettings.setMyLocationButtonEnabled(false); + uiSettings.setMyLocationButtonEnabled(false) //设置旋转手势是否可用。 - uiSettings.setRotateGesturesEnabled(false); + uiSettings.setRotateGesturesEnabled(false) //设置比例尺控件是否可见 - uiSettings.setScaleControlsEnabled(true); + uiSettings.setScaleControlsEnabled(true) //设置拖拽手势是否可用。 - uiSettings.setScrollGesturesEnabled(true); + uiSettings.setScrollGesturesEnabled(true) //设置倾斜手势是否可用。 - uiSettings.setTiltGesturesEnabled(true); + uiSettings.setTiltGesturesEnabled(true) //设置缩放按钮是否可见。 - uiSettings.setZoomControlsEnabled(false); + uiSettings.setZoomControlsEnabled(false) //设置双指缩放手势是否可用。 - uiSettings.setZoomGesturesEnabled(true); + uiSettings.setZoomGesturesEnabled(true) } // TODO 临时初始化地图监听工控机、OBU等数据监听器,用于感知元素绘制 - MapIdentifySubscriber.Companion.getInstance(); - MogoRouteOverlayManager.getInstance().init(); - MapPointCloudSubscriber.Companion.getInstance(); + MapIdentifySubscriber.instance + MogoRouteOverlayManager.getInstance().init() + MapPointCloudSubscriber.instance } - private void queryInfStructure() { - OverViewModel viewModel = ViewModelExtKt.obtainViewModel(this, OverViewModel.class); -// viewModel.getInfStructures().observe(this.getViewLifecycleOwner(), infrastructures -> { + private fun queryInfStructure() { + val viewModel = this.obtainViewModel(OverViewModel::class.java) + // viewModel.getInfStructures().observe(this.getViewLifecycleOwner(), infrastructures -> { // if (isFirst) { // for (Infrastructure entity : infrastructures) { // Double lat = Double.parseDouble(entity.getLat()); @@ -209,151 +222,199 @@ public class MapFragment extends MvpFragment // isFirst = false; // } // }); + viewModel.infStructuresMap.observe(this.viewLifecycleOwner) { t -> InfStructureManager.saveData(t) } - viewModel.getInfStructuresMap().observe(this.getViewLifecycleOwner(), InfStructureManager.INSTANCE::saveData); - viewModel.fetchInfStructures(); + viewModel.fetchInfStructures() } - private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener() { - - @Override - public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp globalPathResp) { - UiThreadHandler.post(() -> { - InfStructureManager.INSTANCE.savePlanningData(globalPathResp.getWayPointsList()); - }); - } - - }; - - @Override - public IMogoMapUIController getUIController() { - return mMogoMap.getUIController(); + override fun getUIController(): IMogoMapUIController { + return mMogoMap!!.uiController } - @Override - public void onDestroyView() { - CallerSkinModeListenerManager.INSTANCE.removeListener(TAG); - CallerPlanningRottingListenerManager.INSTANCE.removeListener(TAG); + override fun onDestroyView() { + CallerSkinModeListenerManager.removeListener(Companion.functionName) + CallerPlanningRottingListenerManager.removeListener(Companion.functionName) + CallerChassisGnssInfoListenerManager.removeListener(Companion.functionName) + CallerChassisLamplightListenerManager.removeListener(Companion.functionName) + if (mMogoMapView != null) { - mMogoMapView.onDestroy(); - mMogoMapView = null; - mMogoMap = null; + mMogoMapView!!.onDestroy() + mMogoMapView = null + mMogoMap = null } else { - CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null"); + e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null") } - super.onDestroyView(); + super.onDestroyView() } - @NonNull - @Override - public String getFunctionName() { - return TAG; - } - - @Override - public void changeMaoViewAngle(int type) { - if (mMogoMapView != null && mMogoMapView.getMap() != null && mMogoMapView.getMap().getUIController() != null) { - mMogoMapView.getMap().getUIController().changeMapViewAngle(type); + override fun changeMaoViewAngle(type: Int) { + if (mMogoMapView != null && mMogoMapView!!.map != null && mMogoMapView!!.map.uiController != null) { + mMogoMapView!!.map.uiController.changeMapViewAngle(type) } else { - CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null"); + e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null") } } - @Override - public void changeCurrentIcon(int iconId) { - if (mMogoMapView != null && mMogoMapView.getMap() != null && mMogoMapView.getMap().getUIController() != null) { - mMogoMapView.getMap().getUIController().changeCurrentIcon(iconId); + override fun changeCurrentIcon(iconId: Int) { + if (mMogoMapView != null && mMogoMapView!!.map != null && mMogoMapView!!.map.uiController != null) { + mMogoMapView!!.map.uiController.changeCurrentIcon(iconId) } else { - CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null"); + e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null") } } - /** - * sight mode - * - * @param mode - */ - public static final int SIGHT_MODE_NORMAL = 0; - public static final int SIGHT_MODE_TOP = 1; - public static final int SIGHT_MODE_BACK = 2; - public static final int SIGHT_MODE_CROSS = 3; - public static final int SIGHT_MODE_FAR = 4; - - @Override - public void setMapDAngle(int mode) { - float angle = getSightModeAngle(mode); - if (mMogoMapView != null && mMogoMapView.getMap() != null && mMogoMapView.getMap().getUIController() != null) { - mMogoMapView.getMap().getUIController().setMapDAngle(angle); + override fun setMapDAngle(mode: Int) { + val angle = getSightModeAngle(mode) + if (mMogoMapView != null && mMogoMapView!!.map != null && mMogoMapView!!.map.uiController != null) { + mMogoMapView!!.map.uiController.setMapDAngle(angle) } else { - CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null"); + e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null") } } - private float getSightModeAngle(int mode) { - float angle = 0.0f; - switch (mode) { - case SIGHT_MODE_NORMAL: - angle = 16.5f; - case SIGHT_MODE_TOP: - angle = 16.5f; - case SIGHT_MODE_BACK: - angle = 16.5f; - case SIGHT_MODE_CROSS: - angle = 16.5f; - case SIGHT_MODE_FAR: - angle = 16.5f; + private fun getSightModeAngle(mode: Int): Float { + var angle = 0.0f + when (mode) { + SIGHT_MODE_NORMAL -> { + angle = 16.5f + angle = 16.5f + angle = 16.5f + angle = 16.5f + angle = 16.5f + } + SIGHT_MODE_TOP -> { + angle = 16.5f + angle = 16.5f + angle = 16.5f + angle = 16.5f + } + SIGHT_MODE_BACK -> { + angle = 16.5f + angle = 16.5f + angle = 16.5f + } + SIGHT_MODE_CROSS -> { + angle = 16.5f + angle = 16.5f + } + SIGHT_MODE_FAR -> angle = 16.5f } - return angle; + return angle } - @Nullable - @Override - public CenterLine getCenterLineInfo(double lon, double lat, float angle) { - if (mMogoMapView != null && mMogoMapView.getMap() != null && mMogoMapView.getMap().getUIController() != null) { - return mMogoMapView.getMap().getUIController().getCenterLineInfo(lon, lat, angle); + override fun getCenterLineInfo(lon: Double, lat: Double, angle: Float): CenterLine? { + return if (mMogoMapView != null && mMogoMapView!!.map != null && mMogoMapView!!.map.uiController != null) { + mMogoMapView!!.map.uiController.getCenterLineInfo(lon, lat, angle) } else { - CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null"); - return null; //上层使用应该判空 + e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null") + null //上层使用应该判空 } } - @Override - public void onSkinModeChange(int skinMode) { + override fun onSkinModeChange(skinMode: Int) { if (skinMode == 0) { - CallerHDMapManager.INSTANCE.stepInVrMode(false); + CallerHDMapManager.stepInVrMode(false) } else if (skinMode == 1) { - CallerHDMapManager.INSTANCE.stepInVrMode(true); + CallerHDMapManager.stepInVrMode(true) } } - @Override - public void setPointCloudSize(float pointCloudSize) { + override fun setPointCloudSize(pointCloudSize: Float) { //设置点云大小 - PointCloudHelper.INSTANCE.setPointCloudSize(pointCloudSize); + PointCloudHelper.setPointCloudSize(pointCloudSize) } - @Override - public void setPointCloudColor(@NonNull String color) { + override fun setPointCloudColor(color: String) { // 设置点云颜色 - PointCloudHelper.INSTANCE.setPointCloudColor(color); + PointCloudHelper.setPointCloudColor(color) } - @Override - public void setIsDrawPointCloud(boolean isDrawPointCloud) { + override fun setIsDrawPointCloud(isDrawPointCloud: Boolean) { try { // 是否绘制点云 - PointCloudHelper.INSTANCE.setIsDrawPointCloud(isDrawPointCloud); - } catch (Exception e) { - e.printStackTrace(); + PointCloudHelper.setIsDrawPointCloud(isDrawPointCloud) + } catch (e: Exception) { + e.printStackTrace() } } /** * 设置地图是否是Debug模式 + * * @param debugMode 是否开启Debug模式 */ - @Override - public void setDebugMode(boolean debugMode) { - MapAutoApi.INSTANCE.setDebugMode(debugMode); + override fun setDebugMode(debugMode: Boolean) { + MapAutoApi.setDebugMode(debugMode) } -} + + override val functionName: String + get() = functionName + + override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) { + UiThreadHandler.post { savePlanningData(globalPathResp!!.wayPointsList) } + } + + private var turnLightTimes = 0 + private var isOnTurnLight = false + private var turnLight = 0 + + private var isShowTurnLight = false + private var brakeLight = -1 + + override fun onAutopilotCarStateData(gnssInfo: MessagePad.GnssInfo?) { + if (gnssInfo != null) { + //设置刹车信息 + if (gnssInfo.acceleration < SharedPrefsMgr.getInstance(Utils.getApp()).getFloat(MoGoConfig.BRAKE_ACCELERATION_THRESHOLD, -2.5f)) { + brakeLight = 1 + } else { + brakeLight = 0 + } + d(SceneConstant.M_DEVA + "BrakeLight", "---onAutopilotLightSwitchData ---Acceleration = " + gnssInfo.acceleration + "-- brakeLight = " + brakeLight) + if (!isShowTurnLight) { + showBrakeLight(brakeLight) + } + } + } + + override fun onAutopilotLightSwitchData(lightSwitch: Chassis.LightSwitch?) { + //can数据转发 转向灯状态 0是正常 1是左转 2是右转 + if (lightSwitch != null) { + val state: Int = setTurnLightState(lightSwitch.number) + d(SceneConstant.M_DEVA + "TurnLight", "---onAutopilotLightSwitchData ---state = " + state + "---lightSwitch.getNumber() = " + lightSwitch.number) + if (state == 1 || state == 2) { + isShowTurnLight = true + showBrakeLight(0) + } else { + isShowTurnLight = false + } + showTurnLight(state) + } + } + + override fun onAutopilotBrakeLightData(brakeLight: Boolean) { + d(SceneConstant.M_DEVA + "TurnLight", "---onAutopilotBrakeLightData ---brakeLight = $brakeLight") + + } + + private fun setTurnLightState(turn_light: Int): Int { + if (turn_light == 0) { + if (isOnTurnLight) { + if (turnLightTimes >= 10) { + isOnTurnLight = false + turnLight = 0 + } + turnLightTimes++ + } + } else if (turn_light == 1) { + turnLightTimes = 0 + isOnTurnLight = true + turnLight = 1 + } else if (turn_light == 2) { + turnLightTimes = 0 + isOnTurnLight = true + turnLight = 2 + } + return turnLight + } + +} \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLamplightListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLamplightListener.kt index 8e9ec25a58..77731e7d1e 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLamplightListener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLamplightListener.kt @@ -11,12 +11,12 @@ interface IMoGoChassisLamplightListener { * 车辆转向灯 数据 * @param lightSwitch */ - fun onAutopilotLightSwitchData(lightSwitch: Chassis.LightSwitch?){} + fun onAutopilotLightSwitchData(lightSwitch: Chassis.LightSwitch?) /** * 车辆刹车灯 数据 * @param brakeLight */ - fun onAutopilotBrakeLightData(brakeLight: Boolean){} + fun onAutopilotBrakeLightData(brakeLight: Boolean) } \ No newline at end of file diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/BaseFragment.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/BaseFragment.java index 6cb9bcf968..2a0e396bf0 100644 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/BaseFragment.java +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/BaseFragment.java @@ -41,12 +41,6 @@ public abstract class BaseFragment extends Fragment { @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - } - - - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); initViews(); initViews(savedInstanceState); } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java index a5d21cb604..59f027a55e 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java @@ -24,7 +24,7 @@ import mogo.telematics.pad.MessagePad; * @author congtaowang * @since 2019-12-26 *

- * 描述 + * 地图控制 */ public class MogoMapUIController implements IMogoMapUIController {