Merge remote-tracking branch 'origin/dev_robotaxi-d_230612_3.3.0' into dev_robotaxi-d_230612_3.3.0
This commit is contained in:
@@ -934,7 +934,7 @@ public class CarouselLayoutManager extends RecyclerView.LayoutManager implements
|
||||
}
|
||||
|
||||
private CarouselSavedState(@NonNull final Parcel in) {
|
||||
mSuperState = in.readParcelable(Parcelable.class.getClassLoader());
|
||||
mSuperState = in.readParcelable(RecyclerView.LayoutManager.class.getClassLoader());
|
||||
mCenterItemPosition = in.readInt();
|
||||
}
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ class PM2DrivingModel private constructor() {
|
||||
private val mAutoPilotStatusListener: IMoGoAutopilotStatusListener =
|
||||
object : IMoGoAutopilotStatusListener {
|
||||
|
||||
override fun onAutopilotStatusResponse(state: Int) { //todo yakun 检查逻辑
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
super.onAutopilotStatusResponse(state)
|
||||
d(SceneConstant.M_BUS_P+TAG, "onAutopilotStatusResponse ===== $state")
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING != state){
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.och.taxi.passenger.callback;
|
||||
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -11,7 +12,7 @@ import mogo.telematics.pad.MessagePad;
|
||||
* @date: 2021/11/1
|
||||
*/
|
||||
public interface IOCHTaxiPassengerAutopilotPlanningCallback {
|
||||
void setLineMarker(List<LatLng> models);
|
||||
void routeResultByServer(List<LatLng> models,int haveArrivedIndex);
|
||||
void setLineMarker(LatLng startStation,LatLng endStation);
|
||||
void routeResultByServer(List<LatLng> routeArriviedTemp, List<LatLng> routeArrivingTemp, MogoLocation location);
|
||||
void showRottingMapView();
|
||||
}
|
||||
@@ -48,6 +48,9 @@ import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
|
||||
import com.mogo.och.common.module.callback.OchAdasStartFailureCallback;
|
||||
import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager;
|
||||
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.common.module.manager.trajectorymamager.IDistanceListener;
|
||||
import com.mogo.och.common.module.manager.trajectorymamager.ITrajectoryListener;
|
||||
import com.mogo.och.common.module.manager.trajectorymamager.TrajectoryAndDistanceManager;
|
||||
import com.mogo.och.common.module.map.AmapNaviToDestinationModel;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.common.module.utils.PinYinUtil;
|
||||
@@ -254,6 +257,10 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(mAdasStartFailureListener);
|
||||
|
||||
CallerMsgBoxEventListenerManager.INSTANCE.addListener(TAG,iMsgBoxEventListener);
|
||||
|
||||
TrajectoryAndDistanceManager.INSTANCE.addDistanceListener(TAG,distanceListener);
|
||||
|
||||
TrajectoryAndDistanceManager.INSTANCE.addTrajectoryListener(TAG,trajectoryListener);
|
||||
}
|
||||
|
||||
private void releaseListeners() {
|
||||
@@ -274,6 +281,8 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(null);
|
||||
|
||||
CallerMsgBoxEventListenerManager.INSTANCE.removeListener(iMsgBoxEventListener);
|
||||
|
||||
TrajectoryAndDistanceManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -446,7 +455,27 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//监听网络变化,避免启动机器时无网导致无法更新订单信息
|
||||
private final IDistanceListener distanceListener = distance -> {
|
||||
|
||||
};
|
||||
|
||||
private final ITrajectoryListener trajectoryListener = (routeArrivied, routeArriving, location) -> {
|
||||
List<LatLng> routeArriviedTemp = new ArrayList<>();
|
||||
List<LatLng> routeArrivingTemp = new ArrayList<>();
|
||||
LatLng temp;
|
||||
for (MogoLocation mogoLocation : routeArrivied) {
|
||||
temp = new LatLng(mogoLocation.getLatitude(),mogoLocation.getLongitude());
|
||||
routeArriviedTemp.add(temp);
|
||||
}
|
||||
for (MogoLocation mogoLocation : routeArriving) {
|
||||
temp = new LatLng(mogoLocation.getLatitude(),mogoLocation.getLongitude());
|
||||
routeArrivingTemp.add(temp);
|
||||
}
|
||||
mAutopilotPlanningCallback.routeResultByServer(routeArriviedTemp,routeArrivingTemp,location);
|
||||
setRouteLineMarker();
|
||||
};
|
||||
private final IMogoIntentListener mNetWorkIntentListener = new IMogoIntentListener() {
|
||||
@Override
|
||||
public void onIntentReceived( String intentStr, Intent intent ) {
|
||||
@@ -584,7 +613,6 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp routeList) {
|
||||
if (null != routeList && routeList.getWayPointsList().size() > 0){
|
||||
calculateRouteLineSum(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext,routeList.getWayPointsList()));
|
||||
setRouteLineMarker(routeList.getWayPointsList());
|
||||
startToRouteAndWipe(routeList.getWayPointsList());
|
||||
}
|
||||
}
|
||||
@@ -664,38 +692,26 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
* @param isStart
|
||||
*/
|
||||
public void startOrStopRouteAndWipe(boolean isStart){
|
||||
if (isStart){
|
||||
TaxiPassengerModelLoopManager.getInstance().startRouteAndWipe();
|
||||
}else {
|
||||
mPreRouteIndex = 0;
|
||||
TaxiPassengerModelLoopManager.getInstance().stopRouteAndWipe();
|
||||
}
|
||||
}
|
||||
|
||||
public void loopRouteAndWipe() {
|
||||
if (mLocationsModels != null && mLocationsModels.size() > 0 && mLocation != null){
|
||||
int haveArrivedIndex = CoordinateCalculateRouteUtil
|
||||
.getArrivedPointIndexNew(mPreRouteIndex,
|
||||
mLocationsModels,
|
||||
mLocation);
|
||||
mPreRouteIndex = haveArrivedIndex;
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
List<LatLng> latLngsModels = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterLocationToLatLng(mContext,
|
||||
mLocationsModels);
|
||||
mAutopilotPlanningCallback.routeResultByServer(latLngsModels,haveArrivedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置小地图路径的起终点marker
|
||||
*/
|
||||
public void setRouteLineMarker(List<MessagePad.Location> models){
|
||||
List<LatLng> latLngModels = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterWgsToGcjListCommon(mContext,models);
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.setLineMarker(latLngModels);
|
||||
public void setRouteLineMarker(){
|
||||
if (mCurrentOCHOrder.startSiteGcjPoint == null || mCurrentOCHOrder.startSiteGcjPoint.isEmpty() || mCurrentOCHOrder.startSiteGcjPoint.size() < 2||
|
||||
mCurrentOCHOrder.endSiteGcjPoint == null || mCurrentOCHOrder.endSiteGcjPoint.isEmpty() || mCurrentOCHOrder.endSiteGcjPoint.size() < 2) {
|
||||
setMarker(null,null);
|
||||
return;
|
||||
}
|
||||
LatLng startStation = new LatLng(mCurrentOCHOrder.startSiteGcjPoint.get(1),mCurrentOCHOrder.startSiteGcjPoint.get(0));
|
||||
LatLng endStation = new LatLng(mCurrentOCHOrder.endSiteGcjPoint.get(1),mCurrentOCHOrder.endSiteGcjPoint.get(0));
|
||||
setMarker(startStation,endStation);
|
||||
}
|
||||
|
||||
private void setMarker(LatLng startStation,LatLng endStation){
|
||||
if (mAutopilotPlanningCallback != null) {
|
||||
mAutopilotPlanningCallback.setLineMarker(startStation,endStation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -772,9 +788,9 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
if (data != null && data.data != null && data.data != null && data.data.size() > 0){
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
calculateRouteLineSum(data.data);
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.setLineMarker(data.data);
|
||||
}
|
||||
// if (mAutopilotPlanningCallback != null){
|
||||
// mAutopilotPlanningCallback.setLineMarker(data.data);
|
||||
// }
|
||||
mLocationsModels.clear();
|
||||
List<MogoLocation> locationsModels = CoordinateCalculateRouteUtil.
|
||||
coordinateConverterLatlngToLocation(data.data);
|
||||
@@ -1044,4 +1060,20 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
|
||||
}
|
||||
}
|
||||
|
||||
public void setStation(){
|
||||
if(mCurrentOCHOrder!=null){
|
||||
MogoLocation startStation = new MogoLocation();
|
||||
startStation.setLongitude(mCurrentOCHOrder.startSiteGcjPoint.get(0));
|
||||
startStation.setLatitude(mCurrentOCHOrder.startSiteGcjPoint.get(1));
|
||||
MogoLocation endStation = new MogoLocation();
|
||||
endStation.setLongitude(mCurrentOCHOrder.endSiteGcjPoint.get(0));
|
||||
endStation.setLatitude(mCurrentOCHOrder.endSiteGcjPoint.get(1));
|
||||
TrajectoryAndDistanceManager.INSTANCE.setStationPoint(startStation,endStation);
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanStation(){
|
||||
TrajectoryAndDistanceManager.INSTANCE.setStationPoint(null,null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,45 +59,6 @@ public class TaxiPassengerModelLoopManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void startRouteAndWipe() {
|
||||
CallerLogger.INSTANCE.i(M_TAXI_P + TAG, "startRouteAndWipe()");
|
||||
if (mRouteWipeDisposable != null) return;
|
||||
|
||||
mRouteWipeDisposable = new CompositeDisposable();
|
||||
Disposable disposable = startLoopRouteAndWipe()
|
||||
.doOnSubscribe(new Consumer<Disposable>() {
|
||||
@Override
|
||||
public void accept(Disposable disposable) throws Exception {
|
||||
|
||||
}
|
||||
}).doOnError(new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
}
|
||||
})
|
||||
.delay(TaxiPassengerConst.LOOP_PERIOD_1S, TimeUnit.MILLISECONDS, true) // 设置delayError为true,表示出现错误的时候也需要延迟5s进行通知,达到无论是请求正常还是请求失败,都是5s后重新订阅,即重新请求。
|
||||
.subscribeOn(Schedulers.io())
|
||||
.repeat() // repeat保证请求成功后能够重新订阅。
|
||||
.retry() // retry保证请求失败后能重新订阅
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<Integer>() {
|
||||
@Override
|
||||
public void accept(Integer integer) throws Exception {
|
||||
}
|
||||
});
|
||||
mRouteWipeDisposable.add(disposable);
|
||||
}
|
||||
|
||||
public Observable<Integer> startLoopRouteAndWipe(){
|
||||
return Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
|
||||
TaxiPassengerModel.getInstance().loopRouteAndWipe();
|
||||
emitter.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void stopRouteAndWipe() {
|
||||
if (mRouteWipeDisposable != null) {
|
||||
CallerLogger.INSTANCE.i(M_TAXI_P + TAG, "stopRouteAndWipe()");
|
||||
|
||||
@@ -173,6 +173,7 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
|
||||
TaxiPassengerGeocodeSearchModel.getInstance(getContext()).destroyGeocodeSearch();
|
||||
TaxiPassengerModel.getInstance().startOrStopReadyToAutopilotLoop(false);
|
||||
clearV2XMarkers();
|
||||
TaxiPassengerModel.getInstance().cleanStation();
|
||||
return;
|
||||
}
|
||||
// 20 司机到达上车点
|
||||
@@ -194,6 +195,7 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
|
||||
});
|
||||
//开启轮询司机是否已准备好开启自动驾驶的环境
|
||||
TaxiPassengerModel.getInstance().startDriverReadyToAutopilotLoop();
|
||||
TaxiPassengerModel.getInstance().setStation();
|
||||
}
|
||||
if (TaxiPassengerOrderStatusEnum.OnTheWayToEnd.getCode() == order.orderStatus){
|
||||
runOnUIThread(() ->{
|
||||
@@ -201,6 +203,7 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
|
||||
mView.showOrHideServingOrderFragment(true,true);
|
||||
});
|
||||
TaxiPassengerModel.getInstance().startOrStopReadyToAutopilotLoop(false);
|
||||
TaxiPassengerModel.getInstance().setStation();
|
||||
}
|
||||
// 30 用户到达上车点 并通过了手机号后四位验证
|
||||
// 40 服务中
|
||||
@@ -229,6 +232,7 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
|
||||
CallerOrderListenerManager.INSTANCE.invokeOrderStatus(false);
|
||||
});
|
||||
clearV2XMarkers();
|
||||
TaxiPassengerModel.getInstance().cleanStation();
|
||||
return;
|
||||
}
|
||||
// 60 服务完成 页面
|
||||
@@ -236,6 +240,7 @@ public class BaseTaxiPassengerPresenter extends Presenter<TaxiPassengerBaseFragm
|
||||
TaxiPassengerGeocodeSearchModel.getInstance(getContext()).destroyGeocodeSearch();
|
||||
mCurrentPassengerOrder = null;
|
||||
clearV2XMarkers();
|
||||
TaxiPassengerModel.getInstance().cleanStation();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,17 +70,14 @@ public class TaxiPassengerServingOrderPresenter extends Presenter<TaxiPassengerS
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineMarker(List<LatLng> models) {
|
||||
if (models == null) return;
|
||||
runOnUIThread(() -> mView.setLineMarker(models));
|
||||
public void setLineMarker(LatLng startStation,LatLng endStation) {
|
||||
if (startStation == null || endStation == null) return;
|
||||
runOnUIThread(() -> mView.setLineMarker(startStation,endStation));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void routeResultByServer(List<LatLng> models, int haveArrivedIndex) {
|
||||
if (models == null) return;
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "routeResultByServer:" + models.size()
|
||||
+ " haveArrivedIndex = " + haveArrivedIndex);
|
||||
runOnUIThread(() ->mView.routeResultByServer(models,haveArrivedIndex));
|
||||
public void routeResultByServer(List<LatLng> routeArriviedTemp, List<LatLng> routeArrivingTemp, MogoLocation location) {
|
||||
runOnUIThread(() ->mView.routeResultByServer(routeArriviedTemp,routeArrivingTemp,location));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.mogo.och.taxi.passenger.ui;
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/6/24 11:33 上午
|
||||
*/
|
||||
public interface ITaxiPassengerMapDirectionView {
|
||||
|
||||
/**
|
||||
* 绘制路径线
|
||||
*/
|
||||
void drawablePolyline();
|
||||
|
||||
/**
|
||||
* 清除路径线
|
||||
*/
|
||||
void clearPolyline();
|
||||
|
||||
/**
|
||||
* 设置路径中起终点marker
|
||||
*/
|
||||
void setLineMarker();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.och.taxi.passenger.ui
|
||||
|
||||
import com.amap.api.maps.model.LatLng
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/6/24 11:33 上午
|
||||
*/
|
||||
interface ITaxiPassengerMapDirectionView {
|
||||
/**
|
||||
* 绘制路径线
|
||||
*/
|
||||
fun drawablePolyline()
|
||||
|
||||
/**
|
||||
* 清除路径线
|
||||
*/
|
||||
fun clearPolyline()
|
||||
|
||||
/**
|
||||
* 设置路径中起终点marker
|
||||
*/
|
||||
fun setLineMarker(startStation: LatLng, endStation: LatLng)
|
||||
}
|
||||
@@ -1,376 +0,0 @@
|
||||
package com.mogo.och.taxi.passenger.ui;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI_P;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
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.maps.model.PolylineOptions;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.taxi.passenger.R;
|
||||
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerMapViewCallback;
|
||||
import com.mogo.och.taxi.passenger.utils.TaxiPassengerMapAssetStyleUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 乘客屏小地图
|
||||
*/
|
||||
public class TaxiPassengerMapDirectionView
|
||||
extends RelativeLayout
|
||||
implements IMoGoChassisLocationGCJ02Listener, ITaxiPassengerMapDirectionView, AMap.OnCameraChangeListener {
|
||||
|
||||
//小地图名称
|
||||
public static final String TAG = "TPMapDirectionView";
|
||||
|
||||
private TextureMapView mAMapNaviView;
|
||||
private AMap mAMap;
|
||||
private Marker mCarMarker;
|
||||
private Marker mStartMarker;
|
||||
private Marker mEndMarker;
|
||||
|
||||
private int zoomLevel = 13;
|
||||
private List<LatLng> mCoordinatesLatLng = new ArrayList<>();
|
||||
private Polyline mPolyline;
|
||||
private CameraUpdate mCameraUpdate;
|
||||
private Context mContext;
|
||||
private int mHaveArrivedIndex;
|
||||
|
||||
List<BitmapDescriptor> textureList = new ArrayList<>();
|
||||
List<Integer> texIndexList = new ArrayList<>();
|
||||
|
||||
private BitmapDescriptor mArrivedRes;
|
||||
private BitmapDescriptor mUnArrivedRes;
|
||||
|
||||
private ITaxiPassengerMapViewCallback mITaxiPassengerMapViewCallback;
|
||||
|
||||
public TaxiPassengerMapDirectionView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public TaxiPassengerMapDirectionView(Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public TaxiPassengerMapDirectionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
try {
|
||||
initView(context);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setTaxiPassengerMapViewCallback(ITaxiPassengerMapViewCallback ITaxiPassengerMapViewCallback){
|
||||
this.mITaxiPassengerMapViewCallback = ITaxiPassengerMapViewCallback;
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "initView");
|
||||
|
||||
mContext = context;
|
||||
|
||||
View smpView = LayoutInflater.from(context).inflate(R.layout.taxi_p_map_view, this);
|
||||
|
||||
mAMapNaviView = (TextureMapView) smpView.findViewById(R.id.taxi_p_order_amap_view);
|
||||
|
||||
initAMapView();
|
||||
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, 10,this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
private void initAMapView() {
|
||||
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
mAMap = mAMapNaviView.getMap();
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);
|
||||
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.setTrafficEnabled(false);
|
||||
|
||||
// 设置 锚点 图标
|
||||
mCarMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_car))
|
||||
.anchor(0.5f, 0.5f));
|
||||
mStartMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_view_dir_start)));
|
||||
mEndMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_view_dir_end)));
|
||||
|
||||
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_arrived);
|
||||
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_un_arrive);
|
||||
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiPassengerMapAssetStyleUtil.getAssetsStyle(getContext(),"map_style.data"))
|
||||
.setStyleExtraData(TaxiPassengerMapAssetStyleUtil.getAssetsExtraStyle(getContext(),"map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap.moveCamera(mCameraUpdate);
|
||||
|
||||
// 设置地图的样式
|
||||
UiSettings uiSettings = mAMap.getUiSettings();
|
||||
uiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮
|
||||
uiSettings.setAllGesturesEnabled(false);// 所有手势
|
||||
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
|
||||
uiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
|
||||
mAMap.setOnMapLoadedListener(new AMap.OnMapLoadedListener() {
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "smp---onMapLoaded");
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiPassengerMapAssetStyleUtil.getAssetsStyle(getContext(),"map_style.data"))
|
||||
.setStyleExtraData(TaxiPassengerMapAssetStyleUtil.getAssetsExtraStyle(getContext(),"map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
mAMapNaviView.getMap().setPointToCenter(mAMapNaviView.getWidth() / 2, mAMapNaviView.getHeight() / 2);
|
||||
}
|
||||
});
|
||||
|
||||
//设置地图状态的监听接口
|
||||
mAMap.setOnCameraChangeListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
if (gnssInfo == null){
|
||||
return;
|
||||
}
|
||||
LatLng currentLatLng = new LatLng(gnssInfo.getLatitude(), gnssInfo.getLongitude());
|
||||
|
||||
if (mCoordinatesLatLng.size() > 1) {
|
||||
//圈定地图显示范围
|
||||
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
|
||||
//存放经纬度
|
||||
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
|
||||
boundsBuilder.include(currentLatLng);
|
||||
boundsBuilder.include(endLatLng);
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100,100,100,100));
|
||||
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "onCarLocationChanged2--moveCamera :" + location.getLatitude()+", "+location.getLongitude());
|
||||
|
||||
} else {
|
||||
//设置希望展示的地图缩放级别
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
.target(mCarMarker.getPosition()).tilt(0).bearing((float) gnssInfo.getHeading()).zoom(zoomLevel).build();
|
||||
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
}
|
||||
//更新车辆位置
|
||||
if (mCarMarker != null) {
|
||||
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "location.getBearing() = " + location.getBearing());
|
||||
mCarMarker.setRotateAngle((float) (360 - gnssInfo.getHeading()));
|
||||
mCarMarker.setPosition(currentLatLng);
|
||||
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "onCarLocationChanged2--loacation :" + location.getLatitude()+", "+location.getLongitude());
|
||||
mCarMarker.setToTop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineMarker() {
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
if (mCoordinatesLatLng.size() >= 2) {
|
||||
// 设置开始结束Marker位置
|
||||
LatLng startLatLng = mCoordinatesLatLng.get(0);
|
||||
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setPosition(startLatLng);
|
||||
mStartMarker.setVisible(true);
|
||||
}
|
||||
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setPosition(endLatLng);
|
||||
mEndMarker.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawablePolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mAMap != null) {
|
||||
|
||||
addRouteColorList();
|
||||
|
||||
if (mCoordinatesLatLng.size() >= 2) {
|
||||
//设置线段纹理
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
polylineOptions.addAll(mCoordinatesLatLng);
|
||||
polylineOptions.setUseTexture(true);
|
||||
polylineOptions.width(15);
|
||||
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound);
|
||||
polylineOptions.setCustomTextureList(textureList);
|
||||
polylineOptions.setCustomTextureIndex(texIndexList);
|
||||
// polylineOptions.setCustomTexture(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_un_arrive));
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加画线颜色值
|
||||
*/
|
||||
private void addRouteColorList() {
|
||||
textureList.clear();
|
||||
texIndexList.clear();
|
||||
for (int i = 0; i < mCoordinatesLatLng.size(); i++){
|
||||
if (i <= mHaveArrivedIndex){
|
||||
textureList.add(mArrivedRes);
|
||||
}else {
|
||||
textureList.add(mUnArrivedRes);
|
||||
}
|
||||
texIndexList.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
LatLng latLng = mCoordinateConverter.convert();
|
||||
return latLng;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetPolyine() {
|
||||
mCoordinatesLatLng.clear();
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreateView(Bundle savedInstanceState) {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
public void convert(List<MogoLatLng> coordinates) {
|
||||
mCoordinatesLatLng.clear();
|
||||
List<LatLng> latLngs = CoordinateConverterFrom84ForList(mContext, coordinates);
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
}
|
||||
|
||||
public void setCoordinatesLatLng(List<LatLng> latLngs){
|
||||
mCoordinatesLatLng.clear();
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
}
|
||||
|
||||
public void setCoordinatesLatLng(List<LatLng> latLngs, int haveArrivedIndex){
|
||||
mCoordinatesLatLng.clear();
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
mHaveArrivedIndex = haveArrivedIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition cameraPosition) {
|
||||
mITaxiPassengerMapViewCallback.onCameraChange(cameraPosition.bearing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinish(CameraPosition cameraPosition) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
package com.mogo.och.taxi.passenger.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.widget.RelativeLayout
|
||||
import com.amap.api.maps.AMap
|
||||
import com.amap.api.maps.CameraUpdate
|
||||
import com.amap.api.maps.CameraUpdateFactory
|
||||
import com.amap.api.maps.TextureMapView
|
||||
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.maps.model.PolylineOptions
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager.addListener
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.och.taxi.passenger.R
|
||||
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerMapViewCallback
|
||||
import com.mogo.och.taxi.passenger.utils.TaxiPassengerMapAssetStyleUtil
|
||||
|
||||
/**
|
||||
* 乘客屏小地图
|
||||
*/
|
||||
class TaxiPassengerMapDirectionView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener,
|
||||
ITaxiPassengerMapDirectionView, AMap.OnCameraChangeListener {
|
||||
|
||||
companion object {
|
||||
//小地图名称
|
||||
const val TAG = "TPMapDirectionView"
|
||||
private const val zoomLevel = 13.0f
|
||||
}
|
||||
|
||||
private lateinit var mAMapNaviView: TextureMapView
|
||||
private lateinit var mAMap: AMap
|
||||
private lateinit var mCarMarker: Marker
|
||||
private lateinit var mStartMarker: Marker
|
||||
private lateinit var mEndMarker: Marker
|
||||
private lateinit var mArrivedRes: BitmapDescriptor
|
||||
private lateinit var mUnArrivedRes: BitmapDescriptor
|
||||
|
||||
private val mCoordinatesLatLng: MutableList<LatLng> = ArrayList()
|
||||
private var mPolyline: Polyline? = null
|
||||
private var mCameraUpdate: CameraUpdate? = null
|
||||
private var mContext: Context? = null
|
||||
var textureList: MutableList<BitmapDescriptor?> = ArrayList()
|
||||
var texIndexList: MutableList<Int> = ArrayList()
|
||||
private var mITaxiPassengerMapViewCallback: ITaxiPassengerMapViewCallback? = null
|
||||
|
||||
private val routeArrivied: MutableList<LatLng> = ArrayList()
|
||||
private val routeArriving: MutableList<LatLng> = ArrayList()
|
||||
private var location: MogoLocation? = null
|
||||
|
||||
init {
|
||||
initView(context)
|
||||
}
|
||||
|
||||
fun setTaxiPassengerMapViewCallback(ITaxiPassengerMapViewCallback: ITaxiPassengerMapViewCallback?) {
|
||||
mITaxiPassengerMapViewCallback = ITaxiPassengerMapViewCallback
|
||||
}
|
||||
|
||||
private fun initView(context: Context) {
|
||||
d(SceneConstant.M_TAXI_P + TAG, "initView")
|
||||
mContext = context
|
||||
LayoutInflater.from(context).inflate(R.layout.taxi_p_map_view, this)
|
||||
mAMapNaviView = findViewById(R.id.taxi_p_order_amap_view)
|
||||
initAMapView()
|
||||
|
||||
// 注册定位监听
|
||||
addListener(TAG, 10, this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
private fun initAMapView() {
|
||||
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel)
|
||||
mAMap = mAMapNaviView.map
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap.mapType = AMap.MAP_TYPE_NIGHT
|
||||
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.isTrafficEnabled = false
|
||||
|
||||
// 设置 锚点 图标
|
||||
mCarMarker = mAMap.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_car)).anchor(0.5f, 0.5f))
|
||||
mStartMarker = mAMap.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_view_dir_start)))
|
||||
mEndMarker = mAMap.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_view_dir_end)))
|
||||
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_arrived)
|
||||
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_un_arrive)
|
||||
|
||||
// 加载自定义样式
|
||||
val customMapStyleOptions = CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiPassengerMapAssetStyleUtil.getAssetsStyle(context, "map_style.data"))
|
||||
.setStyleExtraData(TaxiPassengerMapAssetStyleUtil.getAssetsExtraStyle(context, "map_style_extra.data"))
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions)
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap.moveCamera(mCameraUpdate)
|
||||
|
||||
// 设置地图的样式
|
||||
mAMap.uiSettings.apply {
|
||||
isZoomControlsEnabled = false // 地图缩放级别的交换按钮
|
||||
setAllGesturesEnabled(false) // 所有手势
|
||||
isMyLocationButtonEnabled = false // 显示默认的定位按钮
|
||||
setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
}
|
||||
|
||||
mAMap.setOnMapLoadedListener {
|
||||
d(SceneConstant.M_TAXI_P + TAG, "smp---onMapLoaded")
|
||||
// 加载自定义样式
|
||||
val options = CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(
|
||||
TaxiPassengerMapAssetStyleUtil.getAssetsStyle(context, "map_style.data")
|
||||
)
|
||||
.setStyleExtraData(
|
||||
TaxiPassengerMapAssetStyleUtil.getAssetsExtraStyle(context, "map_style_extra.data")
|
||||
)
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(options)
|
||||
mAMapNaviView.map.setPointToCenter(mAMapNaviView.width / 2, mAMapNaviView.height / 2)
|
||||
}
|
||||
|
||||
//设置地图状态的监听接口
|
||||
mAMap.setOnCameraChangeListener(this)
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
if (mogoLocation == null) {
|
||||
return
|
||||
}
|
||||
val currentLatLng = LatLng(mogoLocation.latitude, mogoLocation.longitude)
|
||||
if (mPolyline!=null&&!mPolyline!!.points.isNullOrEmpty()) {
|
||||
//圈定地图显示范围
|
||||
val endLatLng = mPolyline!!.points.last()
|
||||
//存放经纬度
|
||||
val boundsBuilder = LatLngBounds.Builder().apply {
|
||||
include(currentLatLng)
|
||||
include(endLatLng)
|
||||
}
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100))
|
||||
} else {
|
||||
//设置希望展示的地图缩放级别
|
||||
val cameraPosition = CameraPosition.Builder()
|
||||
.target(mCarMarker.position)
|
||||
.tilt(0f)
|
||||
.bearing(mogoLocation.heading.toFloat())
|
||||
.zoom(zoomLevel).build()
|
||||
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
|
||||
}
|
||||
//更新车辆位置
|
||||
mCarMarker.rotateAngle = (360 - mogoLocation.heading).toFloat()
|
||||
mCarMarker.position = currentLatLng
|
||||
mCarMarker.setToTop()
|
||||
}
|
||||
|
||||
override fun setLineMarker(startStation:LatLng,endStation:LatLng) {
|
||||
mStartMarker.isVisible = false
|
||||
mEndMarker.isVisible = false
|
||||
mStartMarker.position = startStation
|
||||
mStartMarker.isVisible = true
|
||||
mEndMarker.position = endStation
|
||||
mEndMarker.isVisible = true
|
||||
}
|
||||
|
||||
override fun drawablePolyline() {
|
||||
if (routeArrivied.isEmpty() && routeArriving.isEmpty()) {
|
||||
d(SceneConstant.M_TAXI + TAG, "没有点")
|
||||
return
|
||||
}
|
||||
texIndexList.clear()
|
||||
val allPoints = ArrayList(routeArrivied)
|
||||
for (i in routeArrivied.indices) {
|
||||
if (routeArrivied.size > 1 && i < routeArrivied.size - 1) {
|
||||
texIndexList.add(0)
|
||||
}
|
||||
}
|
||||
texIndexList.add(0)
|
||||
allPoints.add(LatLng(location!!.latitude, location!!.longitude))
|
||||
allPoints.addAll(routeArriving)
|
||||
for (ignored in routeArrivied) {
|
||||
texIndexList.add(1)
|
||||
}
|
||||
if (mPolyline != null) {
|
||||
mPolyline!!.points = allPoints
|
||||
mPolyline!!.options.customTextureIndex = texIndexList
|
||||
return
|
||||
}
|
||||
textureList.add(mArrivedRes)
|
||||
textureList.add(mUnArrivedRes)
|
||||
//设置线段纹理
|
||||
val polylineOptions = PolylineOptions().apply {
|
||||
addAll(allPoints)
|
||||
isUseTexture = true
|
||||
width(15f)
|
||||
lineCapType(PolylineOptions.LineCapType.LineCapRound)
|
||||
customTextureList = textureList
|
||||
customTextureIndex = texIndexList
|
||||
}
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions)
|
||||
}
|
||||
|
||||
override fun clearPolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline!!.remove()
|
||||
}
|
||||
mStartMarker.isVisible = false
|
||||
mEndMarker.isVisible = false
|
||||
}
|
||||
|
||||
fun onCreateView(savedInstanceState: Bundle?) {
|
||||
mAMapNaviView.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
fun onResume() {
|
||||
mAMapNaviView.onResume()
|
||||
}
|
||||
|
||||
fun onPause() {
|
||||
mAMapNaviView.onPause()
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
mAMapNaviView.onDestroy()
|
||||
}
|
||||
|
||||
fun setCoordinatesLatLng(routeArrivied: List<LatLng>?, routeArriving: List<LatLng>?, location: MogoLocation?) {
|
||||
this.routeArrivied.clear()
|
||||
this.routeArrivied.addAll(routeArrivied!!)
|
||||
this.routeArriving.clear()
|
||||
this.routeArriving.addAll(routeArriving!!)
|
||||
this.location = location
|
||||
}
|
||||
|
||||
override fun onCameraChange(cameraPosition: CameraPosition) {
|
||||
mITaxiPassengerMapViewCallback!!.onCameraChange(cameraPosition.bearing)
|
||||
}
|
||||
|
||||
override fun onCameraChangeFinish(cameraPosition: CameraPosition) {}
|
||||
}
|
||||
@@ -1,435 +0,0 @@
|
||||
package com.mogo.och.taxi.passenger.ui;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI_P;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorInflater;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.widget.AppCompatSeekBar;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.common.module.map.AmapNaviToDestinationModel;
|
||||
import com.mogo.och.common.module.map.CommonAmapNaviVIew;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil;
|
||||
import com.mogo.och.common.module.wigets.OCHGradientTextView;
|
||||
import com.mogo.och.common.module.wigets.OCHRadiusImageView;
|
||||
import com.mogo.och.taxi.passenger.R;
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean;
|
||||
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerMapViewCallback;
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst;
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerOrderStatusEnum;
|
||||
import com.mogo.och.taxi.passenger.model.TaxiPassengerModel;
|
||||
import com.mogo.och.taxi.passenger.presenter.TaxiPassengerServingOrderPresenter;
|
||||
import com.mogo.och.taxi.passenger.utils.TPRouteDataTestUtils;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/3/8
|
||||
*/
|
||||
public class TaxiPassengerServingOrderFragment extends
|
||||
MvpFragment<TaxiPassengerServingOrderFragment, TaxiPassengerServingOrderPresenter>
|
||||
implements TaxiPassengerTaxiView, ITaxiPassengerMapViewCallback {
|
||||
|
||||
private final String TAG = TaxiPassengerServingOrderFragment.class.getSimpleName();
|
||||
|
||||
private OCHGradientTextView mTPSpeedTv;
|
||||
private TextView mTPSpeedTvShadowBg;
|
||||
|
||||
private TextView mTPOrderStatus;
|
||||
private TextView mTPOrderStartStation;
|
||||
private TextView mTPOrderEndStation;
|
||||
private TextView mTPOrderRemainDis;
|
||||
private TextView mTPOrderRemainDisUnit;
|
||||
private TextView mTPOrderRemainTime;
|
||||
private TextView mTPOrderRemainArriveTime;
|
||||
private ImageView mMapArrowIcon;
|
||||
|
||||
private TaxiPassengerMapDirectionView mMapRottingView;
|
||||
private CommonAmapNaviVIew mAmapNaviVIew;
|
||||
|
||||
private float lastBearing = 0;
|
||||
private RotateAnimation rotateAnimation;
|
||||
|
||||
private AppCompatSeekBar mProgressSeekBar;
|
||||
private TextView mProgessDes;
|
||||
|
||||
private OCHRadiusImageView mSpeedLayoutBg;
|
||||
|
||||
private int mLimitingVelocity = 0;// 返回的道路限速值
|
||||
|
||||
public static TaxiPassengerServingOrderFragment newInstance() {
|
||||
|
||||
Bundle args = new Bundle();
|
||||
|
||||
TaxiPassengerServingOrderFragment fragment = new TaxiPassengerServingOrderFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.taxi_p_activity_serving_order_view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTagName() {
|
||||
return "TaxiPassengerServingOrderFragment";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
|
||||
mTPSpeedTv = findViewById(R.id.taxi_p_speed_tv);
|
||||
mTPSpeedTvShadowBg = findViewById(R.id.taxi_p_speed_tv_bg);
|
||||
mTPSpeedTv.setVertrial(true);
|
||||
mTPSpeedTv.setmColorList(new int[]{getResources().getColor(R.color.taxi_p_speed_normal_color1),getResources().getColor(R.color.taxi_p_speed_normal_color2)});
|
||||
mTPSpeedTv.setText(String.valueOf(0));
|
||||
mTPSpeedTvShadowBg.setText(String.valueOf(0));
|
||||
|
||||
mTPOrderStatus = findViewById(R.id.taxi_p_order_status_tv);
|
||||
mTPOrderStartStation = findViewById(R.id.taxi_p_order_status_start_station_tv);
|
||||
mTPOrderEndStation = findViewById(R.id.taxi_p_order_status_end_station_tv);
|
||||
mTPOrderRemainDis = findViewById(R.id.taxi_p_order_remain_distance);
|
||||
mTPOrderRemainDisUnit = findViewById(R.id.taxi_p_order_remain_distance_unit);
|
||||
mTPOrderRemainTime = findViewById(R.id.taxi_p_order_remain_time);
|
||||
mTPOrderRemainArriveTime = findViewById(R.id.taxi_p_order_remain_arrive_time);
|
||||
|
||||
mMapArrowIcon = findViewById(R.id.taxi_p_arrow_nor);
|
||||
mProgressSeekBar = findViewById(R.id.taxi_p_seekbar);
|
||||
mProgessDes = findViewById(R.id.taxi_p_progress_des);
|
||||
|
||||
mSpeedLayoutBg = findViewById(R.id.taxi_p_speed_bg);
|
||||
|
||||
mTPOrderStatus.setOnLongClickListener(new View.OnLongClickListener() { //测试用
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
TPRouteDataTestUtils.converToRouteData();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews(Bundle savedInstanceState) {
|
||||
super.initViews(savedInstanceState);
|
||||
initRouteNaviView(savedInstanceState);
|
||||
initAmapNaviView(savedInstanceState);
|
||||
}
|
||||
|
||||
private void initAmapNaviView(Bundle savedInstanceState) {
|
||||
mAmapNaviVIew = mRootView.findViewById(R.id.taxi_p_order_amap_navi_view);
|
||||
mAmapNaviVIew.onCreate(savedInstanceState);
|
||||
TaxiPassengerModel.getInstance().startNaviByAmap();
|
||||
}
|
||||
|
||||
private void initRouteNaviView(Bundle savedInstanceState) {
|
||||
mMapRottingView = mRootView.findViewById(R.id.taxi_p_order_rotting_map_view);
|
||||
mMapRottingView.onCreateView(savedInstanceState);
|
||||
mMapRottingView.setTaxiPassengerMapViewCallback(this);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected TaxiPassengerServingOrderPresenter createPresenter() {
|
||||
return new TaxiPassengerServingOrderPresenter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进度条最大值为 起点终点首次规划出的值
|
||||
*/
|
||||
private void setSeekBarMax() {
|
||||
//计算订单起点和终点距离
|
||||
int maxInt = SharedPrefsMgr.getInstance(getContext()).getInt(TaxiPassengerConst.SP_KEY_ORDER_SUM_DIS,0);
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "maxInt = " + maxInt);
|
||||
mProgressSeekBar.setMax(maxInt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 行驶进度值更新
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private void updateDriveProcessLoading(int progressLoading) {
|
||||
int progressInt = SharedPrefsMgr.getInstance(getContext())
|
||||
.getInt(TaxiPassengerConst.SP_KEY_ORDER_SUM_DIS,0) - progressLoading;
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG,"progressInt = "+progressInt);
|
||||
mProgressSeekBar.setProgress(
|
||||
progressInt
|
||||
, true);
|
||||
mProgressSeekBar.jumpDrawablesToCurrentState();
|
||||
}
|
||||
|
||||
private void updateDriveRoadName(String currentRoadName){
|
||||
if (mProgessDes != null){
|
||||
mProgessDes.setText(currentRoadName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (mMapRottingView != null) {
|
||||
mMapRottingView.onResume();
|
||||
}
|
||||
if (mAmapNaviVIew != null){
|
||||
mAmapNaviVIew.onResume();
|
||||
}
|
||||
TaxiPassengerModel.getInstance().initGeocodeSearch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHiddenChanged(boolean hidden) {
|
||||
super.onHiddenChanged(hidden);
|
||||
|
||||
if (hidden){//fragment 隐藏, 导航取消c
|
||||
clearPolyline();
|
||||
TaxiPassengerModel.getInstance().destoryGeocodeSearch();
|
||||
}else { //fragment 显示, 导航开始
|
||||
CallerLogger.INSTANCE.e(M_TAXI_P +"TaxiPassengerNaviTo","initGeocodeSearch");
|
||||
TaxiPassengerModel.getInstance().initGeocodeSearch();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (mMapRottingView != null) {
|
||||
mMapRottingView.onPause();
|
||||
}
|
||||
if (mAmapNaviVIew != null){
|
||||
mAmapNaviVIew.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mMapRottingView != null) {
|
||||
mMapRottingView.onDestroy();
|
||||
}
|
||||
if (mAmapNaviVIew != null){
|
||||
mAmapNaviVIew.onDestroy();
|
||||
}
|
||||
AmapNaviToDestinationModel.getInstance(getContext()).destroyAmaNavi();
|
||||
TaxiPassengerModel.getInstance().destoryGeocodeSearch();
|
||||
}
|
||||
|
||||
public void showRottingMapView(){
|
||||
if (mAmapNaviVIew != null && mAmapNaviVIew.getVisibility() == View.VISIBLE){
|
||||
mAmapNaviVIew.setVisibility(View.GONE);
|
||||
}
|
||||
if (mMapRottingView != null && mMapRottingView.getVisibility() == View.GONE){
|
||||
mMapRottingView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLineMarker(List<LatLng> latLngList){
|
||||
if (latLngList.size() > 0) {
|
||||
if (mMapRottingView != null) {
|
||||
mMapRottingView.setCoordinatesLatLng(latLngList);
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapRottingView.setLineMarker();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
clearPolyline();
|
||||
}
|
||||
}
|
||||
|
||||
public void routeResultByServer(List<LatLng> latLngList,int haveArrivedIndex) {
|
||||
if (latLngList.size() > 0) {
|
||||
drawablePolylineByServerRoute(latLngList,haveArrivedIndex);
|
||||
} else {
|
||||
clearPolyline();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawablePolylineByServerRoute(List<LatLng> mCoordinatesLatLng,int haveArrivedIndex){
|
||||
if (mMapRottingView != null){
|
||||
mMapRottingView.setCoordinatesLatLng(mCoordinatesLatLng,haveArrivedIndex);
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapRottingView.drawablePolyline();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
private void clearPolyline() {
|
||||
if (mMapRottingView != null) {
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapRottingView.clearPolyline();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void updateOrderStatusView(TaxiPassengerOrderQueryRespBean.Result order) {
|
||||
mTPOrderStartStation.setText(order.startSiteAddr);
|
||||
mTPOrderEndStation.setText(order.endSiteAddr);
|
||||
|
||||
if (TaxiPassengerOrderStatusEnum.ArriveAtStart.getCode() == order.orderStatus) {
|
||||
mTPOrderStatus.setText(getString(R.string.taxi_p_arrive_to_start));
|
||||
mTPOrderRemainDis.setText("--");
|
||||
mTPOrderRemainTime.setText("--");
|
||||
mTPOrderRemainArriveTime.setText("--");
|
||||
setSeekBarMax();
|
||||
return;
|
||||
}
|
||||
|
||||
if (TaxiPassengerOrderStatusEnum.OnTheWayToEnd.getCode() == order.orderStatus) {
|
||||
mTPOrderStatus.setText(R.string.taxi_p_start_to_end);
|
||||
setSeekBarMax();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 剩余里程,剩余时间,当前定位点所在道路
|
||||
* @param meters 单位 米
|
||||
* @param remainTime 单位 秒
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public void onCurrentOrderDistToEndChanged(long meters, long remainTime) {
|
||||
String disUnit = "公里";
|
||||
String remainDis = "0";
|
||||
|
||||
if (meters > 0){
|
||||
if (meters / 1000 < 1){
|
||||
disUnit = "米";
|
||||
remainDis = String.valueOf(Math.round(meters));
|
||||
}else {
|
||||
disUnit = "公里";
|
||||
remainDis = NumberFormatUtil.formatLong((double) meters / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
int time = (int)Math.ceil((double)remainTime/ 60f);
|
||||
|
||||
Calendar beforeTime = Calendar.getInstance();
|
||||
beforeTime.add(Calendar.MINUTE,time);
|
||||
String arriveTime = DateTimeUtil.formatCalendarToString(beforeTime,DateTimeUtil.HH_mm);
|
||||
updateOrderDisAndTimeView(remainDis, disUnit,time, arriveTime);
|
||||
updateDriveProcessLoading(new Long(meters).intValue());
|
||||
}
|
||||
|
||||
public void onCurrentRoadName(String roadName){
|
||||
updateDriveRoadName(roadName);
|
||||
}
|
||||
|
||||
private void updateOrderDisAndTimeView(String remainDis, String remainDisUnit, int remainTime, String arriveTime) {
|
||||
mTPOrderRemainDis.setText(remainDis);
|
||||
mTPOrderRemainDisUnit.setText(remainDisUnit);
|
||||
mTPOrderRemainTime.setText(String.valueOf(remainTime));
|
||||
mTPOrderRemainArriveTime.setText(arriveTime);
|
||||
|
||||
}
|
||||
|
||||
public void onCarLocationChanged(MogoLocation location) {
|
||||
updateSpeedView((float) location.getGnssSpeed());
|
||||
}
|
||||
|
||||
public void onLimitingVelocityChange(int limitingVelocity) {
|
||||
mLimitingVelocity = limitingVelocity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新速度
|
||||
*
|
||||
* @param newSpeed
|
||||
*/
|
||||
private void updateSpeedView(float newSpeed) {
|
||||
int speed = (int) (Math.abs(newSpeed) * 3.6F); // 倒车时工控机反馈定位信息中speed为负值
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG,"mLimitingVelocity = "+mLimitingVelocity);
|
||||
// if (mLimitingVelocity > 0 && speed >= mLimitingVelocity) {
|
||||
// mTPSpeedTv.setmColorList(new int[]{getResources().getColor(R.color.taxi_p_speed_warn_color1),getResources().getColor(R.color.taxi_p_speed_warn_color2)});
|
||||
// mTPSpeedTv.setText(String.valueOf(speed));
|
||||
// mTPSpeedTvShadowBg.setText(String.valueOf(speed));
|
||||
//
|
||||
// mSpeedLayoutBg.setImageResource(R.drawable.taxi_p_speed_light_red_bg);
|
||||
// } else {
|
||||
mTPSpeedTv.setmColorList(new int[]{getResources().getColor(R.color.taxi_p_speed_normal_color1),getResources().getColor(R.color.taxi_p_speed_normal_color2)});
|
||||
mTPSpeedTv.setText(String.valueOf(speed));
|
||||
mTPSpeedTvShadowBg.setText(String.valueOf(speed));
|
||||
|
||||
mSpeedLayoutBg.setImageResource(R.drawable.taxi_p_speed_light_green_bg);
|
||||
// }
|
||||
}
|
||||
|
||||
private void runOnUIThread(Runnable executor) {
|
||||
if (executor == null) {
|
||||
return;
|
||||
}
|
||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
UiThreadHandler.post(executor);
|
||||
} else {
|
||||
executor.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange(float bearing) {
|
||||
startIvCompass(bearing);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置指南针旋转
|
||||
*
|
||||
* @param bearing
|
||||
*/
|
||||
private void startIvCompass(float bearing) {
|
||||
bearing = 360 - bearing;
|
||||
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "startIvCompass: " + bearing);
|
||||
rotateAnimation = new RotateAnimation(lastBearing, bearing, Animation.RELATIVE_TO_SELF
|
||||
, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
rotateAnimation.setFillAfter(true);
|
||||
|
||||
mMapArrowIcon.startAnimation(rotateAnimation);
|
||||
lastBearing = bearing;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
|
||||
if (transit == FragmentTransaction.TRANSIT_FRAGMENT_OPEN) {
|
||||
if (enter) {//普通的进入的动作
|
||||
return AnimatorInflater.loadAnimator(getContext(),R.animator.alpha_hide_show_f);
|
||||
} else {//比如一个已经Fragmen被另一个replace,是一个进入动作,被replace的那个就是false
|
||||
return AnimatorInflater.loadAnimator(getContext(),R.animator.alpha_hide_hide_f);
|
||||
}
|
||||
} else if (FragmentTransaction.TRANSIT_FRAGMENT_CLOSE == transit) {
|
||||
if (enter) {//之前被replace的重新进入到界面或者Fragment回到栈顶
|
||||
return AnimatorInflater.loadAnimator(getContext(),R.animator.alpha_hide_show_f);
|
||||
} else {//Fragment退出,出栈
|
||||
return AnimatorInflater.loadAnimator(getContext(),R.animator.alpha_hide_hide_f);
|
||||
}
|
||||
}
|
||||
return super.onCreateAnimator(transit,enter,nextAnim);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,369 @@
|
||||
package com.mogo.och.taxi.passenger.ui
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorInflater
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.RotateAnimation
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.widget.AppCompatSeekBar
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.common.module.map.AmapNaviToDestinationModel
|
||||
import com.mogo.och.common.module.map.CommonAmapNaviVIew
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil
|
||||
import com.mogo.och.common.module.wigets.OCHGradientTextView
|
||||
import com.mogo.och.common.module.wigets.OCHRadiusImageView
|
||||
import com.mogo.och.taxi.passenger.R
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerOrderQueryRespBean
|
||||
import com.mogo.och.taxi.passenger.callback.ITaxiPassengerMapViewCallback
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerConst
|
||||
import com.mogo.och.taxi.passenger.constant.TaxiPassengerOrderStatusEnum
|
||||
import com.mogo.och.taxi.passenger.model.TaxiPassengerModel
|
||||
import com.mogo.och.taxi.passenger.presenter.TaxiPassengerServingOrderPresenter
|
||||
import com.mogo.och.taxi.passenger.utils.TPRouteDataTestUtils
|
||||
import java.util.Calendar
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2022/3/8
|
||||
*/
|
||||
class TaxiPassengerServingOrderFragment :
|
||||
MvpFragment<TaxiPassengerServingOrderFragment?, TaxiPassengerServingOrderPresenter?>(),
|
||||
TaxiPassengerTaxiView, ITaxiPassengerMapViewCallback {
|
||||
private val TAG = TaxiPassengerServingOrderFragment::class.java.simpleName
|
||||
private var mTPSpeedTv: OCHGradientTextView? = null
|
||||
private var mTPSpeedTvShadowBg: TextView? = null
|
||||
private var mTPOrderStatus: TextView? = null
|
||||
private var mTPOrderStartStation: TextView? = null
|
||||
private var mTPOrderEndStation: TextView? = null
|
||||
private var mTPOrderRemainDis: TextView? = null
|
||||
private var mTPOrderRemainDisUnit: TextView? = null
|
||||
private var mTPOrderRemainTime: TextView? = null
|
||||
private var mTPOrderRemainArriveTime: TextView? = null
|
||||
private var mMapArrowIcon: ImageView? = null
|
||||
private var mMapRottingView: TaxiPassengerMapDirectionView? = null
|
||||
private var mAmapNaviVIew: CommonAmapNaviVIew? = null
|
||||
private var lastBearing = 0f
|
||||
private var rotateAnimation: RotateAnimation? = null
|
||||
private var mProgressSeekBar: AppCompatSeekBar? = null
|
||||
private var mProgessDes: TextView? = null
|
||||
private var mSpeedLayoutBg: OCHRadiusImageView? = null
|
||||
private var mLimitingVelocity = 0 // 返回的道路限速值
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.taxi_p_activity_serving_order_view
|
||||
}
|
||||
|
||||
override fun getTagName(): String {
|
||||
return "TaxiPassengerServingOrderFragment"
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
mTPSpeedTv = findViewById(R.id.taxi_p_speed_tv)
|
||||
mTPSpeedTvShadowBg = findViewById(R.id.taxi_p_speed_tv_bg)
|
||||
mTPSpeedTv!!.setVertrial(true)
|
||||
mTPSpeedTv!!.setmColorList(
|
||||
intArrayOf(
|
||||
resources.getColor(R.color.taxi_p_speed_normal_color1), resources.getColor(
|
||||
R.color.taxi_p_speed_normal_color2
|
||||
)
|
||||
)
|
||||
)
|
||||
mTPSpeedTv!!.text = 0.toString()
|
||||
mTPSpeedTvShadowBg!!.text = 0.toString()
|
||||
mTPOrderStatus = findViewById(R.id.taxi_p_order_status_tv)
|
||||
mTPOrderStartStation = findViewById(R.id.taxi_p_order_status_start_station_tv)
|
||||
mTPOrderEndStation = findViewById(R.id.taxi_p_order_status_end_station_tv)
|
||||
mTPOrderRemainDis = findViewById(R.id.taxi_p_order_remain_distance)
|
||||
mTPOrderRemainDisUnit = findViewById(R.id.taxi_p_order_remain_distance_unit)
|
||||
mTPOrderRemainTime = findViewById(R.id.taxi_p_order_remain_time)
|
||||
mTPOrderRemainArriveTime = findViewById(R.id.taxi_p_order_remain_arrive_time)
|
||||
mMapArrowIcon = findViewById(R.id.taxi_p_arrow_nor)
|
||||
mProgressSeekBar = findViewById(R.id.taxi_p_seekbar)
|
||||
mProgessDes = findViewById(R.id.taxi_p_progress_des)
|
||||
mSpeedLayoutBg = findViewById(R.id.taxi_p_speed_bg)
|
||||
mTPOrderStatus!!.setOnLongClickListener {
|
||||
TPRouteDataTestUtils.converToRouteData()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
override fun initViews(savedInstanceState: Bundle?) {
|
||||
super.initViews(savedInstanceState)
|
||||
initRouteNaviView(savedInstanceState)
|
||||
initAmapNaviView(savedInstanceState)
|
||||
}
|
||||
|
||||
private fun initAmapNaviView(savedInstanceState: Bundle?) {
|
||||
mAmapNaviVIew = findViewById(R.id.taxi_p_order_amap_navi_view)
|
||||
mAmapNaviVIew?.onCreate(savedInstanceState)
|
||||
TaxiPassengerModel.getInstance().startNaviByAmap()
|
||||
}
|
||||
|
||||
private fun initRouteNaviView(savedInstanceState: Bundle?) {
|
||||
mMapRottingView = findViewById(R.id.taxi_p_order_rotting_map_view)
|
||||
mMapRottingView?.onCreateView(savedInstanceState)
|
||||
mMapRottingView?.setTaxiPassengerMapViewCallback(this)
|
||||
}
|
||||
|
||||
override fun createPresenter(): TaxiPassengerServingOrderPresenter {
|
||||
return TaxiPassengerServingOrderPresenter(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进度条最大值为 起点终点首次规划出的值
|
||||
*/
|
||||
private fun setSeekBarMax() {
|
||||
//计算订单起点和终点距离
|
||||
val maxInt = SharedPrefsMgr.getInstance(requireContext())
|
||||
.getInt(TaxiPassengerConst.SP_KEY_ORDER_SUM_DIS, 0)
|
||||
d(SceneConstant.M_TAXI_P + TAG, "maxInt = $maxInt")
|
||||
mProgressSeekBar!!.max = maxInt
|
||||
}
|
||||
|
||||
/**
|
||||
* 行驶进度值更新
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private fun updateDriveProcessLoading(progressLoading: Int) {
|
||||
val progressInt = SharedPrefsMgr.getInstance(requireContext())
|
||||
.getInt(TaxiPassengerConst.SP_KEY_ORDER_SUM_DIS, 0) - progressLoading
|
||||
d(SceneConstant.M_TAXI_P + TAG, "progressInt = $progressInt")
|
||||
mProgressSeekBar?.setProgress(progressInt, true)
|
||||
mProgressSeekBar?.jumpDrawablesToCurrentState()
|
||||
}
|
||||
|
||||
private fun updateDriveRoadName(currentRoadName: String) {
|
||||
mProgessDes?.text = currentRoadName
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mMapRottingView?.onResume()
|
||||
mAmapNaviVIew?.onResume()
|
||||
TaxiPassengerModel.getInstance().initGeocodeSearch()
|
||||
}
|
||||
|
||||
override fun onHiddenChanged(hidden: Boolean) {
|
||||
super.onHiddenChanged(hidden)
|
||||
if (hidden) { //fragment 隐藏, 导航取消c
|
||||
clearPolyline()
|
||||
TaxiPassengerModel.getInstance().destoryGeocodeSearch()
|
||||
} else { //fragment 显示, 导航开始
|
||||
e(SceneConstant.M_TAXI_P + "TaxiPassengerNaviTo", "initGeocodeSearch")
|
||||
TaxiPassengerModel.getInstance().initGeocodeSearch()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mMapRottingView?.onPause()
|
||||
mAmapNaviVIew?.onPause()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mMapRottingView?.onDestroy()
|
||||
mAmapNaviVIew?.onDestroy()
|
||||
AmapNaviToDestinationModel.getInstance(context).destroyAmaNavi()
|
||||
TaxiPassengerModel.getInstance().destoryGeocodeSearch()
|
||||
}
|
||||
|
||||
fun showRottingMapView() {
|
||||
if (mAmapNaviVIew != null && mAmapNaviVIew!!.visibility == View.VISIBLE) {
|
||||
mAmapNaviVIew!!.visibility = View.GONE
|
||||
}
|
||||
if (mMapRottingView != null && mMapRottingView!!.visibility == View.GONE) {
|
||||
mMapRottingView!!.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
fun setLineMarker(startStation: LatLng?, endStation: LatLng?) {
|
||||
if (startStation != null && endStation != null) {
|
||||
UiThreadHandler.post { mMapRottingView?.setLineMarker(startStation, endStation) }
|
||||
} else {
|
||||
clearPolyline()
|
||||
}
|
||||
}
|
||||
|
||||
fun routeResultByServer(
|
||||
routeArriviedTemp: List<LatLng>?,
|
||||
routeArrivingTemp: List<LatLng>?,
|
||||
location: MogoLocation
|
||||
) {
|
||||
if (routeArriviedTemp.isNullOrEmpty()||routeArrivingTemp.isNullOrEmpty()) {
|
||||
clearPolyline()
|
||||
} else {
|
||||
drawablePolylineByServerRoute(routeArriviedTemp, routeArrivingTemp,location)
|
||||
}
|
||||
}
|
||||
|
||||
private fun drawablePolylineByServerRoute(routeArrivied: List<LatLng>?,
|
||||
routeArriving: List<LatLng>?,
|
||||
location: MogoLocation?) {
|
||||
mMapRottingView?.setCoordinatesLatLng(routeArrivied, routeArriving,location)
|
||||
UiThreadHandler.post { mMapRottingView?.drawablePolyline() }
|
||||
}
|
||||
|
||||
private fun clearPolyline() {
|
||||
UiThreadHandler.post { mMapRottingView?.clearPolyline() }
|
||||
}
|
||||
|
||||
fun updateOrderStatusView(order: TaxiPassengerOrderQueryRespBean.Result) {
|
||||
mTPOrderStartStation!!.text = order.startSiteAddr
|
||||
mTPOrderEndStation!!.text = order.endSiteAddr
|
||||
if (TaxiPassengerOrderStatusEnum.ArriveAtStart.code == order.orderStatus) {
|
||||
mTPOrderStatus!!.text = getString(R.string.taxi_p_arrive_to_start)
|
||||
mTPOrderRemainDis!!.text = "--"
|
||||
mTPOrderRemainTime!!.text = "--"
|
||||
mTPOrderRemainArriveTime!!.text = "--"
|
||||
setSeekBarMax()
|
||||
return
|
||||
}
|
||||
if (TaxiPassengerOrderStatusEnum.OnTheWayToEnd.code == order.orderStatus) {
|
||||
mTPOrderStatus!!.setText(R.string.taxi_p_start_to_end)
|
||||
setSeekBarMax()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 剩余里程,剩余时间,当前定位点所在道路
|
||||
* @param meters 单位 米
|
||||
* @param remainTime 单位 秒
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
fun onCurrentOrderDistToEndChanged(meters: Long, remainTime: Long) {
|
||||
var disUnit = "公里"
|
||||
var remainDis = "0"
|
||||
if (meters > 0) {
|
||||
if (meters / 1000 < 1) {
|
||||
disUnit = "米"
|
||||
remainDis = Math.round(meters.toFloat()).toString()
|
||||
} else {
|
||||
disUnit = "公里"
|
||||
remainDis = NumberFormatUtil.formatLong(meters.toDouble() / 1000)
|
||||
}
|
||||
}
|
||||
val time = Math.ceil(remainTime.toDouble() / 60f).toInt()
|
||||
val beforeTime = Calendar.getInstance()
|
||||
beforeTime.add(Calendar.MINUTE, time)
|
||||
val arriveTime = DateTimeUtil.formatCalendarToString(beforeTime, DateTimeUtil.HH_mm)
|
||||
updateOrderDisAndTimeView(remainDis, disUnit, time, arriveTime)
|
||||
updateDriveProcessLoading(meters.toInt())
|
||||
}
|
||||
|
||||
fun onCurrentRoadName(roadName: String) {
|
||||
updateDriveRoadName(roadName)
|
||||
}
|
||||
|
||||
private fun updateOrderDisAndTimeView(
|
||||
remainDis: String,
|
||||
remainDisUnit: String,
|
||||
remainTime: Int,
|
||||
arriveTime: String
|
||||
) {
|
||||
mTPOrderRemainDis!!.text = remainDis
|
||||
mTPOrderRemainDisUnit!!.text = remainDisUnit
|
||||
mTPOrderRemainTime!!.text = remainTime.toString()
|
||||
mTPOrderRemainArriveTime!!.text = arriveTime
|
||||
}
|
||||
|
||||
fun onCarLocationChanged(location: MogoLocation) {
|
||||
updateSpeedView(location.gnssSpeed)
|
||||
}
|
||||
|
||||
fun onLimitingVelocityChange(limitingVelocity: Int) {
|
||||
mLimitingVelocity = limitingVelocity
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新速度
|
||||
*
|
||||
* @param newSpeed
|
||||
*/
|
||||
private fun updateSpeedView(newSpeed: Float) {
|
||||
val speed = (Math.abs(newSpeed) * 3.6f).toInt() // 倒车时工控机反馈定位信息中speed为负值
|
||||
d(SceneConstant.M_TAXI_P + TAG, "mLimitingVelocity = $mLimitingVelocity")
|
||||
mTPSpeedTv?.setmColorList(
|
||||
intArrayOf(
|
||||
resources.getColor(R.color.taxi_p_speed_normal_color1), resources.getColor(
|
||||
R.color.taxi_p_speed_normal_color2
|
||||
)
|
||||
)
|
||||
)
|
||||
mTPSpeedTv?.text = speed.toString()
|
||||
mTPSpeedTvShadowBg?.text = speed.toString()
|
||||
mSpeedLayoutBg?.setImageResource(R.drawable.taxi_p_speed_light_green_bg)
|
||||
}
|
||||
|
||||
override fun onCameraChange(bearing: Float) {
|
||||
startIvCompass(360-bearing)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置指南针旋转
|
||||
*
|
||||
* @param bearing
|
||||
*/
|
||||
private fun startIvCompass(bearing: Float) {
|
||||
d(SceneConstant.M_TAXI_P + TAG, "startIvCompass: $bearing")
|
||||
rotateAnimation = RotateAnimation(
|
||||
lastBearing, bearing, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f
|
||||
)
|
||||
rotateAnimation!!.fillAfter = true
|
||||
mMapArrowIcon!!.startAnimation(rotateAnimation)
|
||||
lastBearing = bearing
|
||||
}
|
||||
|
||||
override fun onCreateAnimator(transit: Int, enter: Boolean, nextAnim: Int): Animator? {
|
||||
if (transit == FragmentTransaction.TRANSIT_FRAGMENT_OPEN) {
|
||||
return if (enter) { //普通的进入的动作
|
||||
AnimatorInflater.loadAnimator(
|
||||
context,
|
||||
R.animator.alpha_hide_show_f
|
||||
)
|
||||
} else { //比如一个已经Fragmen被另一个replace,是一个进入动作,被replace的那个就是false
|
||||
AnimatorInflater.loadAnimator(
|
||||
context,
|
||||
R.animator.alpha_hide_hide_f
|
||||
)
|
||||
}
|
||||
} else if (FragmentTransaction.TRANSIT_FRAGMENT_CLOSE == transit) {
|
||||
return if (enter) { //之前被replace的重新进入到界面或者Fragment回到栈顶
|
||||
AnimatorInflater.loadAnimator(
|
||||
context,
|
||||
R.animator.alpha_hide_show_f
|
||||
)
|
||||
} else { //Fragment退出,出栈
|
||||
AnimatorInflater.loadAnimator(
|
||||
context,
|
||||
R.animator.alpha_hide_hide_f
|
||||
)
|
||||
}
|
||||
}
|
||||
return super.onCreateAnimator(transit, enter, nextAnim)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(): TaxiPassengerServingOrderFragment {
|
||||
val args = Bundle()
|
||||
val fragment = TaxiPassengerServingOrderFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -934,7 +934,7 @@ public class CarouselLayoutManager extends RecyclerView.LayoutManager implements
|
||||
}
|
||||
|
||||
private CarouselSavedState(@NonNull final Parcel in) {
|
||||
mSuperState = in.readParcelable(Parcelable.class.getClassLoader());
|
||||
mSuperState = in.readParcelable(RecyclerView.LayoutManager.class.getClassLoader());
|
||||
mCenterItemPosition = in.readInt();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ public class TPRouteDataTestUtils {
|
||||
builder.setLongitude(s.getDouble("lon"));
|
||||
list.add(builder.build());
|
||||
}
|
||||
TaxiPassengerModel.getInstance().setRouteLineMarker(list);
|
||||
TaxiPassengerModel.getInstance().startToRouteAndWipe(list);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1,330 +0,0 @@
|
||||
package com.mogo.och.taxi.ui;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
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.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.maps.model.PolylineOptions;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.taxi.R;
|
||||
import com.mogo.och.taxi.utils.TaxiMapAssetStyleUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* taxi司机端前往目的地小地图导航
|
||||
*/
|
||||
public class TaxiMapDirectionView
|
||||
extends RelativeLayout
|
||||
implements IMoGoChassisLocationGCJ02Listener, ITaxiMapDirectionView, AMap.OnCameraChangeListener {
|
||||
|
||||
//小地图名称
|
||||
public static final String TAG = "TPMapDirectionView";
|
||||
|
||||
private TextureMapView mAMapNaviView;
|
||||
private AMap mAMap;
|
||||
private Marker mCarMarker;
|
||||
private Marker mStartMarker;
|
||||
private Marker mEndMarker;
|
||||
|
||||
private final int zoomLevel = 13;
|
||||
private final List<LatLng> routeArrivied = new ArrayList<>();
|
||||
private final List<LatLng> routeArriving = new ArrayList<>();
|
||||
private MogoLocation location;
|
||||
|
||||
private LatLng startStation;
|
||||
private LatLng endStation;
|
||||
private Polyline mPolyline;
|
||||
|
||||
List<BitmapDescriptor> textureList = new ArrayList<>();
|
||||
List<Integer> texIndexList = new ArrayList<>();
|
||||
|
||||
private BitmapDescriptor mArrivedRes;
|
||||
private BitmapDescriptor mUnArrivedRes;
|
||||
|
||||
public TaxiMapDirectionView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public TaxiMapDirectionView(Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public TaxiMapDirectionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
try {
|
||||
initView(context);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initView(Context context) {
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "initView");
|
||||
|
||||
View smpView = LayoutInflater.from(context).inflate(R.layout.taxi_map_view, this);
|
||||
|
||||
mAMapNaviView = smpView.findViewById(R.id.taxi_amap_view);
|
||||
|
||||
initAMapView();
|
||||
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, 10, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
private void initAMapView() {
|
||||
CameraUpdate mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
mAMap = mAMapNaviView.getMap();
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);
|
||||
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.setTrafficEnabled(false);
|
||||
|
||||
// 设置 锚点 图标
|
||||
mCarMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_car))
|
||||
.anchor(0.5f, 0.5f));
|
||||
mStartMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_view_dir_start)));
|
||||
mEndMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_view_dir_end)));
|
||||
mStartMarker.setVisible(false);
|
||||
mEndMarker.setVisible(false);
|
||||
|
||||
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_arrow_arrived);
|
||||
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_arrow_un_arrive);
|
||||
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiMapAssetStyleUtil.getAssetsStyle(getContext(), "map_style.data"))
|
||||
.setStyleExtraData(TaxiMapAssetStyleUtil.getAssetsExtraStyle(getContext(), "map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap.moveCamera(mCameraUpdate);
|
||||
|
||||
// 设置地图的样式
|
||||
UiSettings uiSettings = mAMap.getUiSettings();
|
||||
uiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮
|
||||
uiSettings.setAllGesturesEnabled(false);// 所有手势
|
||||
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
|
||||
uiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
|
||||
mAMap.setOnMapLoadedListener(new AMap.OnMapLoadedListener() {
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "smp---onMapLoaded");
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiMapAssetStyleUtil.getAssetsStyle(getContext(), "map_style.data"))
|
||||
.setStyleExtraData(TaxiMapAssetStyleUtil.getAssetsExtraStyle(getContext(), "map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
mAMapNaviView.getMap().setPointToCenter(mAMapNaviView.getWidth() / 2, mAMapNaviView.getHeight() / 2);
|
||||
}
|
||||
});
|
||||
|
||||
//设置地图状态的监听接口
|
||||
mAMap.setOnCameraChangeListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
if (gnssInfo == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
LatLng currentLatLng = new LatLng(gnssInfo.getLatitude(), gnssInfo.getLongitude());
|
||||
if (mPolyline!=null&&mPolyline.getPoints().size() > 1) {
|
||||
List<LatLng> points = mPolyline.getPoints();
|
||||
//圈定地图显示范围
|
||||
LatLng endLatLng = points.get(points.size() - 1);
|
||||
//存放经纬度
|
||||
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
|
||||
boundsBuilder.include(currentLatLng);
|
||||
boundsBuilder.include(endLatLng);
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100));
|
||||
|
||||
} else {
|
||||
//设置希望展示的地图缩放级别
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
.target(mCarMarker.getPosition()).tilt(0).bearing((float) gnssInfo.getHeading()).zoom(zoomLevel).build();
|
||||
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
}
|
||||
//更新车辆位置
|
||||
if (mCarMarker != null) {
|
||||
mCarMarker.setRotateAngle((float) (360 - gnssInfo.getHeading()));
|
||||
mCarMarker.setPosition(currentLatLng);
|
||||
mCarMarker.setToTop();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineMarker() {
|
||||
if (mStartMarker != null && mEndMarker != null
|
||||
&& mStartMarker.isVisible() && mEndMarker.isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (startStation != null && endStation != null) {
|
||||
// 设置开始结束Marker位置
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setPosition(startStation);
|
||||
mStartMarker.setVisible(true);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setPosition(endStation);
|
||||
mEndMarker.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawablePolyline() {
|
||||
if(routeArrivied.isEmpty()&&routeArriving.isEmpty()){
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "没有点");
|
||||
return;
|
||||
}
|
||||
texIndexList.clear();
|
||||
ArrayList<LatLng> allPoints = new ArrayList<>(routeArrivied);
|
||||
for (int i = 0; i < routeArrivied.size(); i++) {
|
||||
if(routeArrivied.size()>1&&i<routeArrivied.size()-1){
|
||||
texIndexList.add(0);
|
||||
}
|
||||
}
|
||||
texIndexList.add(0);
|
||||
allPoints.add(new LatLng(location.getLatitude(),location.getLongitude()));
|
||||
allPoints.addAll(routeArriving);
|
||||
for (LatLng ignored : routeArrivied) {
|
||||
texIndexList.add(1);
|
||||
}
|
||||
|
||||
if (mPolyline != null) {
|
||||
mPolyline.setPoints(allPoints);
|
||||
mPolyline.getOptions().setCustomTextureIndex(texIndexList);
|
||||
return;
|
||||
}
|
||||
textureList.add(mArrivedRes);
|
||||
textureList.add(mUnArrivedRes);
|
||||
if (mAMap != null) {
|
||||
//设置线段纹理
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
polylineOptions.addAll(allPoints);
|
||||
polylineOptions.setUseTexture(true);
|
||||
polylineOptions.width(15);
|
||||
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound);
|
||||
polylineOptions.setCustomTextureList(textureList);
|
||||
polylineOptions.setCustomTextureIndex(texIndexList);
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreateView(Bundle savedInstanceState) {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
public void setStartMarkAndEndMark(LatLng startStation, LatLng endStation) {
|
||||
this.startStation = startStation;
|
||||
this.endStation = endStation;
|
||||
}
|
||||
|
||||
public void setCoordinatesLatLng(List<LatLng> routeArrivied, List<LatLng> routeArriving, MogoLocation location) {
|
||||
this.routeArrivied.clear();
|
||||
this.routeArrivied.addAll(routeArrivied);
|
||||
this.routeArriving.clear();
|
||||
this.routeArriving.addAll(routeArriving);
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition cameraPosition) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinish(CameraPosition cameraPosition) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
package com.mogo.och.taxi.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.widget.RelativeLayout
|
||||
import com.amap.api.maps.AMap
|
||||
import com.amap.api.maps.CameraUpdateFactory
|
||||
import com.amap.api.maps.TextureMapView
|
||||
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.maps.model.PolylineOptions
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.och.taxi.R
|
||||
import com.mogo.och.taxi.utils.TaxiMapAssetStyleUtil
|
||||
|
||||
/**
|
||||
* taxi司机端前往目的地小地图导航
|
||||
*/
|
||||
class TaxiMapDirectionView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener,
|
||||
ITaxiMapDirectionView, AMap.OnCameraChangeListener {
|
||||
private lateinit var mAMapNaviView: TextureMapView
|
||||
private lateinit var mAMap: AMap
|
||||
private var mCarMarker: Marker? = null
|
||||
private lateinit var mStartMarker: Marker
|
||||
private lateinit var mEndMarker: Marker
|
||||
private val zoomLevel = 13
|
||||
private val routeArrivied: MutableList<LatLng> = ArrayList()
|
||||
private val routeArriving: MutableList<LatLng> = ArrayList()
|
||||
private var location: MogoLocation? = null
|
||||
private var startStation: LatLng? = null
|
||||
private var endStation: LatLng? = null
|
||||
private var mPolyline: Polyline? = null
|
||||
var textureList: MutableList<BitmapDescriptor?> = ArrayList()
|
||||
var texIndexList: MutableList<Int> = ArrayList()
|
||||
private var mArrivedRes: BitmapDescriptor? = null
|
||||
private var mUnArrivedRes: BitmapDescriptor? = null
|
||||
|
||||
init {
|
||||
try {
|
||||
initView(context)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initView(context: Context) {
|
||||
d(SceneConstant.M_TAXI + TAG, "initView")
|
||||
val smpView = LayoutInflater.from(context).inflate(R.layout.taxi_map_view, this)
|
||||
mAMapNaviView = smpView.findViewById(R.id.taxi_amap_view)
|
||||
initAMapView()
|
||||
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10, this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
private fun initAMapView() {
|
||||
val mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel.toFloat())
|
||||
mAMap = mAMapNaviView.map
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap.mapType = AMap.MAP_TYPE_NIGHT
|
||||
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.isTrafficEnabled = false
|
||||
|
||||
// 设置 锚点 图标
|
||||
mCarMarker = mAMap.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_car)).anchor(0.5f, 0.5f))
|
||||
mStartMarker = mAMap.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_view_dir_start)))
|
||||
mEndMarker = mAMap.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_view_dir_end)))
|
||||
mStartMarker.isVisible = false
|
||||
mEndMarker.isVisible = false
|
||||
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_arrow_arrived)
|
||||
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_arrow_un_arrive)
|
||||
|
||||
// 加载自定义样式
|
||||
val customMapStyleOptions = CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiMapAssetStyleUtil.getAssetsStyle(context, "map_style.data"))
|
||||
.setStyleExtraData(
|
||||
TaxiMapAssetStyleUtil.getAssetsExtraStyle(
|
||||
context,
|
||||
"map_style_extra.data"
|
||||
)
|
||||
)
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions)
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap.moveCamera(mCameraUpdate)
|
||||
|
||||
// 设置地图的样式
|
||||
mAMap.uiSettings.apply {
|
||||
isZoomControlsEnabled = false // 地图缩放级别的交换按钮
|
||||
setAllGesturesEnabled(false) // 所有手势
|
||||
isMyLocationButtonEnabled = false // 显示默认的定位按钮
|
||||
setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
}
|
||||
mAMap.setOnMapLoadedListener(AMap.OnMapLoadedListener {
|
||||
d(SceneConstant.M_TAXI + TAG, "smp---onMapLoaded")
|
||||
// 加载自定义样式
|
||||
val customMapStyleOptions = CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiMapAssetStyleUtil.getAssetsStyle(context, "map_style.data"))
|
||||
.setStyleExtraData(
|
||||
TaxiMapAssetStyleUtil.getAssetsExtraStyle(
|
||||
context,
|
||||
"map_style_extra.data"
|
||||
)
|
||||
)
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions)
|
||||
mAMapNaviView.map.setPointToCenter(
|
||||
mAMapNaviView.width / 2,
|
||||
mAMapNaviView.height / 2
|
||||
)
|
||||
})
|
||||
|
||||
//设置地图状态的监听接口
|
||||
mAMap.setOnCameraChangeListener(this)
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
if (mogoLocation == null) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
val currentLatLng = LatLng(mogoLocation.latitude, mogoLocation.longitude)
|
||||
if (mPolyline != null && mPolyline!!.points.size > 1) {
|
||||
val points = mPolyline!!.points
|
||||
//圈定地图显示范围
|
||||
val endLatLng = points[points.size - 1]
|
||||
//存放经纬度
|
||||
val boundsBuilder = LatLngBounds.Builder()
|
||||
boundsBuilder.include(currentLatLng)
|
||||
boundsBuilder.include(endLatLng)
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.moveCamera(
|
||||
CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100)
|
||||
)
|
||||
} else {
|
||||
//设置希望展示的地图缩放级别
|
||||
val cameraPosition = CameraPosition.Builder()
|
||||
.target(mCarMarker!!.position).tilt(0f).bearing(mogoLocation.heading.toFloat())
|
||||
.zoom(zoomLevel.toFloat()).build()
|
||||
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
|
||||
}
|
||||
//更新车辆位置
|
||||
if (mCarMarker != null) {
|
||||
mCarMarker!!.rotateAngle = (360 - mogoLocation.heading).toFloat()
|
||||
mCarMarker!!.position = currentLatLng
|
||||
mCarMarker!!.setToTop()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun setLineMarker() {
|
||||
if (mStartMarker.isVisible && mEndMarker.isVisible
|
||||
) {
|
||||
return
|
||||
}
|
||||
if (startStation != null && endStation != null) {
|
||||
// 设置开始结束Marker位置
|
||||
mStartMarker.position = startStation
|
||||
mStartMarker.isVisible = true
|
||||
mEndMarker.position = endStation
|
||||
mEndMarker.isVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun drawablePolyline() {
|
||||
if (routeArrivied.isEmpty() && routeArriving.isEmpty()) {
|
||||
d(SceneConstant.M_TAXI + TAG, "没有点")
|
||||
return
|
||||
}
|
||||
texIndexList.clear()
|
||||
val allPoints = ArrayList(routeArrivied)
|
||||
for (i in routeArrivied.indices) {
|
||||
if (routeArrivied.size > 1 && i < routeArrivied.size - 1) {
|
||||
texIndexList.add(0)
|
||||
}
|
||||
}
|
||||
texIndexList.add(0)
|
||||
allPoints.add(LatLng(location!!.latitude, location!!.longitude))
|
||||
allPoints.addAll(routeArriving)
|
||||
for (ignored in routeArrivied) {
|
||||
texIndexList.add(1)
|
||||
}
|
||||
if (mPolyline != null) {
|
||||
mPolyline!!.points = allPoints
|
||||
mPolyline!!.options.customTextureIndex = texIndexList
|
||||
return
|
||||
}
|
||||
textureList.add(mArrivedRes)
|
||||
textureList.add(mUnArrivedRes)
|
||||
//设置线段纹理
|
||||
val polylineOptions = PolylineOptions().apply {
|
||||
addAll(allPoints)
|
||||
isUseTexture = true
|
||||
width(15f)
|
||||
lineCapType(PolylineOptions.LineCapType.LineCapRound)
|
||||
customTextureList = textureList
|
||||
customTextureIndex = texIndexList
|
||||
}
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions)
|
||||
}
|
||||
|
||||
override fun clearPolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline!!.remove()
|
||||
}
|
||||
mStartMarker.isVisible = false
|
||||
mEndMarker.isVisible = false
|
||||
}
|
||||
|
||||
fun onCreateView(savedInstanceState: Bundle?) {
|
||||
mAMapNaviView.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
fun onResume() {
|
||||
mAMapNaviView.onResume()
|
||||
}
|
||||
|
||||
fun onPause() {
|
||||
mAMapNaviView.onPause()
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
mAMapNaviView.onDestroy()
|
||||
}
|
||||
|
||||
fun setStartMarkAndEndMark(startStation: LatLng?, endStation: LatLng?) {
|
||||
this.startStation = startStation
|
||||
this.endStation = endStation
|
||||
}
|
||||
|
||||
fun setCoordinatesLatLng(
|
||||
routeArrivied: List<LatLng>?,
|
||||
routeArriving: List<LatLng>?,
|
||||
location: MogoLocation?
|
||||
) {
|
||||
this.routeArrivied.clear()
|
||||
this.routeArrivied.addAll(routeArrivied!!)
|
||||
this.routeArriving.clear()
|
||||
this.routeArriving.addAll(routeArriving!!)
|
||||
this.location = location
|
||||
}
|
||||
|
||||
override fun onCameraChange(cameraPosition: CameraPosition) {}
|
||||
override fun onCameraChangeFinish(cameraPosition: CameraPosition) {}
|
||||
|
||||
companion object {
|
||||
//小地图名称
|
||||
const val TAG = "TPMapDirectionView"
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import com.mogo.eagle.core.data.enums.DataSourceType
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType
|
||||
import com.mogo.eagle.core.data.msgbox.V2XMsg
|
||||
import com.mogo.eagle.core.data.obu.MogoObuConst
|
||||
import com.mogo.eagle.core.function.api.datacenter.obu.IMoGoObuSaveMessageListener
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
|
||||
import com.mogo.eagle.core.function.call.obu.CallerObuSaveMessageListenerManager
|
||||
@@ -37,20 +36,19 @@ object V2xObuEventManager : IMoGoObuSaveMessageListener {
|
||||
* @param content 事件内容
|
||||
* @param tts 事件语音播报 //30秒内同一个事件只出现一次 TODO 临时添加,后面宏宇统一在数据中心处理
|
||||
*/
|
||||
override fun onMoGoObuSaveMessage(type: String, content: String, tts: String, source: DataSourceType) {
|
||||
override fun onMoGoObuSaveMessage(type: String, content: String, tts: String, sourceType: DataSourceType) {
|
||||
if (content.isNotEmpty()) {
|
||||
if (obuDataMap.containsKey(type)) {
|
||||
var oldTime = obuDataMap[type]
|
||||
var timeDiff = (System.currentTimeMillis() - oldTime!!) / 1000
|
||||
if (timeDiff < 30) {
|
||||
return
|
||||
val oldTime = obuDataMap[type]
|
||||
oldTime?.let {
|
||||
val timeDiff = (System.currentTimeMillis() - it) / 1000
|
||||
if (timeDiff < 30) {
|
||||
return
|
||||
}
|
||||
obuDataMap.remove(type)
|
||||
}
|
||||
obuDataMap.remove(type)
|
||||
obuDataMap[type] = System.currentTimeMillis()
|
||||
} else {
|
||||
obuDataMap[type] = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
obuDataMap[type] = System.currentTimeMillis()
|
||||
CallerLogger.d("${SceneConstant.M_OBU}${TAG}", "onMoGoObuSaveMessage type = $type ---content = $content ---tts = $tts ")
|
||||
CallerMsgBoxManager.saveMsgBox(
|
||||
MsgBoxBean(
|
||||
@@ -61,7 +59,7 @@ object V2xObuEventManager : IMoGoObuSaveMessageListener {
|
||||
tts
|
||||
)
|
||||
).apply {
|
||||
sourceType = source
|
||||
this.sourceType = sourceType
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ import com.mogo.eagle.core.function.api.map.collect.IMoGoMapDataCollectProvider
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicStatusListenerManager
|
||||
import com.mogo.eagle.core.function.datacenter.autopilot.adapter.MoGoAdasListenerImpl
|
||||
import com.mogo.eagle.core.function.datacenter.autopilot.adapter.MoGoAdasMsgConnectStatusListenerImpl
|
||||
import com.mogo.eagle.core.function.datacenter.autopilot.server.AsyncDataToAutopilotServer
|
||||
import com.mogo.eagle.core.function.datacenter.autopilot.telematic.EventListener
|
||||
import com.mogo.eagle.core.function.datacenter.autopilot.telematic.IMsgHandler
|
||||
import com.mogo.eagle.core.function.datacenter.autopilot.telematic.TeleMsgHandler
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicStatusListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_D_C
|
||||
@@ -52,6 +52,7 @@ import com.mogo.telematic.server.netty.NettyTcpServer
|
||||
import com.zhidao.support.adas.high.AdasManager
|
||||
import com.zhidao.support.adas.high.AdasOptions
|
||||
import com.zhidao.support.adas.high.OnMultiDeviceListener
|
||||
import com.zhidao.support.adas.high.chain.AdasChain
|
||||
import com.zhidao.support.adas.high.common.Constants
|
||||
import com.zhidao.support.adas.high.common.Constants.IPC_CONNECTION_STATUS
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils
|
||||
@@ -321,6 +322,12 @@ class MoGoAutopilotControlProvider :
|
||||
CallerLogger.d("$M_D_C$TAG", "结束记录包: [$cmdId, $result]")
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = AdasChain.CHAIN_TYPE_SOCKET_AUTOPILOT,
|
||||
linkCode = AdasChain.CHAIN_SOURCE_ADAS,
|
||||
nodeAliasCode = AdasChain.CHAIN_CODE_ADAS_START_AUTOPILOT,
|
||||
paramIndexes = [0]
|
||||
)
|
||||
override fun startAutoPilot(controlParameters: AutopilotControlParameters) {
|
||||
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
val invokeResult = AdasManager.getInstance()
|
||||
@@ -858,7 +865,7 @@ class MoGoAutopilotControlProvider :
|
||||
}
|
||||
|
||||
if (carConfigResp.dockVersion.isNotEmpty()) {
|
||||
if (carConfigResp.dockVersion.contains("taxi")) {
|
||||
if (carConfigResp.dockVersion.toLowerCase(Locale.getDefault()).contains("taxi")) {
|
||||
//修改雨天模式开关默认状态为开启(仅针对taxi320及以上的版本)-sop 215
|
||||
val num = ParseVersionUtils.parseVersion(true, carConfigResp.dockVersion)
|
||||
if (num >= 30200) {
|
||||
|
||||
@@ -30,6 +30,7 @@ class IPCUpgradeManager: IMogoOnMessageListener<IPCUpgradeStateInfo> ,
|
||||
|
||||
private var mContext: Context? = null
|
||||
private val ipcUpgradeNetWorkModel = IPCUpgradeNetWorkModel()
|
||||
@Volatile
|
||||
private var autopilotStatus: Int? = null //自动驾驶状态 0代表不可自动驾驶,1代表可自动驾驶,2代表自动驾驶中
|
||||
|
||||
private var hasIPCUpgradeTask = false //是否有工控机升级任务,默认没有该任务
|
||||
|
||||
@@ -49,7 +49,7 @@ class StatusView private constructor() {
|
||||
.setSidePattern(sidePattern)
|
||||
.setGravity(gravity, offsetY = 70)
|
||||
.setImmersionStatusBar(true)
|
||||
.slideDel(false)
|
||||
.slideDel(true)
|
||||
.setWindowHeight(currentHeight)
|
||||
.setWindowWidth(AutoSizeUtils.dp2px(context, 600f))
|
||||
.setAnimator(object : DefaultAnimator() {
|
||||
@@ -69,9 +69,12 @@ class StatusView private constructor() {
|
||||
params: WindowManager.LayoutParams,
|
||||
windowManager: WindowManager,
|
||||
sidePattern: SidePattern
|
||||
): Animator? =
|
||||
super.exitAnim(view, params, windowManager, sidePattern)
|
||||
): Animator? {
|
||||
mStatusSummaryViewFloat = null
|
||||
mStatusSummaryView = null
|
||||
return super.exitAnim(view, params, windowManager, sidePattern)
|
||||
?.setDuration(200)
|
||||
}
|
||||
})
|
||||
.show()
|
||||
}
|
||||
|
||||
@@ -324,6 +324,12 @@ class SmallMapView @JvmOverloads constructor(
|
||||
if (globalPathResp == null || globalPathResp.wayPointsList.size == 0) {
|
||||
return
|
||||
}
|
||||
if(CallerAutoPilotStatusListenerManager.getState() != 2){
|
||||
UiThreadHandler.post {
|
||||
clearPolyline()
|
||||
}
|
||||
return
|
||||
}
|
||||
val latLngList: MutableList<MogoLatLng> = ArrayList()
|
||||
for (routeModel in globalPathResp.wayPointsList) {
|
||||
latLngList.add(MogoLatLng(routeModel.latitude, routeModel.longitude))
|
||||
|
||||
@@ -61,13 +61,6 @@ object CallerAutoPilotControlManager {
|
||||
*
|
||||
* @param controlParameters 开启自动驾驶的控制参数
|
||||
*/
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_TYPE_SOCKET_AUTOPILOT,
|
||||
linkCode = CHAIN_SOURCE_ADAS,
|
||||
nodeAliasCode = CHAIN_CODE_EAGLE_START_AUTOPILOT,
|
||||
paramIndexes = [0],
|
||||
endPoint = false
|
||||
)
|
||||
fun startAutoPilot(controlParameters: AutopilotControlParameters?) {
|
||||
if (controlParameters == null) {
|
||||
//LogUtils.eTag(TAG, "自动驾驶控制参数异常,请检查参数信息")
|
||||
|
||||
@@ -841,12 +841,6 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
* @param routeInfo 自动驾驶路径信息
|
||||
* @return boolean
|
||||
*/
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_TYPE_SOCKET_AUTOPILOT,
|
||||
linkCode = CHAIN_SOURCE_ADAS,
|
||||
nodeAliasCode = CHAIN_CODE_ADAS_START_AUTOPILOT,
|
||||
paramIndexes = {0, 1, 2}
|
||||
)
|
||||
@Override
|
||||
public boolean sendAutoPilotModeReq(int mode, int source, MessagePad.RouteInfo routeInfo) {
|
||||
MessagePad.SetAutopilotModeReq.Builder builder = MessagePad.SetAutopilotModeReq.newBuilder();
|
||||
|
||||
Reference in New Issue
Block a user