Merge branch 'dev_robotaxi-d-app-module_290_220715_2.9.0' into 'test_robotaxi-d-app-module_290_220715_2.9.0.1'
Dev robotaxi d app module 290 220715 2.9.0 See merge request zhjt/AndroidApp/MoGoEagleEye!114
@@ -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
|
||||
|
||||
@@ -82,7 +82,7 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
|
||||
|
||||
@Override
|
||||
public void onAutopilotArriveEnd() {
|
||||
mView.showOverviewFragment();
|
||||
// mView.showOverviewFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -107,13 +107,13 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
if (currentIndex == 0){
|
||||
mCurrentArriveStationTitle.setText(getResources().getString(R.string.bus_p_cur_station_title_init));
|
||||
mCurrentArriveTip.setText(getResources().getString(R.string.bus_p_cur_station_arrived_tip_init));
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
removeProgressBar();
|
||||
return;
|
||||
}
|
||||
if (isArrived){
|
||||
mCurrentArriveStationTitle.setText(getResources().getString(R.string.bus_p_cur_station_title));
|
||||
mCurrentArriveTip.setText(getResources().getString(R.string.bus_p_cur_station_arrived_tip));
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
removeProgressBar();
|
||||
}else {
|
||||
mCurrentArriveStationTitle.setText(getResources().getString(R.string.bus_p_cur_next_station_title));
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
@@ -122,6 +122,12 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
|
||||
}
|
||||
|
||||
private void removeProgressBar() {
|
||||
mProgressBar.setProgress(0);
|
||||
mProgressBar.setMax(0);
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void updateRoutePlanningToNextStation(long meters, long timeInSecond){
|
||||
//更新进度条
|
||||
updateProgressBar(meters);
|
||||
|
||||
@@ -14,7 +14,6 @@ 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;
|
||||
@@ -23,7 +22,6 @@ 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.autonavi.tbt.TrafficFacilityInfo;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
@@ -279,6 +277,11 @@ public class NaviToDestinationModel implements AMapNaviListener {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGpsSignalWeak(boolean b) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCameraInfo(AMapNaviCameraInfo[] aMapCameraInfos) {
|
||||
|
||||
@@ -289,21 +292,11 @@ public class NaviToDestinationModel implements AMapNaviListener {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdated(AMapNaviInfo aMapNaviInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo aMapNaviTrafficFacilityInfo) {
|
||||
//已过时
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnUpdateTrafficFacility(TrafficFacilityInfo trafficFacilityInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showCross(AMapNaviCross aMapNaviCross) {
|
||||
//显示放大图回调
|
||||
|
||||
@@ -38,7 +38,7 @@ ext {
|
||||
// amapnavi3dmap : "com.amap.api:navi-3dmap:8.0.1_3dmap8.0.1",
|
||||
// amapsearch : "com.amap.api:search:7.9.0",
|
||||
// amaplocation : "com.amap.api:location:5.5.0",
|
||||
amapnavi3dmap : "com.amap.api:navi-3dmap:7.2.0_3dmap7.2.0",
|
||||
amapnavi3dmap : "com.amap.api:navi-3dmap:7.7.0_3dmap7.7.0",
|
||||
amapsearch : "com.amap.api:search:7.1.0",
|
||||
amaplocation : "com.amap.api:location:5.3.1",
|
||||
// json 转换
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.zhjt.mogo_core_function_devatools
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.*
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainLogParam
|
||||
@@ -102,12 +102,12 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
upgradeManager.downLoadPackage(mContext!!, downloadKey,downloadUrl)
|
||||
}
|
||||
|
||||
override fun showStatusBar(ctx: Context, anchor: View) {
|
||||
StatusManager.init(ctx, anchor)
|
||||
StatusManager.show()
|
||||
override fun showStatusBar(ctx: Context, container: ViewGroup) {
|
||||
StatusManager.init(ctx)
|
||||
StatusManager.show(container)
|
||||
}
|
||||
|
||||
override fun hideStatusBar() {
|
||||
StatusManager.hide()
|
||||
override fun hideStatusBar(container: ViewGroup) {
|
||||
StatusManager.hide(container)
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
@file:Suppress("COMPATIBILITY_WARNING")
|
||||
|
||||
package com.zhjt.mogo_core_function_devatools.status
|
||||
|
||||
import android.content.*
|
||||
import android.view.*
|
||||
import android.view.WindowManager.LayoutParams
|
||||
import android.widget.*
|
||||
import androidx.core.view.*
|
||||
import androidx.lifecycle.*
|
||||
import androidx.lifecycle.Lifecycle.Event
|
||||
import androidx.lifecycle.Lifecycle.Event.ON_CREATE
|
||||
@@ -13,7 +12,6 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.zhjt.mogo_core_function_devatools.ext.*
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.CanStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.GpsStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.IpcStatus
|
||||
@@ -29,11 +27,12 @@ import com.zhjt.mogo_core_function_devatools.status.flow.ipc.IpcImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.nets.NetsImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.rtk.RTKImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.trace.TracingImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.ui.*
|
||||
import com.zhjt.mogo_core_function_devatools.status.ui.StatusView
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
import mogo_msg.MogoReportMsg
|
||||
import java.lang.ref.*
|
||||
import java.util.concurrent.*
|
||||
|
||||
|
||||
object StatusManager {
|
||||
|
||||
@@ -41,18 +40,13 @@ object StatusManager {
|
||||
|
||||
private lateinit var model: StatusModel
|
||||
|
||||
private var pop: PopupWindow? = null
|
||||
|
||||
private var timer: Job? = null
|
||||
|
||||
private var context: WeakReference<Context>? = null
|
||||
|
||||
private var anchor: WeakReference<View>? = null
|
||||
|
||||
private var hasInit = false
|
||||
|
||||
private var oldX = 0
|
||||
private var oldY = 0
|
||||
private val listeners by lazy { CopyOnWriteArrayList<IStatusListener>() }
|
||||
|
||||
|
||||
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<Status>, hasException: Boolean)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,13 +8,12 @@
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="156px"
|
||||
android:minWidth="902px"
|
||||
android:layout_width="611px"
|
||||
android:layout_height="271px"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/iv"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginEnd="20px"
|
||||
android:layout_marginEnd="42px"
|
||||
android:overScrollMode="never"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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" />
|
||||
|
||||
<!--左右转向灯-->
|
||||
<com.mogo.eagle.core.function.hmi.ui.turnlight.TurnLightViewStatus
|
||||
@@ -189,13 +190,15 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vs_status_bar"
|
||||
android:layout_width="107px"
|
||||
android:layout_height="107px"
|
||||
<RelativeLayout
|
||||
android:id="@+id/statusBarContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="30px"
|
||||
app:layout_constraintTop_toTopOf="@+id/viewLimitingVelocity"
|
||||
app:layout_constraintEnd_toStartOf="@+id/viewLimitingVelocity"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/viewLimitingVelocity"/>
|
||||
app:layout_goneMarginTop="30px"
|
||||
app:layout_goneMarginEnd="40px"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
|
||||
@@ -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<MapView, MapPresenter>
|
||||
}
|
||||
// 添加换肤监听
|
||||
CallerSkinModeListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -212,6 +209,17 @@ public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
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<MessagePad.TrajectoryPoint> trajectoryInfos) {}
|
||||
};
|
||||
|
||||
@Override
|
||||
public IMogoMapUIController getUIController() {
|
||||
return mMogoMap.getUIController();
|
||||
|
||||
@@ -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<String, ArrayList<Infrastructure>>()
|
||||
}
|
||||
|
||||
private val _planningList by lazy {
|
||||
ArrayList<MessagePad.Location>()
|
||||
}
|
||||
|
||||
fun saveData(map: HashMap<String, java.util.ArrayList<Infrastructure>>) {
|
||||
if (_infMap.isNotEmpty()) {
|
||||
_infMap.clear()
|
||||
@@ -34,4 +39,13 @@ object InfStructureManager {
|
||||
}
|
||||
|
||||
fun getPathData(): Map<String, ArrayList<Infrastructure>> = _pathMap
|
||||
|
||||
fun savePlanningData(planningList: List<MessagePad.Location>) {
|
||||
if (_planningList.isNotEmpty()) {
|
||||
_planningList.clear()
|
||||
}
|
||||
_planningList.addAll(planningList)
|
||||
}
|
||||
|
||||
fun getPlanningData() = _planningList
|
||||
}
|
||||
@@ -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<List<Infrastructure>>()
|
||||
|
||||
val infStructures
|
||||
get() = _infStructures
|
||||
|
||||
|
||||
@@ -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<NaviLatLng> sList = new ArrayList<NaviLatLng>();
|
||||
protected final List<NaviLatLng> eList = new ArrayList<NaviLatLng>();
|
||||
private int zoomLevel = 15;
|
||||
private final List<LatLng> mCoordinatesLatLng = new ArrayList<>();
|
||||
private final List<MogoLatLng> mCoordinatesLatLngCurrent = new ArrayList<>();
|
||||
protected List<NaviLatLng> mWayPointList = new ArrayList<NaviLatLng>();
|
||||
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<String, ArrayList<Infrastructure>> pathMap = new HashMap();
|
||||
private Map<LatLng, ArrayList<Infrastructure>> 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<BitmapDescriptor> textureList = new ArrayList<>();
|
||||
private List<Integer> 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<MessagePad.Location> locationList) {
|
||||
List list = locationList;
|
||||
// 转成高德坐标系并存储
|
||||
MarkerDrawerManager.INSTANCE.updateRoutePoints(list, mContext);
|
||||
List<LatLng> 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<LatLng> CoordinateConverterFrom84ForList(Context mContext, List<MogoLatLng> mogoLatLngList) {
|
||||
List<LatLng> 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<MogoLatLng> 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<Infrastructure> 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<MessagePad.Location> locationList) {
|
||||
if (!pathMap.isEmpty()) {
|
||||
pathMap.clear();
|
||||
}
|
||||
String geoHash;
|
||||
ArrayList<Infrastructure> 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<String, ArrayList<Infrastructure>> 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<LatLng> 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<LatLng> 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<LatLng> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<LatLng>, locIndex: Int)
|
||||
}
|
||||
|
||||
private val routeWipeDisposable by lazy {
|
||||
CompositeDisposable()
|
||||
}
|
||||
|
||||
// 自主画线的所有高德坐标系的轨迹点
|
||||
val planningPoints by lazy {
|
||||
ArrayList<LatLng>()
|
||||
}
|
||||
|
||||
@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<Int> {
|
||||
return Observable.create(ObservableOnSubscribe { emitter ->
|
||||
if (emitter.isDisposed) return@ObservableOnSubscribe
|
||||
loopRouteAndWipe(planningPoints, lonLat.first, lonLat.second)
|
||||
emitter.onComplete()
|
||||
})
|
||||
}
|
||||
|
||||
private fun loopRouteAndWipe(routePoints: List<LatLng>?, 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<MessagePad.Location>?, 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<LatLng>,
|
||||
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<LatLng>?): 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<MessagePad.Location>
|
||||
): List<LatLng> {
|
||||
//转成MogoLatLng集合
|
||||
val list: MutableList<LatLng> = 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()
|
||||
}
|
||||
}
|
||||
@@ -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<MogoLatLng> 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<MessagePad.TrajectoryPoint> 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<MogoLatLng> 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) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 879 B |
|
After Width: | Height: | Size: 443 B |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 879 B |
|
After Width: | Height: | Size: 215 B |
|
After Width: | Height: | Size: 443 B |
|
After Width: | Height: | Size: 6.9 KiB |
@@ -17,8 +17,8 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true">
|
||||
|
||||
<com.amap.api.navi.AMapNaviView
|
||||
android:id="@+id/aMapNaviView"
|
||||
<com.amap.api.maps.TextureMapView
|
||||
android:id="@+id/aMapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<Int, Int>? = null
|
||||
private var mVerticalDelta: Pair<Int, Int>? = null
|
||||
|
||||
private var mRightCache: HashMap<Int, Int> = HashMap()
|
||||
private var mLeftCache: HashMap<Int, Int> = HashMap()
|
||||
private var mBottomCache: HashMap<Int, Int> = HashMap()
|
||||
private var mTopCache: HashMap<Int, Int> = 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]!!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||