修复小地图以及订位置缓存和订单站点更新问题
This commit is contained in:
@@ -218,6 +218,7 @@ public class OchBusFragment extends BaseOchFragment< OchBusFragment, OchBusPrese
|
|||||||
* @param launch true-收车,false-出车
|
* @param launch true-收车,false-出车
|
||||||
*/
|
*/
|
||||||
public void changeOperationStatus( boolean launch ) {
|
public void changeOperationStatus( boolean launch ) {
|
||||||
|
mPresenter.queryBusRoutes();
|
||||||
isOperationStatus = launch;
|
isOperationStatus = launch;
|
||||||
if ( launch ) {
|
if ( launch ) {
|
||||||
tvOperationStatus.setText( "收车" );
|
tvOperationStatus.setText( "收车" );
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.mogo.commons.constants.SharedPrefsConstants;
|
import com.mogo.commons.constants.SharedPrefsConstants;
|
||||||
import com.mogo.commons.debug.DebugConfig;
|
import com.mogo.commons.debug.DebugConfig;
|
||||||
import com.mogo.commons.voice.AIAssist;
|
|
||||||
import com.mogo.map.IMogoMap;
|
import com.mogo.map.IMogoMap;
|
||||||
import com.mogo.map.IMogoMapView;
|
import com.mogo.map.IMogoMapView;
|
||||||
import com.mogo.map.MogoLatLng;
|
import com.mogo.map.MogoLatLng;
|
||||||
@@ -36,7 +35,6 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
|
|||||||
import com.mogo.map.uicontroller.MapCameraPosition;
|
import com.mogo.map.uicontroller.MapCameraPosition;
|
||||||
import com.mogo.map.uicontroller.MapControlResult;
|
import com.mogo.map.uicontroller.MapControlResult;
|
||||||
import com.mogo.map.uicontroller.VisualAngleMode;
|
import com.mogo.map.uicontroller.VisualAngleMode;
|
||||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
|
||||||
import com.mogo.utils.TipToast;
|
import com.mogo.utils.TipToast;
|
||||||
import com.mogo.utils.UiThreadHandler;
|
import com.mogo.utils.UiThreadHandler;
|
||||||
import com.mogo.utils.logger.Logger;
|
import com.mogo.utils.logger.Logger;
|
||||||
@@ -761,13 +759,15 @@ public class AMapViewWrapper implements IMogoMapView,
|
|||||||
sysLocation.setBearing(location.getHeading());
|
sysLocation.setBearing(location.getHeading());
|
||||||
sysLocation.setSpeed(location.getSpeed());
|
sysLocation.setSpeed(location.getSpeed());
|
||||||
|
|
||||||
// 暂存本地,提供给下一次的Http-DNS使用,防止首次请求位置获取不到
|
// 将有效经纬度暂存本地,提供给下一次的Http-DNS使用,防止首次请求位置获取不到
|
||||||
SharedPrefsMgr.getInstance(mMapView.getContext())
|
if (location.getLat() > 0) {
|
||||||
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, location.getCityCode());
|
SharedPrefsMgr.getInstance(mMapView.getContext())
|
||||||
SharedPrefsMgr.getInstance(mMapView.getContext())
|
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, location.getCityCode());
|
||||||
.putString(SharedPrefsConstants.LOCATION_LATITUDE, String.valueOf(location.getLat()));
|
SharedPrefsMgr.getInstance(mMapView.getContext())
|
||||||
SharedPrefsMgr.getInstance(mMapView.getContext())
|
.putString(SharedPrefsConstants.LOCATION_LATITUDE, String.valueOf(location.getLat()));
|
||||||
.putString(SharedPrefsConstants.LOCATION_LONGITUDE, String.valueOf(location.getLon()));
|
SharedPrefsMgr.getInstance(mMapView.getContext())
|
||||||
|
.putString(SharedPrefsConstants.LOCATION_LONGITUDE, String.valueOf(location.getLon()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NaviClient.getInstance(getContext()).syncCarLocation(sysLocation);
|
NaviClient.getInstance(getContext()).syncCarLocation(sysLocation);
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ package com.mogo.module.small.map;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.location.Location;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -16,15 +14,18 @@ import com.amap.api.maps.AMap;
|
|||||||
import com.amap.api.maps.CameraUpdate;
|
import com.amap.api.maps.CameraUpdate;
|
||||||
import com.amap.api.maps.CameraUpdateFactory;
|
import com.amap.api.maps.CameraUpdateFactory;
|
||||||
import com.amap.api.maps.UiSettings;
|
import com.amap.api.maps.UiSettings;
|
||||||
|
import com.amap.api.maps.model.CustomMapStyleOptions;
|
||||||
|
import com.amap.api.navi.AMapNavi;
|
||||||
import com.amap.api.navi.AMapNaviView;
|
import com.amap.api.navi.AMapNaviView;
|
||||||
import com.amap.api.navi.AMapNaviViewOptions;
|
import com.amap.api.navi.AMapNaviViewOptions;
|
||||||
import com.mogo.commons.AbsMogoApplication;
|
import com.mogo.commons.AbsMogoApplication;
|
||||||
import com.mogo.commons.debug.DebugConfig;
|
import com.mogo.commons.debug.DebugConfig;
|
||||||
|
import com.mogo.map.MogoLatLng;
|
||||||
|
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||||
import com.mogo.module.common.MogoApisHandler;
|
import com.mogo.module.common.MogoApisHandler;
|
||||||
import com.mogo.module.common.view.RoundLayout;
|
import com.mogo.module.common.view.RoundLayout;
|
||||||
import com.mogo.utils.FileUtils;
|
import com.mogo.module.small.map.utils.MapAssetStyleUtils;
|
||||||
|
import com.mogo.utils.logger.Logger;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小地图的方向View
|
* 小地图的方向View
|
||||||
@@ -32,13 +33,19 @@ import java.io.IOException;
|
|||||||
* @author donghongyu
|
* @author donghongyu
|
||||||
* @date 12/14/20 4:40 PM
|
* @date 12/14/20 4:40 PM
|
||||||
*/
|
*/
|
||||||
public class SmallMapDirectionView extends RelativeLayout {
|
public class SmallMapDirectionView
|
||||||
private String styleFilePath = "/mnt/sdcard/amap/small_map_style.data";
|
extends RelativeLayout
|
||||||
|
implements IMogoCarLocationChangedListener2 {
|
||||||
|
|
||||||
|
//小地图名称
|
||||||
|
public static final String MODULE_NAME = "SmallMap";
|
||||||
|
|
||||||
private RoundLayout rlSmallMapBorder;
|
private RoundLayout rlSmallMapBorder;
|
||||||
|
|
||||||
private AMapNaviView mAMapNaviView;
|
private AMapNaviView mAMapNaviView;
|
||||||
|
private AMap mAMap;
|
||||||
|
private AMapNavi mAMapNavi;
|
||||||
private int zoomLevel = 15;
|
private int zoomLevel = 15;
|
||||||
private boolean mapIsLoaded = false;
|
|
||||||
|
|
||||||
public SmallMapDirectionView(Context context) {
|
public SmallMapDirectionView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
@@ -64,15 +71,75 @@ public class SmallMapDirectionView extends RelativeLayout {
|
|||||||
rlSmallMapBorder = findViewById(R.id.rlSmallMapBorder);
|
rlSmallMapBorder = findViewById(R.id.rlSmallMapBorder);
|
||||||
rlSmallMapBorder.addView(mAMapNaviView);
|
rlSmallMapBorder.addView(mAMapNaviView);
|
||||||
|
|
||||||
|
|
||||||
|
initAMapView();
|
||||||
|
|
||||||
|
// 注册定位监听
|
||||||
|
SmpServiceManager.getMogoRegisterCenter()
|
||||||
|
.registerCarLocationChangedListener(MODULE_NAME, this);
|
||||||
|
|
||||||
|
setOnClickListener(view -> {
|
||||||
|
if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
|
||||||
|
MogoApisHandler.getInstance().getApis()
|
||||||
|
.getMapServiceApi()
|
||||||
|
.getMapUIController()
|
||||||
|
.changeMapMode(
|
||||||
|
MogoApisHandler.getInstance()
|
||||||
|
.getApis()
|
||||||
|
.getAdasControllerApi()
|
||||||
|
.getCurrentSkinMode()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDetachedFromWindow() {
|
||||||
|
super.onDetachedFromWindow();
|
||||||
|
// 注册定位监听
|
||||||
|
SmpServiceManager.getMogoRegisterCenter()
|
||||||
|
.unregisterCarLocationChangedListener(MODULE_NAME, this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initAMapView() {
|
||||||
// 车头朝上
|
// 车头朝上
|
||||||
mAMapNaviView.setNaviMode(AMapNaviView.CAR_UP_MODE);
|
mAMapNaviView.setNaviMode(AMapNaviView.CAR_UP_MODE);
|
||||||
// 设置电子眼所在路线的可见性
|
// 设置电子眼所在路线的可见性
|
||||||
mAMapNaviView.setRouteOverlayVisible(false);
|
mAMapNaviView.setRouteOverlayVisible(false);
|
||||||
AMap aMap = mAMapNaviView.getMap();
|
mAMap = mAMapNaviView.getMap();
|
||||||
// 关闭地图文字标注
|
// 关闭地图文字标注
|
||||||
aMap.showMapText(false);
|
mAMap.showMapText(false);
|
||||||
|
// 设置导航地图模式,aMap是地图控制器对象。
|
||||||
|
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);
|
||||||
|
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||||
|
mAMap.setTrafficEnabled(false);
|
||||||
|
|
||||||
|
mAMapNavi = AMapNavi.getInstance(getContext());
|
||||||
|
//使用外部GPS数据
|
||||||
|
mAMapNavi.setIsUseExtraGPSData(true);
|
||||||
|
|
||||||
|
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
mAMap.setCustomMapStyle(
|
||||||
|
new CustomMapStyleOptions()
|
||||||
|
.setEnable(true)
|
||||||
|
.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext()))
|
||||||
|
.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext()))
|
||||||
|
);
|
||||||
|
|
||||||
|
//设置希望展示的地图缩放级别
|
||||||
|
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||||
|
mAMap.moveCamera(cameraUpdate);
|
||||||
|
}).start();
|
||||||
|
|
||||||
// 设置地图的样式
|
// 设置地图的样式
|
||||||
UiSettings uiSettings = aMap.getUiSettings();
|
UiSettings uiSettings = mAMap.getUiSettings();
|
||||||
uiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮
|
uiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮
|
||||||
uiSettings.setAllGesturesEnabled(false);// 所有手势
|
uiSettings.setAllGesturesEnabled(false);// 所有手势
|
||||||
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
|
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
|
||||||
@@ -139,95 +206,9 @@ public class SmallMapDirectionView extends RelativeLayout {
|
|||||||
// 2D模式
|
// 2D模式
|
||||||
options.setTilt(0);
|
options.setTilt(0);
|
||||||
// 黑夜模式
|
// 黑夜模式
|
||||||
//options.setNaviNight(true);
|
options.setNaviNight(true);
|
||||||
// 自定义地图样式
|
|
||||||
options.setCustomMapStylePath(styleFilePath);
|
|
||||||
mAMapNaviView.setViewOptions(options);
|
mAMapNaviView.setViewOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
//设置希望展示的地图缩放级别
|
|
||||||
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
|
||||||
aMap.moveCamera(cameraUpdate);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 判断是否有样式文件存在
|
|
||||||
FileUtils.copy(
|
|
||||||
context.getAssets().open("small_map_style.data"),
|
|
||||||
styleFilePath,
|
|
||||||
new FileUtils.FileCopyListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
Log.w("FileCopyListener", "onStart=");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFail(Exception e) {
|
|
||||||
Log.w("FileCopyListener", "onFail=");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProcess(int process) {
|
|
||||||
Log.w("FileCopyListener", "onProcess=" + process);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFinish(String toPath) {
|
|
||||||
Log.w("FileCopyListener", "onFinish toPath=" + toPath);
|
|
||||||
|
|
||||||
// 高德地图有bug,所以需要多次调用设置皮肤才能成功
|
|
||||||
if (options != null) {
|
|
||||||
options.setCustomMapStylePath(styleFilePath);
|
|
||||||
mAMapNaviView.setViewOptions(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
//设置希望展示的地图缩放级别
|
|
||||||
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
|
||||||
aMap.moveCamera(cameraUpdate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000L);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
// 高德地图有bug,所以需要多次调用设置皮肤才能成功
|
|
||||||
if (options != null) {
|
|
||||||
options.setCustomMapStylePath(styleFilePath);
|
|
||||||
mAMapNaviView.setViewOptions(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
//设置希望展示的地图缩放级别
|
|
||||||
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
|
||||||
aMap.moveCamera(cameraUpdate);
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
|
|
||||||
|
|
||||||
setOnClickListener(view -> {
|
|
||||||
if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_LENOVO ) {
|
|
||||||
MogoApisHandler.getInstance().getApis()
|
|
||||||
.getMapServiceApi()
|
|
||||||
.getMapUIController()
|
|
||||||
.changeMapMode(
|
|
||||||
MogoApisHandler.getInstance()
|
|
||||||
.getApis()
|
|
||||||
.getAdasControllerApi()
|
|
||||||
.getCurrentSkinMode()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -235,4 +216,18 @@ public class SmallMapDirectionView extends RelativeLayout {
|
|||||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCarLocationChanged2(Location latLng) {
|
||||||
|
Logger.d(MODULE_NAME, "onCarLocationChanged2 latLng:" + latLng);
|
||||||
|
if (mAMapNavi != null) {
|
||||||
|
mAMapNavi.setExtraGPSData(2, latLng);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCarLocationChanged(MogoLatLng latLng) {
|
||||||
|
Logger.d(MODULE_NAME, "onCarLocationChanged latLng:" + latLng);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.mogo.module.small.map;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
|
import com.mogo.service.IMogoServiceApis;
|
||||||
|
import com.mogo.service.MogoServicePaths;
|
||||||
|
import com.mogo.service.module.IMogoRegisterCenter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* author : donghongyu
|
||||||
|
* e-mail : 1358506549@qq.com
|
||||||
|
* date : 2020-01-2114:01
|
||||||
|
* desc : V2X 服务
|
||||||
|
* version: 1.0
|
||||||
|
*/
|
||||||
|
public class SmpServiceManager {
|
||||||
|
private static final String TAG = "V2XServiceManager";
|
||||||
|
private static boolean isInit;
|
||||||
|
private static Context mContext;
|
||||||
|
private static IMogoServiceApis mMogoServiceApis;
|
||||||
|
private static IMogoRegisterCenter mMogoRegisterCenter;
|
||||||
|
|
||||||
|
private SmpServiceManager() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(final Context context) {
|
||||||
|
if (!isInit) {
|
||||||
|
isInit = true;
|
||||||
|
mContext = context;
|
||||||
|
mMogoServiceApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
|
||||||
|
mMogoRegisterCenter = mMogoServiceApis.getRegisterCenterApi();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Context getContext() {
|
||||||
|
return mContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IMogoRegisterCenter getMogoRegisterCenter() {
|
||||||
|
return mMogoRegisterCenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user