diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java index 7ddfb2df9f..f28068397c 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/model/BusPassengerModel.java @@ -157,6 +157,7 @@ public class BusPassengerModel { BusPassengerStation station = stations.get(i); if (station.getDrivingStatus() == STATION_STATUS_STOPPED && station.isLeaving() && i+1 < stations.size()){ mRouteLineInfoCallback.updateStationsInfo(stations,i+1,false); + mTwoStationsRouts.clear(); if(mNextStationIndex != i+1){ startRemainRouteInfo(); } @@ -299,6 +300,8 @@ public class BusPassengerModel { } }; + private volatile int mPreAutoStatus = -1; + private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener(){ @Override @@ -314,17 +317,27 @@ public class BusPassengerModel { @Override public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) { -// if (autopilotStatusInfo == null) return; -// int state = autopilotStatusInfo.getState(); -// CallerLogger.INSTANCE.d( M_BUS_P + TAG, "state = %s", state ); -// if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { -// //2022.7.20 自动驾驶更换成带档位的 -//// if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotRunning(); -// } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) { -//// if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotEnable(); -// } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) { -//// if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotDisable(); -// } + if (autopilotStatusInfo == null) return; + int state = autopilotStatusInfo.getState(); + if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + //2022.7.20 自动驾驶更换成带档位的 +// if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotRunning(); + } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) { + if(state != mPreAutoStatus){ + mTwoStationsRouts.clear(); + } +// if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotEnable(); + } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) { + if(state != mPreAutoStatus){ + mTwoStationsRouts.clear(); + } +// if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotDisable(); + }else if (state == IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING){ + if(state != mPreAutoStatus){ + mTwoStationsRouts.clear(); + } + } + mPreAutoStatus = state; } @Override diff --git a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java index e139ae3dff..b855057746 100644 --- a/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java +++ b/OCH/mogo-och-bus-passenger/src/main/java/com/mogo/och/bus/passenger/presenter/BaseBusPassengerPresenter.java @@ -82,7 +82,7 @@ public class BaseBusPassengerPresenter extends Presenter? = null - - private var anchor: WeakReference? = null private var hasInit = false - private var oldX = 0 - private var oldY = 0 + private val listeners by lazy { CopyOnWriteArrayList() } + private val listener = object : IMoGoAutopilotStatusListener { override fun onAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?) { @@ -93,7 +87,7 @@ object StatusManager { } } - fun init(ctx: Context, anchor: View) { + fun init(ctx: Context) { if (hasInit) { return } @@ -110,26 +104,6 @@ object StatusManager { } } }) - context = WeakReference(ctx) - anchor.viewTreeObserver.addOnGlobalLayoutListener { - anchor.getLocationInWindow(IntArray(2).also { - val currentX = it[0] - val currentY = it[1] - var changed = false - if (oldX != currentX) { - oldX = currentX - changed = true - } - if (oldY != currentY) { - changed = true - oldY = currentY - } - if (changed && pop?.isShowing == true) { - pop?.update(getOffsetX(currentX), currentY + 130.PX, -1, -1) - } - }) - } - this.anchor = WeakReference(anchor) } private fun onCreate(ctx: Context) { @@ -153,35 +127,42 @@ object StatusManager { model.update(it) } } + f.onCreate() } - } - fun show() { - val anchor = this.anchor?.get() ?: return - context?.get()?.also { ctx -> - pop?.takeIf { it.isShowing }?.dismiss() - val content = StatusView(model, ctx) - content.doOnAttach { - for (f in flows) { - f.onCreate() - } - } - val out = IntArray(2) - anchor.getLocationInWindow(out) - ctx.normalPop(content, width = LayoutParams.WRAP_CONTENT, height = LayoutParams.WRAP_CONTENT, gravity = Gravity.END or Gravity.TOP, startX = getOffsetX(out[0]), startY = out[1] + 130.PX , isFocusable = false)?.also { - pop = it + model.status.observe(ctx.lifeCycleOwner) { + listeners.forEach { itx -> + itx.onStatusChanged(it.second, it.first != null) } } } - private fun getOffsetX(anchorX: Int): Int { - return ScreenUtils.getScreenWidth() - anchorX + 40.PX + + fun registerListener(listener: IStatusListener) { + listeners.add(listener) } - fun hide() { - pop?.takeIf { it.isShowing }?.dismiss() + + fun unRegisterListener(listener: IStatusListener) { + listeners.remove(listener) } + fun show(container: ViewGroup) { + if (container.childCount > 0) { + if (container.visibility != View.VISIBLE) { + container.visibility = View.VISIBLE + } + return + } + val child = StatusView(model, container.context) + container.addView(child, ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)) + } + + fun hide(container: ViewGroup) { + container.visibility = View.GONE + } + + private fun onDestroy(ctx: Context) { hasInit = false CallerAutoPilotStatusListenerManager.removeListener(TAG) @@ -190,7 +171,12 @@ object StatusManager { flows.forEach { it.onDestroy() } + listeners.clear() flows.clear() - pop?.takeIf { it.isShowing }?.dismiss() + } + + interface IStatusListener { + + fun onStatusChanged(data: List, hasException: Boolean) } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/entity/Status.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/entity/Status.kt index 562722debe..ff949723fb 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/entity/Status.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/entity/Status.kt @@ -3,12 +3,12 @@ package com.zhjt.mogo_core_function_devatools.status.entity import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus.Tracing import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus.Tracing.* -internal sealed class Status +sealed class Status /** * 工控机 */ -internal class IpcStatus(val enabled: Boolean = false): Status() { +class IpcStatus(val enabled: Boolean = false): Status() { override fun equals(other: Any?): Boolean { if (javaClass != other?.javaClass) return false @@ -26,7 +26,7 @@ internal class IpcStatus(val enabled: Boolean = false): Status() { } } -internal class NetStatus(val enabled: Boolean = false, var name: String? = null, val speed: Speed? = null): Status() { +class NetStatus(val enabled: Boolean = false, var name: String? = null, val speed: Speed? = null): Status() { class Speed(val tx: Int, val rx: Int) { override fun toString(): String { @@ -56,7 +56,7 @@ internal class NetStatus(val enabled: Boolean = false, var name: String? = null, /** * android系统定位状态 */ -internal class GpsStatus(val enabled: Boolean = false, val isGranted: Boolean = false): Status() { +class GpsStatus(val enabled: Boolean = false, val isGranted: Boolean = false): Status() { override fun equals(other: Any?): Boolean { if (javaClass != other?.javaClass) return false @@ -81,7 +81,7 @@ internal class GpsStatus(val enabled: Boolean = false, val isGranted: Boolean = /** * RTK/GNSS定位状态 */ -internal class RTKStatus(var enabled: Boolean = false, var desc: String = "RTK"): Status() { +class RTKStatus(var enabled: Boolean = false, var desc: String = "RTK"): Status() { override fun equals(other: Any?): Boolean { if (javaClass != other?.javaClass) return false @@ -102,7 +102,7 @@ internal class RTKStatus(var enabled: Boolean = false, var desc: String = "RTK") /** * Can总线 */ -internal class CanStatus(var enabled: Boolean = false): Status() { +class CanStatus(var enabled: Boolean = false): Status() { override fun equals(other: Any?): Boolean { if (javaClass != other?.javaClass) return false @@ -125,7 +125,7 @@ internal class CanStatus(var enabled: Boolean = false): Status() { /** * 寻迹/算路/未知 */ -internal class TracingStatus(var state: Tracing = UNKNOWN): Status() { +class TracingStatus(var state: Tracing = UNKNOWN): Status() { enum class Tracing(val code: String? = "") { /** @@ -188,7 +188,7 @@ internal class TracingStatus(var state: Tracing = UNKNOWN): Status() { } } -internal fun String.toState(): Tracing? { +fun String.toState(): Tracing? { return when(this) { "IMAP_TRA_EXIST" -> TRACK_FINDED "IMAP_TRA_LOADED" -> TRACK_LOADED diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/ui/StatusView.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/ui/StatusView.kt index 0adf523bb6..1eebcf28e9 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/ui/StatusView.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/ui/StatusView.kt @@ -5,6 +5,7 @@ import android.content.* import android.graphics.* import android.graphics.drawable.* import android.transition.* +import android.util.* import android.view.* import androidx.appcompat.widget.* import androidx.constraintlayout.widget.* @@ -42,7 +43,6 @@ internal class StatusView(private val model: StatusModel, ctx: Context): Constra } private fun init() { - isClickable = true dot.background = shape(solid = Color.parseColor("#F33F1D"), shape = GradientDrawable.OVAL, width = 30.PX, height = 30.PX) iv.also { it.background = ContextCompat.getDrawable(context, R.drawable.icon_dev_status_un_fold) @@ -59,13 +59,14 @@ internal class StatusView(private val model: StatusModel, ctx: Context): Constra moveDuration = 0 removeDuration = 0 } - itx.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) + itx.layoutManager = GridLayoutManager(context,4, GridLayoutManager.VERTICAL, false) itx.background = shape(solid = Color.parseColor("#80000000"), radius = 40.PX) itx.addItemDecoration( CommonDividerItemDecoration.Builder() .horizontalExternalSpace(38.PX) .verticalExternalSpace(30.PX) - .spanCountLRCare(false) + .verticalInnerSpace(20.PX) + .spanCountTBCare(false) .horizontalInnerSpace(50.PX) .build() ) @@ -90,6 +91,17 @@ internal class StatusView(private val model: StatusModel, ctx: Context): Constra } } + override fun onVisibilityChanged(changedView: View, visibility: Int) { + super.onVisibilityChanged(changedView, visibility) + if (changedView != this) { + if (visibility == View.VISIBLE) { + observer?.also { model.status.observeForever(it) } + } else { + observer?.also { model.status.removeObserver(it) } + } + } + } + private fun animate(expand: Boolean) { TransitionManager.beginDelayedTransition(this, AutoTransition().setDuration(200)) rv.visibility = if (expand) View.VISIBLE else View.INVISIBLE diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/layout/layout_status_bar.xml b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/layout_status_bar.xml index baecaea7f1..ac03487212 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/res/layout/layout_status_bar.xml +++ b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/layout_status_bar.xml @@ -8,13 +8,12 @@ @@ -24,7 +23,7 @@ android:layout_height="107px" android:layout_marginBottom="20px" app:layout_constraintTop_toTopOf="parent" - app:layout_constraintBottom_toBottomOf="parent" + android:layout_marginTop="12px" app:layout_constraintStart_toEndOf="@+id/rv" app:layout_constraintEnd_toEndOf="parent" android:background="@drawable/icon_dev_status_un_fold"/> 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 6922a189c9..901e32a7bb 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 @@ -207,7 +207,7 @@ import java.util.* setProxyLimitingSpeedView(viewLimitingVelocity) setViewNotificationProvider(this) context?.also { - CallerDevaToolsManager.showStatusBar(it, vs_status_bar) + CallerDevaToolsManager.showStatusBar(it, statusBarContainer) } } @@ -1214,7 +1214,7 @@ import java.util.* } override fun showSmallFragment() { - CallerDevaToolsManager.hideStatusBar() + CallerDevaToolsManager.hideStatusBar(statusBarContainer) // 加载全览模式图层 val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) .navigation() as BaseFragment @@ -1229,7 +1229,7 @@ import java.util.* } override fun hideSmallFragment() { - context?.let { CallerDevaToolsManager.showStatusBar(it, vs_status_bar) } + context?.let { CallerDevaToolsManager.showStatusBar(it, statusBarContainer) } val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) .navigation() as BaseFragment activity?.supportFragmentManager?.beginTransaction() diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SteeringWheelView.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SteeringWheelView.java index 7fb56ed8d9..67594f090e 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SteeringWheelView.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SteeringWheelView.java @@ -129,14 +129,26 @@ public class SteeringWheelView extends ConstraintLayout { if (autopilotIV != null) { Log.d(TAG, "autopilotIV != null"); if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + // TODO - autopilotIV.setImageResource(R.drawable.bg_auto); - + } else { + autopilotIV.setImageResource(R.drawable.bg_auto); + } } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) { - autopilotIV.setImageResource(R.drawable.bg_auto_nor); + if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + // TODO + } else { + autopilotIV.setImageResource(R.drawable.bg_auto_nor); + } } else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) { - autopilotIV.setImageResource(R.drawable.bg_auto_nor); + if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + // TODO + + } else { + autopilotIV.setImageResource(R.drawable.bg_auto_nor); + } } } else { Log.d(TAG, "autopilotIV=null"); diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml index ed3b74663e..64c1661753 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml @@ -147,6 +147,7 @@ android:layout_height="120px" android:layout_marginTop="30px" android:layout_marginEnd="40px" + android:background="@drawable/bg_waring_limiting_velocity" android:elevation="@dimen/dp_10" android:gravity="center" @@ -158,7 +159,7 @@ app:layout_constraintTop_toBottomOf="@+id/ivCameraIcon" app:layout_goneMarginEnd="40px" app:layout_goneMarginTop="40px" - tools:visibility="visible" /> + tools:visibility="gone" /> - + app:layout_goneMarginTop="30px" + app:layout_goneMarginEnd="40px"/> 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.java index 80daca40c3..6f1e3c704a 100644 --- 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.java @@ -12,7 +12,6 @@ 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.data.map.Infrastructure; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener; import com.mogo.eagle.core.function.api.map.hd.IMoGoMapFragmentProvider; import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener; @@ -30,11 +29,8 @@ import com.mogo.map.uicontroller.IMogoMapUIController; import com.zhidaoauto.map.sdk.open.MapAutoApi; import com.zhidaoauto.map.sdk.open.business.PointCloudHelper; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import ch.hsr.geohash.GeoHash; import mogo.telematics.pad.MessagePad; /** @@ -96,6 +92,7 @@ public class MapFragment extends MvpFragment } // 添加换肤监听 CallerSkinModeListenerManager.INSTANCE.addListener(TAG, this); + CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener); } @NonNull @@ -212,6 +209,17 @@ public class MapFragment extends MvpFragment viewModel.fetchInfStructures(); } + private final IMoGoAutopilotPlanningListener moGoAutopilotPlanningListener = new IMoGoAutopilotPlanningListener() { + + @Override + public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp globalPathResp) { + InfStructureManager.INSTANCE.savePlanningData(globalPathResp.getWayPointsList()); + } + + @Override + public void onAutopilotTrajectory(@NonNull List trajectoryInfos) {} + }; + @Override public IMogoMapUIController getUIController() { return mMogoMap.getUIController(); diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/InfStructureManager.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/InfStructureManager.kt index b249f7d1df..b355165c92 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/InfStructureManager.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/InfStructureManager.kt @@ -1,6 +1,7 @@ package com.mogo.eagle.core.function.overview import com.mogo.eagle.core.data.map.Infrastructure +import mogo.telematics.pad.MessagePad /** * 本地数据库查询出来的红绿灯、摄像头等数据 @@ -17,6 +18,10 @@ object InfStructureManager { HashMap>() } + private val _planningList by lazy { + ArrayList() + } + fun saveData(map: HashMap>) { if (_infMap.isNotEmpty()) { _infMap.clear() @@ -34,4 +39,13 @@ object InfStructureManager { } fun getPathData(): Map> = _pathMap + + fun savePlanningData(planningList: List) { + if (_planningList.isNotEmpty()) { + _planningList.clear() + } + _planningList.addAll(planningList) + } + + fun getPlanningData() = _planningList } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/vm/OverViewModel.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/vm/OverViewModel.kt index 6b5fb5c6fd..59440482c8 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/vm/OverViewModel.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/vm/OverViewModel.kt @@ -1,15 +1,17 @@ package com.mogo.eagle.core.function.overview.vm import androidx.lifecycle.* +import com.amap.api.maps.model.LatLng import com.mogo.eagle.core.data.map.Infrastructure import com.mogo.eagle.core.function.overview.OverviewDao +import io.reactivex.disposables.CompositeDisposable import kotlinx.coroutines.launch -import java.lang.Exception class OverViewModel( private val overviewDao: OverviewDao ) : ViewModel() { private val _infStructures = MutableLiveData>() + val infStructures get() = _infStructures diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java index bc506d5711..96aca1cc99 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java @@ -2,9 +2,7 @@ package com.mogo.eagle.core.function.smp; import android.content.Context; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.Canvas; -import android.location.Location; import android.os.Bundle; import android.util.AttributeSet; import android.util.Log; @@ -14,62 +12,35 @@ import android.view.View; import android.widget.RelativeLayout; import android.widget.TextView; -import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.amap.api.maps.AMap; import com.amap.api.maps.CameraUpdate; import com.amap.api.maps.CameraUpdateFactory; -import com.amap.api.maps.CoordinateConverter; +import com.amap.api.maps.TextureMapView; import com.amap.api.maps.UiSettings; +import com.amap.api.maps.model.BitmapDescriptor; import com.amap.api.maps.model.BitmapDescriptorFactory; +import com.amap.api.maps.model.CameraPosition; import com.amap.api.maps.model.CustomMapStyleOptions; import com.amap.api.maps.model.LatLng; +import com.amap.api.maps.model.LatLngBounds; +import com.amap.api.maps.model.Marker; import com.amap.api.maps.model.MarkerOptions; import com.amap.api.maps.model.Polyline; -import com.amap.api.navi.AMapNavi; -import com.amap.api.navi.AMapNaviListener; -import com.amap.api.navi.AMapNaviView; -import com.amap.api.navi.AMapNaviViewListener; -import com.amap.api.navi.AMapNaviViewOptions; -import com.amap.api.navi.enums.NaviType; -import com.amap.api.navi.model.AMapCalcRouteResult; -import com.amap.api.navi.model.AMapLaneInfo; -import com.amap.api.navi.model.AMapModelCross; -import com.amap.api.navi.model.AMapNaviCameraInfo; -import com.amap.api.navi.model.AMapNaviCross; -import com.amap.api.navi.model.AMapNaviInfo; -import com.amap.api.navi.model.AMapNaviLocation; -import com.amap.api.navi.model.AMapNaviRouteNotifyData; -import com.amap.api.navi.model.AMapNaviTrafficFacilityInfo; -import com.amap.api.navi.model.AMapServiceAreaInfo; -import com.amap.api.navi.model.AimLessModeCongestionInfo; -import com.amap.api.navi.model.AimLessModeStat; -import com.amap.api.navi.model.NaviInfo; -import com.amap.api.navi.model.NaviLatLng; -import com.amap.api.navi.model.RouteOverlayOptions; -import com.autonavi.tbt.TrafficFacilityInfo; -import com.elegant.utils.UiThreadHandler; -import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; +import com.amap.api.maps.model.PolylineOptions; import com.mogo.eagle.core.data.config.FunctionBuildConfig; import com.mogo.eagle.core.data.map.Infrastructure; -import com.mogo.eagle.core.data.map.MogoLatLng; import com.mogo.eagle.core.data.map.MogoLocation; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener; -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener; -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager; import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager; import com.mogo.eagle.core.function.map.R; import com.mogo.eagle.core.function.overview.InfStructureManager; -import com.mogo.eagle.core.function.smp.view.ISmallMapDirectionView; import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils; -import com.mogo.eagle.core.utilcode.util.ThreadUtils; -import com.mogo.module.common.utils.DrivingDirectionUtils; -import com.zhidao.support.adas.high.AdasManager; import org.jetbrains.annotations.NotNull; @@ -79,9 +50,8 @@ import java.util.List; import java.util.Map; import ch.hsr.geohash.GeoHash; +import kotlin.Pair; import mogo.telematics.pad.MessagePad; -import mogo_msg.MogoReportMsg; -import system_master.SystemStatusInfo; /** * 小地图的方向View @@ -92,23 +62,14 @@ import system_master.SystemStatusInfo; */ public class AMapCustomView extends RelativeLayout - implements IMoGoMapLocationListener, ISmallMapDirectionView, AMapNaviListener, AMapNaviViewListener { + implements IMoGoMapLocationListener { public static final String TAG = "AMapCustomView"; - private AMapNaviView mAMapNaviView; - protected AMapNavi mAMapNavi; + private TextureMapView mAMapView; private AMap mAMap; - protected NaviLatLng mStartLatlng = new NaviLatLng(); - protected NaviLatLng mEndLatlng = new NaviLatLng(); - protected final List sList = new ArrayList(); - protected final List eList = new ArrayList(); private int zoomLevel = 15; - private final List mCoordinatesLatLng = new ArrayList<>(); - private final List mCoordinatesLatLngCurrent = new ArrayList<>(); - protected List mWayPointList = new ArrayList(); - private Polyline mPolyline; private CameraUpdate mCameraUpdate; private Context mContext; - private float tilt = 30f; + private float mTilt = 60f; private TextView overLayerView; private boolean calculate = false; @@ -116,6 +77,23 @@ public class AMapCustomView private Map> pathMap = new HashMap(); private Map> posInfMap = new HashMap(); + // =============绘制轨迹线相关============= + private Marker mCarMarker; + private Marker mCompassMarker; + private Marker mStartMarker; + private Marker mEndMarker; + private Polyline mBottomPolyline; + private Polyline mCoveredPolyline; + // 计算索引并设置对应的Bitmap + BitmapDescriptor arrivedBitmap; + BitmapDescriptor unArrivedBitmap; + // 绘制轨迹线的集合 + private List textureList = new ArrayList<>(); + private List texIndexList = new ArrayList<>(); + + private MogoLocation mLocation; + private boolean isFirstLocation = true; + public AMapCustomView(Context context) { this(context, null); } @@ -136,35 +114,48 @@ public class AMapCustomView private void initView(Context context) { mContext = context; View smpView = LayoutInflater.from(context).inflate(R.layout.module_overview_map_view, this); - mAMapNaviView = smpView.findViewById(R.id.aMapNaviView); + mAMapView = smpView.findViewById(R.id.aMapView); overLayerView = findViewById(R.id.overLayer); - if(AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) { + if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) { overLayerView.setBackground(getResources().getDrawable(R.drawable.amap_reset)); - }else { + arrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.arrow_arrived_img); + unArrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.amap_bus_smooth_route); + } else { overLayerView.setBackground(getResources().getDrawable(R.drawable.amap_reset_bus)); + arrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.arrow_arrived_img); + unArrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.amap_bus_smooth_route); } - mAMapNavi = AMapNavi.getInstance(context); - mAMapNavi.addAMapNaviListener(this); - mAMapNaviView.setAMapNaviViewListener(this); - CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, mGoAutopilotStatusListener); CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener); initAMapView(context); // 注册定位监听 CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this); //设置全览模式 overLayerView.setOnClickListener(v -> { - mAMapNaviView.displayOverview(); + displayCustomOverView(); }); - // 注册定位监听 - CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this); - CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, mGoAutopilotStatusListener); - CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener); } private void initAMapView(Context context) { Log.d(TAG, "initAMapView"); mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel); - mAMap = mAMapNaviView.getMap(); + mAMap = mAMapView.getMap(); + mAMap.setOnMapLoadedListener(() -> { + Log.d(TAG, "---onMapLoaded---"); + CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions(); + // 加载自定义样式 + customMapStyleOptions.setEnable(true); + if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) { + customMapStyleOptions.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "over_view_style.data")); + customMapStyleOptions.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "over_view_style_extra.data")); + } else { + customMapStyleOptions.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "over_view_style_bus.data")); + customMapStyleOptions.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "over_view_style_extra_bus.data")); + } + // 设置自定义样式 + mAMap.setCustomMapStyle(customMapStyleOptions); + // 实时路况图层关闭,必须添加在loaded结束之后,其他位置不生效 + mAMap.setTrafficEnabled(false); + }); setUpMap(); customOptions(); } @@ -195,98 +186,28 @@ public class AMapCustomView * 自定义导航View和路况状态 */ private void customOptions() { - AMapNaviViewOptions options = mAMapNaviView.getViewOptions(); - //关闭自动绘制路线,自行绘制路线 -// options.setAutoDrawRoute(false); - //不显示导航界面 - options.setLayoutVisible(false); - options.setTilt(60); - //黑夜模式 - options.setNaviNight(true); - //导航全程光柱 - options.setTrafficBarEnabled(false); - //隐藏摄像头 - options.setCameraBubbleShow(false); - //转向箭头 - options.setNaviArrowVisible(false); - //指南针 -// options.setCompassEnabled(false); -// options.setTilt((int) tilt); - //自车车标 - options.setCarBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.map_car_icon)); - options.setFourCornersBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.amap_custom_corner)); - options.setStartPointBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.module_small_map_view_dir_start)); - options.setWayPointBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.icon_module_small_map_four_corners)); - options.setEndPointBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.module_small_map_view_dir_end)); - //与走过的路线 - options.setAfterRouteAutoGray(true); - //路线纹理自定义 - RouteOverlayOptions routeOverlayOptions = new RouteOverlayOptions(); - routeOverlayOptions.setTurnArrowIs3D(false); - // 未知路段和导航路段颜色一样 - routeOverlayOptions.setUnknownTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.amap_custom_smooth_route));//未知路段 - routeOverlayOptions.setSmoothTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.amap_custom_smooth_route)); - routeOverlayOptions.setJamTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.custtexture_bad));//拥堵路段 - routeOverlayOptions.setVeryJamTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.custtexture_grayred));//超级拥堵路段 - routeOverlayOptions.setPassRoute(BitmapFactory.decodeResource(getResources(), R.drawable.amap_custom_pass_route));//走过的路段 - options.setRouteOverlayOptions(routeOverlayOptions); - mAMapNaviView.setTrafficLightsVisible(true); - mAMapNaviView.setViewOptions(options); + if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) { + mCarMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_car_icon)) + .anchor(0.5f, 0.5f)); + mCompassMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.amap_custom_corner)) + .anchor(0.5f, 0.5f)); + } else { + mCarMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_bus_icon)) + .anchor(0.5f, 0.5f)); + mCompassMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.amap_bus_corner)) + .anchor(0.5f, 0.5f)); + } + + mStartMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start))); + mEndMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end))); } - private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener() { - - @Override - public void onAutopilotStatusRespByQuery(@NonNull SystemStatusInfo.StatusInfo status) { - - } - - @Override - public void onAutopilotIpcConnectStatusChanged(int status, @org.jetbrains.annotations.Nullable String reason) { - - } - - @Override - public void onAutopilotGuardian(@org.jetbrains.annotations.Nullable MogoReportMsg.MogoReportMessage guardianInfo) { - - } - - @Override - public void onAutopilotSNRequest() { - - } - - @Override - public void onAutopilotArriveAtStation(@org.jetbrains.annotations.Nullable MessagePad.ArrivalNotification arrivalNotification) { - - } - - @Override - public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autoPilotStatusInfo) { - ThreadUtils.runOnUiThread(new Runnable() { - @Override - public void run() { - if (autoPilotStatusInfo == null) return; - int state = autoPilotStatusInfo.getState(); - //0 不能自动驾驶 1 可以自动驾驶,但是在人工干预 2 自动驾驶中 - if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { - Log.d(TAG, "自动驾驶中 state=" + String.valueOf(state)); - if (sList.size() == 0 && eList.size() == 0 && mWayPointList.size() == 0) { - Log.d(TAG, "sendGlobalPathReq"); - AdasManager.getInstance().sendGlobalPathReq(); - } - } else { - int type = mAMapNavi.getNaviType(); - Log.d(TAG, "非自动驾驶状态,导航类型==" + String.valueOf(type)); - if (type == NaviType.GPS || type == NaviType.EMULATOR) { - mAMapNavi.stopNavi(); - } - } - } - }); - } - }; - private final IMoGoAutopilotPlanningListener moGoAutopilotPlanningListener = new IMoGoAutopilotPlanningListener() { @Override @@ -301,52 +222,35 @@ public class AMapCustomView */ @Override public void onAutopilotRotting(@org.jetbrains.annotations.Nullable MessagePad.GlobalPathResp globalPathResp) { - if (calculate == true && sList.size() == 0 && eList.size() == 0 && mWayPointList.size() == 0) { - return; - } - calculate = true; Log.d(TAG, "onAutopilotRotting"); - List list = globalPathResp.getWayPointsList(); - int minCount = 2; - if (list.size() >= minCount) { - calculate = true; - MessagePad.Location sLocation = (MessagePad.Location) list.get(0); - MessagePad.Location eLocation = (MessagePad.Location) list.get(list.size() - 1); - mStartLatlng = new NaviLatLng(sLocation.getLatitude(), sLocation.getLongitude()); - mEndLatlng = new NaviLatLng(eLocation.getLatitude(), eLocation.getLongitude()); - sList.clear(); - eList.clear(); - sList.add(mStartLatlng); - eList.add(mEndLatlng); - - mWayPointList.clear(); - for (int i = 1; i < list.size() - minCount; i++) { - MessagePad.Location wayLoc = (MessagePad.Location) list.get(i); - NaviLatLng way = new NaviLatLng(wayLoc.getLatitude(), wayLoc.getLongitude()); - mWayPointList.add(way); - } - } - int strategy = 0; - try { - //再次强调,最后一个参数为true时代表多路径,否则代表单路径 - strategy = mAMapNavi.strategyConvert(true, false, false, false, false); - } catch (Exception e) { - e.printStackTrace(); - } - Log.d(TAG, "全局路径" + list.size() + ",起点:" + sList.toString() + ",终点:" + eList.toString() + ",经点:" + mWayPointList.toString()); - //指定路径绘制导航路线 - mAMapNavi.calculateDriveRoute(sList, eList, mWayPointList, strategy); - - drawInfrastructureMarkers(globalPathResp); + handlePlanningData(globalPathResp.getWayPointsList()); } }; + public void handlePlanningData(List locationList) { + List list = locationList; + // 转成高德坐标系并存储 + MarkerDrawerManager.INSTANCE.updateRoutePoints(list, mContext); + List planningPointList = MarkerDrawerManager.INSTANCE.getPlanningPoints(); + displayCustomOverView(); + drawStartAndEndMarker(planningPointList); + MarkerDrawerManager.INSTANCE.setCallback((points, locIndex) -> { + // 每1s刷新一下轨迹线 + if (points.size() > 0) { + drawPolyline(points, locIndex); + } else { + clearCustomPolyline(); + } + }); + MarkerDrawerManager.INSTANCE.startLoopCalCarLocation(); + drawInfrastructureMarkers(locationList); + } + @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); // 注册定位监听 CallerMapLocationListenerManager.INSTANCE.removeListener(TAG); - CallerAutoPilotStatusListenerManager.INSTANCE.removeListener(TAG); CallerAutopilotPlanningListenerManager.INSTANCE.removeListener(TAG); } @@ -358,395 +262,76 @@ public class AMapCustomView @Override public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from) { - - } - - private void removeLocation(Location latLng) { - for (LatLng l : mCoordinatesLatLng) { - if (!isPointOnCarFront(latLng, l)) { - mCoordinatesLatLng.remove(l); - } - } - } - - public static boolean isPointOnCarFront(Location carLocal, LatLng pointLocal) { - double carLon = carLocal.getLongitude(); - double carLat = carLocal.getLatitude(); - double poiLon = pointLocal.longitude; - double poiLat = pointLocal.latitude; - float carAngle = carLocal.getBearing(); - - // 计算车辆与点之间的夹角 - int diffAngle = DrivingDirectionUtils.getDegreeOfCar2Poi( - carLon, carLat, poiLon, poiLat, (int) carAngle); - - return diffAngle <= 90; - } - - - @Override - public void drawablePolyline() { - } - - - public LatLng CoordinateConverterFrom84(Context mContext, MogoLatLng mogoLatLng) { - CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext); - mCoordinateConverter.from(CoordinateConverter.CoordType.GPS); - mCoordinateConverter.coord(new LatLng(mogoLatLng.lat, mogoLatLng.lon)); - return mCoordinateConverter.convert(); - } - - public List CoordinateConverterFrom84ForList(Context mContext, List mogoLatLngList) { - List list = new ArrayList<>(); - for (MogoLatLng m : mogoLatLngList) { - LatLng mogoLatLng = CoordinateConverterFrom84(mContext, m); - list.add(mogoLatLng); - } - return list; - } - - @Override - public void clearPolyline() { - if (mPolyline != null) { - mPolyline.remove(); - } - } - - public void resetPolyLine() { - mCoordinatesLatLng.clear(); - if (mPolyline != null) { - mPolyline.remove(); + mLocation = location; + MarkerDrawerManager.INSTANCE.setLonLat(new Pair(location.getLongitude(), location.getLatitude())); + drawCarMarker(location); + if (isFirstLocation) { + displayCustomOverView(); + isFirstLocation = false; } } public void onCreateView(Bundle savedInstanceState) { - if (mAMapNaviView != null) { - mAMapNaviView.onCreate(savedInstanceState); + if (mAMapView != null) { + mAMapView.onCreate(savedInstanceState); } } public void onResume() { - if (mAMapNaviView != null) { - mAMapNaviView.onResume(); + if (mAMapView != null) { + mAMapView.onResume(); } } public void onPause() { - if (mAMapNaviView != null) { - mAMapNaviView.onPause(); + if (mAMapView != null) { + mAMapView.onPause(); } } public void onDestroy() { - if (mAMapNaviView != null) { - mAMapNaviView.onDestroy(); + if (mAMapView != null) { + mAMapView.onDestroy(); } - //since 1.6.0 不再在naviview destroy的时候自动执行AMapNavi.stopNavi();请自行执行 - if (mAMapNavi != null) { - mAMapNavi.stopNavi(); - mAMapNavi.destroy(); - } - if (mAMapNaviView != null) { - mAMapNaviView.onDestroy(); + + if (mAMapView != null) { + mAMapView.onDestroy(); } } - public void convert(List coordinates) { - - } - - //多路径算路成功回调 - @Override - public void onCalculateRouteSuccess(int[] ints) { - Log.d(TAG, "onCalculateRouteSuccess int"); - } - - - @Override - public void onInitNaviFailure() { - calculate = false; - Log.d(TAG, "onInitNaviFailure"); - } - - @Override - public void onInitNaviSuccess() { - Log.d(TAG, "onInitNaviSuccess"); - - } - - @Override - public void onStartNavi(int i) { - Log.d(TAG, "onStartNavi"); - - } - - @Override - public void onTrafficStatusUpdate() { - - } - - @Override - public void onLocationChange(AMapNaviLocation aMapNaviLocation) { -// Log.d(TAG, "高德地图经纬度:" + aMapNaviLocation.getCoord().getLongitude() + "," + aMapNaviLocation.getCoord().getLatitude()); - - } - - @Override - public void onGetNavigationText(int i, String s) { - Log.d(TAG, "onGetNavigationText int"); - } - - @Override - public void onGetNavigationText(String s) { - Log.d(TAG, "onGetNavigationText ss"); - - } - - @Override - public void onEndEmulatorNavi() { - Log.d(TAG, "onEndEmulatorNavi"); - } - - @Override - public void onArriveDestination() { - Log.d(TAG, "onArriveDestination"); - } - - @Override - public void onCalculateRouteFailure(int i) { - Log.d(TAG, "onCalculateRouteFailure"); - } - - @Override - public void onReCalculateRouteForYaw() { - Log.d(TAG, "onReCalculateRouteForYaw"); - } - - @Override - public void onReCalculateRouteForTrafficJam() { - Log.d(TAG, "onReCalculateRouteForTrafficJam"); - } - - @Override - public void onArrivedWayPoint(int i) { - Log.d(TAG, "onArrivedWayPoint"); - } - - @Override - public void onGpsOpenStatus(boolean b) { - Log.d(TAG, "onGpsOpenStatus"); - } - - @Override - public void onNaviInfoUpdate(NaviInfo naviInfo) { - Log.d(TAG, "onNaviInfoUpdate"); - } - - @Override - public void onNaviInfoUpdated(AMapNaviInfo aMapNaviInfo) { - Log.d(TAG, "onNaviInfoUpdated"); - } - - @Override - public void updateCameraInfo(AMapNaviCameraInfo[] aMapNaviCameraInfos) { - Log.d(TAG, "updateCameraInfo"); - } - - @Override - public void updateIntervalCameraInfo(AMapNaviCameraInfo aMapNaviCameraInfo, AMapNaviCameraInfo aMapNaviCameraInfo1, int i) { - Log.d(TAG, "updateIntervalCameraInfo"); - } - - @Override - public void onServiceAreaUpdate(AMapServiceAreaInfo[] aMapServiceAreaInfos) { - Log.d(TAG, "onServiceAreaUpdate"); - } - - @Override - public void showCross(AMapNaviCross aMapNaviCross) { - Log.d(TAG, "showCross"); - } - - @Override - public void hideCross() { - Log.d(TAG, "hideCross"); - } - - @Override - public void showModeCross(AMapModelCross aMapModelCross) { - Log.d(TAG, "showModeCross"); - } - - @Override - public void hideModeCross() { - Log.d(TAG, "hideModeCross"); - } - - @Override - public void showLaneInfo(AMapLaneInfo[] aMapLaneInfos, byte[] bytes, byte[] bytes1) { - Log.d(TAG, "showLaneInfo"); - } - - @Override - public void showLaneInfo(AMapLaneInfo aMapLaneInfo) { - Log.d(TAG, "showLaneInfo"); - } - - @Override - public void hideLaneInfo() { - Log.d(TAG, "hideLaneInfo"); - } - - @Override - public void notifyParallelRoad(int i) { - - } - - @Override - public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo[] aMapNaviTrafficFacilityInfos) { - - } - - @Override - public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo aMapNaviTrafficFacilityInfo) { - - } - - @Override - public void OnUpdateTrafficFacility(TrafficFacilityInfo trafficFacilityInfo) { - - } - - @Override - public void updateAimlessModeStatistics(AimLessModeStat aimLessModeStat) { - - } - - @Override - public void updateAimlessModeCongestionInfo(AimLessModeCongestionInfo aimLessModeCongestionInfo) { - - } - - @Override - public void onPlayRing(int i) { - - } - - //算路详情 - @Override - public void onCalculateRouteSuccess(AMapCalcRouteResult aMapCalcRouteResult) { - Log.d(TAG, "onCalculateRouteSuccess aMapCalcRouteResult" + aMapCalcRouteResult.toString()); - //提测修改为EMULATOR - mAMapNavi.startNavi(NaviType.GPS); - UiThreadHandler.postDelayed(() -> { - mAMapNaviView.displayOverview(); - }, 2000); - //停止导航测试代码 -// UiThreadHandler.postDelayed(() -> { -// mAMapNavi.stopNavi(); -// Log.d(TAG, "stop------------"); -// }, 20000); - } - - @Override - public void onCalculateRouteFailure(AMapCalcRouteResult aMapCalcRouteResult) { - Log.d(TAG, "onCalculateRouteFailure"); - } - - @Override - public void onNaviRouteNotify(AMapNaviRouteNotifyData aMapNaviRouteNotifyData) { - Log.d(TAG, "onNaviRouteNotify"); - } - - @Override - public void onNaviSetting() { - - } - - @Override - public void onNaviCancel() { - - } - - @Override - public boolean onNaviBackClick() { - return false; - } - - @Override - public void onNaviMapMode(int i) { - - } - - @Override - public void onNaviTurnClick() { - - } - - @Override - public void onNextRoadClick() { - - } - - @Override - public void onScanViewButtonClick() { - - } - - @Override - public void onLockMap(boolean b) { - - } - - @Override - public void onNaviViewLoaded() { - Log.d(TAG, "---onNaviViewLoaded---"); - CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions(); - // 加载自定义样式 - customMapStyleOptions.setEnable(true); - if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) { - customMapStyleOptions.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "over_view_style.data")); - customMapStyleOptions.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "over_view_style_extra.data")); - } else { - customMapStyleOptions.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "over_view_style_bus.data")); - customMapStyleOptions.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "over_view_style_extra_bus.data")); + public void clearCustomPolyline() { + if (mBottomPolyline != null) { + mBottomPolyline.remove(); + } + if (mCoveredPolyline != null) { + mCoveredPolyline.remove(); } - // 设置自定义样式 - mAMap.setCustomMapStyle(customMapStyleOptions); - // 实时路况图层关闭,必须添加在loaded结束之后,其他位置不生效 - mAMap.setTrafficEnabled(false); } - @Override - public void onMapTypeChanged(int i) { - - } - - @Override - public void onNaviViewShowMode(int i) { - - } - - private void drawInfrastructureMarkers(MessagePad.GlobalPathResp globalPathResp) { - if (globalPathResp != null) { - if (!pathMap.isEmpty()) { - pathMap.clear(); - } - String geoHash; - ArrayList infList; - for (MessagePad.Location location : globalPathResp.getWayPointsList()) { - geoHash = GeoHash.withCharacterPrecision(location.getLatitude(), location.getLongitude(), 7).toBase32(); - // 网格内的轨迹点只取一次 - if (!pathMap.containsKey(geoHash)) { - // 从缓存的新基建数据中去取对应geoHash的新基建数据集合 - infList = InfStructureManager.INSTANCE.getData().get(geoHash); - if (infList != null) { - pathMap.put(geoHash, infList); - } + /** + * 绘制新基建Markers(比如:摄像头) + * + * @param locationList + */ + private void drawInfrastructureMarkers(List locationList) { + if (!pathMap.isEmpty()) { + pathMap.clear(); + } + String geoHash; + ArrayList infList; + for (MessagePad.Location location : locationList) { + LatLng latLng = MarkerDrawerManager.INSTANCE.coordinateConverterWgsToGcj(mContext, location); + geoHash = GeoHash.withCharacterPrecision(latLng.latitude, latLng.longitude, 7).toBase32(); + // 网格内的轨迹点只取一次s + if (!pathMap.containsKey(geoHash)) { + // 从缓存的新基建数据中去取对应geoHash的新基建数据集合 + infList = InfStructureManager.INSTANCE.getData().get(geoHash); + if (infList != null) { + pathMap.put(geoHash, infList); } } - drawInfMarkers(pathMap); } + drawInfMarkers(pathMap); } public void drawInfMarkers(Map> infStruMap) { @@ -782,7 +367,7 @@ public class AMapCustomView }); } - private Bitmap getBitmap(int count) { + private Bitmap getBitmap(int count) { MakerWithCount marker = new MakerWithCount(getContext()); marker.setCount(count); @@ -793,4 +378,114 @@ public class AMapCustomView marker.draw(new Canvas(bitmap)); return bitmap; } + + /** + * 进入自定义全览模式 + */ + private void displayCustomOverView() { + ArrayList linePointsLatLng = MarkerDrawerManager.INSTANCE.getPlanningPoints(); + MogoLocation location = mLocation; + if (linePointsLatLng.size() > 1) { + //圈定地图显示范围 + //存放经纬度 + LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); + for (int i = 0; i < linePointsLatLng.size(); i++) { + boundsBuilder.include(linePointsLatLng.get(i)); + } + LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude()); + boundsBuilder.include(currentLatLng); + + CameraPosition cameraPosition = new CameraPosition.Builder().tilt(mTilt).build(); + //第二个参数为四周留空宽度 + mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100)); + mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); + } else { + //设置希望展示的地图缩放级别 + CameraPosition cameraPosition = new CameraPosition.Builder() + .target(mCarMarker.getPosition()).tilt(0).zoom(zoomLevel).build(); + mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); + } + } + + /** + * 绘制自车 + * + * @param location + */ + private void drawCarMarker(MogoLocation location) { + if (location == null) return; + if (mCarMarker != null) { + LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude()); + mCarMarker.setRotateAngle(360 - location.getBearing()); + mCarMarker.setPosition(currentLatLng); + mCarMarker.setToTop(); + if (mCompassMarker != null) { + mCompassMarker.setRotateAngle(360 - location.getBearing()); + mCompassMarker.setPosition(currentLatLng); + } + } + } + + /** + * 绘制起始点、终点 + */ + private void drawStartAndEndMarker(List coordinates) { + if (mStartMarker != null) { + mStartMarker.setVisible(false); + } + if (mEndMarker != null) { + mEndMarker.setVisible(false); + } + if (coordinates.size() > 2) { + // 设置开始结束Marker位置 + + LatLng startLatLng = coordinates.get(0); + LatLng endLatLng = coordinates.get(coordinates.size() - 1); + + mStartMarker.setPosition(startLatLng); + mEndMarker.setPosition(endLatLng); + mStartMarker.setVisible(true); + mEndMarker.setVisible(true); + } + } + + /** + * 绘制轨迹线 + * + * @param coordinates + * @param locIndex + */ + private void drawPolyline(List coordinates, int locIndex) { + if (textureList.size() > 0) { + textureList.clear(); + } + if (texIndexList.size() > 0) { + texIndexList.clear(); + } + for (int i = 0; i < coordinates.size(); i++) { + if (i <= locIndex) { + // 已走过的置灰 + textureList.add(arrivedBitmap); + } else { + // 未走过的纹理 + textureList.add(unArrivedBitmap); + } + texIndexList.add(i); + } + if (mAMap != null && coordinates.size() > 2) { + //设置线段纹理 + PolylineOptions polylineOptions = new PolylineOptions(); + polylineOptions.addAll(coordinates); + polylineOptions.width(14); //线段宽度 + polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound); + polylineOptions.setCustomTextureList(textureList); + polylineOptions.setCustomTextureIndex(texIndexList); + // 绘制线 + mBottomPolyline = mCoveredPolyline; + mCoveredPolyline = mAMap.addPolyline(polylineOptions); + if (mBottomPolyline != null) { + mBottomPolyline.remove(); + } + } + } } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt new file mode 100644 index 0000000000..08f04fdb0e --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt @@ -0,0 +1,165 @@ +package com.mogo.eagle.core.function.smp + +import android.content.Context +import android.util.Log +import com.amap.api.maps.CoordinateConverter +import com.amap.api.maps.model.LatLng +import com.mogo.cloud.commons.utils.CoordinateUtils +import io.reactivex.Observable +import io.reactivex.ObservableOnSubscribe +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.CompositeDisposable +import io.reactivex.schedulers.Schedulers +import mogo.telematics.pad.MessagePad +import java.util.concurrent.TimeUnit + +/** + * 自定义高德地图画线管理者 + */ +object MarkerDrawerManager { + + interface Callback { + fun onLocationChanged(planningPoints: List, locIndex: Int) + } + + private val routeWipeDisposable by lazy { + CompositeDisposable() + } + + // 自主画线的所有高德坐标系的轨迹点 + val planningPoints by lazy { + ArrayList() + } + + @Volatile + var lastArrivedIndex: Int = -1 + + @Volatile + var lonLat = Pair(0.0, 0.0) + + var callback: Callback? = null + + fun startLoopCalCarLocation() { + getLoopCalCarObservable().delay(1000L, TimeUnit.MILLISECONDS, true) + .subscribeOn(Schedulers.io()) + .repeat() + .retry() + .observeOn(AndroidSchedulers.mainThread()) + .subscribe().let { + routeWipeDisposable.add(it) + } + } + + fun stopLoopCalCarLocation() { + if (!routeWipeDisposable.isDisposed) { + routeWipeDisposable.dispose() + } + } + + private fun getLoopCalCarObservable(): Observable { + return Observable.create(ObservableOnSubscribe { emitter -> + if (emitter.isDisposed) return@ObservableOnSubscribe + loopRouteAndWipe(planningPoints, lonLat.first, lonLat.second) + emitter.onComplete() + }) + } + + private fun loopRouteAndWipe(routePoints: List?, lon: Double, lat: Double) { + if (routePoints != null && routePoints.isNotEmpty()) { + val arrivedIndex: Int = getArrivedPointIndex(routePoints, lon, lat) + Log.d("cff", "thread is:${Thread.currentThread().name},arrivedIndex is:$arrivedIndex") + if (arrivedIndex != -1 && lastArrivedIndex != arrivedIndex) { + callback?.onLocationChanged(routePoints, arrivedIndex) + lastArrivedIndex = arrivedIndex + } + } + } + + fun updateRoutePoints(routePoints: List?, context: Context) { + if (routePoints == null || routePoints.isEmpty()) return + val latLngModels = coordinateConverterWgsToGcjListCommon(context, routePoints) + planningPoints.clear() + planningPoints.addAll(latLngModels) +// float remainingSumLength = calculateRemainingSumLength(mRoutePoints); + } + + /** + * @param routePoints + * @param realLon + * @param realLat + * @return 返回已经到达点的index + */ + private fun getArrivedPointIndex( + routePoints: List, + realLon: Double, + realLat: Double + ): Int { + var currentIndex = 0 //记录疑似点 + if (routePoints.isNotEmpty()) { + //基础点 + val baseLatLng = routePoints[0] + var baseDiffDis = CoordinateUtils.calculateLineDistance( + realLon, realLat, baseLatLng.longitude, baseLatLng.latitude + ) // lon,lat, prelon, prelat + for (i in 1 until routePoints.size) { + val latLng = routePoints[i] + val diff = CoordinateUtils.calculateLineDistance( + realLon, realLat, latLng.longitude, latLng.latitude + ) + if (baseDiffDis > diff) { + baseDiffDis = diff + currentIndex = i + } + } + return currentIndex + } + return currentIndex + } + + /** + * + * @param points + * @return 剩余的总距离 + */ + private fun calculateRemainingSumLength(points: List?): Float { + if (null == points || points.isEmpty()) return 0F + var sumLength = 0f + + //计算全路径总距离 + var i = 0 + while (i + 1 < points.size) { + val preLat = points[i].latitude + val preLon = points[i].longitude + val laLat = points[i + 1].latitude + val laLon = points[i + 1].longitude + val length = CoordinateUtils.calculateLineDistance(laLon, laLat, preLon, preLat) + sumLength += length + i++ + } + return sumLength + } + + private fun coordinateConverterWgsToGcjListCommon( + mContext: Context, + models: List + ): List { + //转成MogoLatLng集合 + val list: MutableList = java.util.ArrayList() + for (m in models) { + val mogoLatLng = coordinateConverterWgsToGcj(mContext, m) + list.add(mogoLatLng) + } + return list + } + + fun coordinateConverterWgsToGcj( + mContext: Context, + mogoLatLng: MessagePad.Location + ): LatLng { + val mCoordinateConverter = + CoordinateConverter(mContext) + mCoordinateConverter.from(CoordinateConverter.CoordType.GPS) + mCoordinateConverter.coord(LatLng(mogoLatLng.latitude, mogoLatLng.longitude)) + return mCoordinateConverter.convert() + } +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java index e8a3d3bf49..c1862a7485 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java @@ -4,32 +4,18 @@ import android.content.Context; import android.os.Bundle; import android.view.View; -import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.alibaba.android.arouter.facade.annotation.Route; import com.mogo.commons.mvp.BaseFragment; -import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; import com.mogo.eagle.core.data.constants.MoGoFragmentPaths; import com.mogo.eagle.core.data.map.MogoLatLng; -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener; -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.api.map.smp.IMogoSmallMapProvider; import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager; import com.mogo.eagle.core.function.map.R; import com.mogo.eagle.core.function.overview.InfStructureManager; -import com.mogo.eagle.core.data.map.Infrastructure; -import com.mogo.eagle.core.utilcode.util.UiThreadHandler; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; import java.util.List; -import java.util.Map; - -import mogo.telematics.pad.MessagePad; -import mogo_msg.MogoReportMsg; -import system_master.SystemStatusInfo; /** * @author donghongyu @@ -38,8 +24,7 @@ import system_master.SystemStatusInfo; */ @Route(path = MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) public class OverviewMapFragment extends BaseFragment - implements IMogoSmallMapProvider, IMoGoAutopilotPlanningListener, - IMoGoAutopilotStatusListener { + implements IMogoSmallMapProvider { private final String TAG = "SmallMapFragment"; protected AMapCustomView mAMapCustomView; @@ -68,7 +53,6 @@ public class OverviewMapFragment extends BaseFragment super.initViews(savedInstanceState); mAMapCustomView = mRootView.findViewById(R.id.smallMapDirectionView); mAMapCustomView.onCreateView(savedInstanceState); - CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this); } @Override @@ -87,17 +71,10 @@ public class OverviewMapFragment extends BaseFragment @Override public void drawablePolyline(List coordinates) { - if (mAMapCustomView != null) { - mAMapCustomView.convert(coordinates); - UiThreadHandler.post(() -> mAMapCustomView.drawablePolyline()); - } } @Override public void clearPolyline() { - if (mAMapCustomView != null) { - UiThreadHandler.post(() -> mAMapCustomView.clearPolyline()); - } } @Override @@ -106,6 +83,7 @@ public class OverviewMapFragment extends BaseFragment if (mAMapCustomView != null) { mAMapCustomView.onResume(); } + mAMapCustomView.handlePlanningData(InfStructureManager.INSTANCE.getPlanningData()); } @Override @@ -140,56 +118,4 @@ public class OverviewMapFragment extends BaseFragment } CallerAutopilotPlanningListenerManager.INSTANCE.removeListener(TAG); } - - @Override - public void onAutopilotTrajectory(List trajectoryInfos) { - - } - - @Override - public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autoPilotStatusInfo) { - if (autoPilotStatusInfo.getPilotmode() != 1) { - clearPolyline(); - } - } - - @Override - public void onAutopilotArriveAtStation(MessagePad.ArrivalNotification arrivalNotification) { - - } - - @Override - public void onAutopilotSNRequest() { - - } - - @Override - public void onAutopilotGuardian(MogoReportMsg.MogoReportMessage guardianInfo) { - - } - - @Override - public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) { - } - - @Override - public void onAutopilotRotting(MessagePad.GlobalPathResp globalPathResp) { - if (globalPathResp == null || globalPathResp.getWayPointsList().size() == 0) { - return; - } - List latLngList = new ArrayList<>(); - for (MessagePad.Location routeModel : globalPathResp.getWayPointsList()) { - latLngList.add(new MogoLatLng(routeModel.getLatitude(), routeModel.getLongitude())); - } - if (latLngList.size() > 0) { - drawablePolyline(latLngList); - } else { - clearPolyline(); - } - } - - @Override - public void onAutopilotStatusRespByQuery(@NonNull SystemStatusInfo.StatusInfo status) { - - } } diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/amap_bus_corner.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/amap_bus_corner.png new file mode 100644 index 0000000000..840089ceab Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/amap_bus_corner.png differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/amap_bus_smooth_route.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/amap_bus_smooth_route.png new file mode 100644 index 0000000000..99d8bd7b56 Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/amap_bus_smooth_route.png differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/arrow_arrived_img.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/arrow_arrived_img.png new file mode 100644 index 0000000000..ac919d5a4b Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/arrow_arrived_img.png differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/map_bus_icon.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/map_bus_icon.png new file mode 100644 index 0000000000..b1d54919d7 Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/map_bus_icon.png differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/amap_bus_corner.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/amap_bus_corner.png new file mode 100644 index 0000000000..840089ceab Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/amap_bus_corner.png differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/amap_bus_smooth_route.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/amap_bus_smooth_route.png new file mode 100644 index 0000000000..99d8bd7b56 Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/amap_bus_smooth_route.png differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/amap_custom_smooth_route.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/amap_custom_smooth_route.png new file mode 100644 index 0000000000..1dcfe1d5a3 Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/amap_custom_smooth_route.png differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/arrow_arrived_img.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/arrow_arrived_img.png new file mode 100644 index 0000000000..ac919d5a4b Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/arrow_arrived_img.png differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/map_bus_icon.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/map_bus_icon.png new file mode 100644 index 0000000000..b1d54919d7 Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/map_bus_icon.png differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_view.xml b/core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_view.xml index cd97415ef1..dedfa69132 100644 --- a/core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_view.xml +++ b/core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_view.xml @@ -17,8 +17,8 @@ android:layout_height="match_parent" android:layout_centerInParent="true"> - diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/devatools/IDevaToolsProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/devatools/IDevaToolsProvider.kt index fcbafafc21..e5328f0dec 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/devatools/IDevaToolsProvider.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/devatools/IDevaToolsProvider.kt @@ -2,7 +2,7 @@ package com.mogo.eagle.core.function.api.devatools import android.app.Activity import android.content.Context -import android.view.View +import android.view.* import com.alibaba.android.arouter.facade.template.IProvider import com.mogo.eagle.core.data.deva.chain.ChainLogParam import com.mogo.eagle.core.data.deva.scene.SceneModule @@ -107,10 +107,10 @@ interface IDevaToolsProvider : IProvider { /** * 展示状态栏 */ - fun showStatusBar(ctx: Context, anchor: View) + fun showStatusBar(ctx: Context, container: ViewGroup) /** * 隐藏状态栏 */ - fun hideStatusBar() + fun hideStatusBar(container: ViewGroup) } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/devatools/CallerDevaToolsManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/devatools/CallerDevaToolsManager.kt index 509a611781..71cc263d5c 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/devatools/CallerDevaToolsManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/devatools/CallerDevaToolsManager.kt @@ -150,27 +150,18 @@ object CallerDevaToolsManager { /** * 展示状态栏 */ - fun showStatusBar(ctx: Context, anchor: View) { + fun showStatusBar(ctx: Context, container: ViewGroup) { if (!AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { - if (anchor.isLaidOut) { - devaToolsProviderApi?.showStatusBar(ctx, anchor) - } else { - anchor.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { - override fun onGlobalLayout() { - devaToolsProviderApi?.showStatusBar(ctx, anchor) - anchor.viewTreeObserver.removeOnGlobalLayoutListener(this) - } - }) - } + devaToolsProviderApi?.showStatusBar(ctx, container) } } /** * 隐藏状态栏 */ - fun hideStatusBar() { + fun hideStatusBar(container: ViewGroup) { if (!AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { - devaToolsProviderApi?.hideStatusBar() + devaToolsProviderApi?.hideStatusBar(container) } } } \ No newline at end of file diff --git a/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/rv/divider/CommonDividerItemDecoration.kt b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/rv/divider/CommonDividerItemDecoration.kt index 62a5dfd1d2..f1234c0b90 100644 --- a/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/rv/divider/CommonDividerItemDecoration.kt +++ b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/rv/divider/CommonDividerItemDecoration.kt @@ -31,12 +31,15 @@ class CommonDividerItemDecoration internal constructor(builder: Builder) : ItemD private var mSpanCountTBCare = false private val mHorizontalExternalSpace: Int private val mVerticalExternalSpace: Int - private var mLastRight = 0 - private var mLastBottom = 0 private var mFromPosition = 0 private var mHorizontalDelta: Pair? = null private var mVerticalDelta: Pair? = null + private var mRightCache: HashMap = HashMap() + private var mLeftCache: HashMap = HashMap() + private var mBottomCache: HashMap = HashMap() + private var mTopCache: HashMap = HashMap() + /** * 外部间隔结束位置是否需要 */ @@ -84,23 +87,28 @@ class CommonDividerItemDecoration internal constructor(builder: Builder) : ItemD } } else { val averageDistance = (((spanCount - 1) * mHorizontalInnerSpace + 2 * mHorizontalExternalSpace + deltaHL + deltaHR) * 1.0f / spanCount).toInt() - Log.d("UUUU", "step::0::$averageDistance: lastRight: $mLastRight : state: $state " ) if (spanIndex == 0) { outRect.left = mHorizontalExternalSpace + deltaHL outRect.right = averageDistance - outRect.left - mLastRight = outRect.right - Log.d("UUUU", "step::1::$averageDistance: lastRight: $mLastRight" ) + if (state.didStructureChange()) { + mRightCache[position] = outRect.right + } + Log.d("UUUU", "step::1::$averageDistance: outRect.right: ${outRect.right} ::outRect.left: ${outRect.left}:: position: $position :: state: $state" ) } else if (spanIndex == spanCount - 1) { outRect.right = mHorizontalExternalSpace + deltaHR outRect.left = averageDistance - outRect.right - Log.d("UUUU", "step::2::$averageDistance: lastRight: $mLastRight ::outRect.left: ${outRect.left}" ) + Log.d("UUUU", "step::2::$averageDistance: outRect.right: ${outRect.right} ::outRect.left: ${outRect.left} :: position: $position :: state: $state" ) } else { - outRect.left = mHorizontalInnerSpace - mLastRight - outRect.right = averageDistance - outRect.left if (state.didStructureChange()) { - mLastRight = outRect.right + outRect.left = mHorizontalInnerSpace - (mRightCache[position - 1] ?: 0) + outRect.right = averageDistance - outRect.left + mLeftCache[position] = outRect.left + mRightCache[position] = outRect.right + } else { + outRect.left = mLeftCache[position]!! + outRect.right = mRightCache[position]!! } - Log.d("UUUU", "step::2::$averageDistance: lastRight: $mLastRight ::outRect.left: ${outRect.left}" ) + Log.d("UUUU", "step::2::$averageDistance: outRect.right: ${outRect.right} ::outRect.left: ${outRect.left} :: position: $position :: state: $state" ) } } //所在的行数 if (lookUp.getSpanGroupIndex(childPosition, spanCount) == lookUp.getSpanGroupIndex(mFromPosition, spanCount)) { @@ -130,15 +138,21 @@ class CommonDividerItemDecoration internal constructor(builder: Builder) : ItemD if (spanIndex == 0) { outRect.top = mVerticalExternalSpace + deltaVT outRect.bottom = averageDistance - outRect.top - mLastBottom = outRect.bottom + if (state.didStructureChange()) { + mBottomCache[position] = outRect.bottom + } } else if (spanIndex == spanCount - 1) { outRect.top = mVerticalExternalSpace + deltaVB outRect.bottom = averageDistance - outRect.top } else { - outRect.top = mVerticalInnerSpace - mLastBottom - outRect.bottom = averageDistance - outRect.top if (state.didStructureChange()) { - mLastBottom = outRect.bottom + outRect.top = mVerticalInnerSpace - (mBottomCache[position - 1] ?: 0 ) + outRect.bottom = averageDistance - outRect.top + mBottomCache[position] = outRect.bottom + mTopCache[position] = outRect.top + } else { + outRect.top = mTopCache[position]!! + outRect.bottom = mBottomCache[position]!! } } } @@ -223,15 +237,21 @@ class CommonDividerItemDecoration internal constructor(builder: Builder) : ItemD if (spanIndex == 0) { outRect.left = mHorizontalExternalSpace + deltaHL outRect.right = averageDistance - outRect.left - mLastRight = outRect.right + if (state.didStructureChange()) { + mRightCache[position] = outRect.right + } } else if (spanIndex == spanCount - 1) { outRect.right = mHorizontalExternalSpace + deltaHR outRect.left = averageDistance - outRect.right } else { - outRect.left = mHorizontalInnerSpace - mLastRight - outRect.right = averageDistance - outRect.left if (state.didStructureChange()) { - mLastRight = outRect.right + outRect.left = mHorizontalInnerSpace - (mRightCache[position - 1] ?: 0) + outRect.right = averageDistance - outRect.left + mLeftCache[position] = outRect.left + mRightCache[position] = outRect.right + } else { + outRect.left = mLeftCache[position]!! + outRect.right = mRightCache[position]!! } } } @@ -282,15 +302,22 @@ class CommonDividerItemDecoration internal constructor(builder: Builder) : ItemD if (spanIndex == 0) { outRect.top = mVerticalExternalSpace + deltaVT outRect.bottom = averageDistance - outRect.top - mLastBottom = outRect.bottom + if (state.didStructureChange()) { + mBottomCache[position] = outRect.bottom + } } else if (spanIndex == spanCount - 1) { outRect.top = mVerticalExternalSpace + deltaVB outRect.bottom = averageDistance - outRect.top } else { - outRect.top = mVerticalInnerSpace - mLastBottom - outRect.bottom = averageDistance - outRect.top + if (state.didStructureChange()) { - mLastBottom = outRect.bottom + outRect.top = mVerticalInnerSpace - (mBottomCache[position - 1] ?: 0) + outRect.bottom = averageDistance - outRect.top + mBottomCache[position] = outRect.bottom + mTopCache[position] = outRect.top + } else { + outRect.top = mTopCache[position]!! + outRect.bottom = mBottomCache[position]!! } } }