diff --git a/app/build.gradle b/app/build.gradle index b1bf259..0b0d948 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,8 +12,8 @@ android { applicationId "com.navinfo.outdoor" minSdkVersion 24 targetSdkVersion 30 - versionCode 42 - versionName "8.230110" + versionCode 43 + versionName "8.230113" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ndk { @@ -133,16 +133,16 @@ dependencies { //腾讯地图 // 地图库 - implementation 'com.tencent.map:tencent-map-vector-sdk:4.5.4' - // 地图组件库,包括小车平移、点聚合等组件功能,详见开发指南。 - implementation 'com.tencent.map:sdk-utilities:1.0.6' + implementation 'com.tencent.map:tencent-map-vector-sdk:4.5.10' +// // 地图组件库,包括小车平移、点聚合等组件功能,详见开发指南。 +// implementation 'com.tencent.map:sdk-utilities:1.0.6' // 导航库 - implementation "com.tencent.map:tencent-map-nav-sdk:5.3.8.1" + implementation ("com.tencent.map:tencent-map-nav-sdk:5.4.2.3") // 导航依赖库 - implementation 'com.tencent.map:tencent-map-nav-surport:1.0.2.9' + implementation ("com.tencent.map:tencent-map-nav-surport:1.1.0.1") // //腾讯地图 定位 -// implementation 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.2.6' +// implementation 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.4.9' // 权限请求框架:https://github.com/getActivity/XXPermissions implementation 'com.github.getActivity:XXPermissions:11.6' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bb94c2d..b3b0678 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -60,7 +60,7 @@ tools:targetApi="n"> - + @@ -92,7 +92,8 @@ + android:value="7UEBZ-TWAYK-5JFJM-A5SJI-FA4U6-3IBMX" /> + @@ -155,13 +156,13 @@ android:screenOrientation="portrait" /> + android:screenOrientation="sensor" /> + android:screenOrientation="sensor" /> + android:screenOrientation="sensor" /> adapterView, View view, int i, long l) { - if (i == 0) { - LocationLifeCycle.getInstance().setMainLocationFrom(LocationLifeCycle.LOCATION_FROM.TENCENT); - } else if (i==1) { - LocationLifeCycle.getInstance().setMainLocationFrom(LocationLifeCycle.LOCATION_FROM.ORIGIN); - } - } - - @Override - public void onNothingSelected(AdapterView adapterView) { - - } - }); - - spnRefrenceLocation.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { - @Override - public void onItemSelected(AdapterView adapterView, View view, int i, long l) { - if (i == 0) { - LocationLifeCycle.getInstance().setReferenceLocationFrom(LocationLifeCycle.LOCATION_FROM.TENCENT); - } else if (i==1) { - LocationLifeCycle.getInstance().setReferenceLocationFrom(LocationLifeCycle.LOCATION_FROM.ORIGIN); - } - } - - @Override - public void onNothingSelected(AdapterView adapterView) { - - } - }); +// Spinner spnBaseLocation = findViewById(R.id.spn_main_location); +// Spinner spnRefrenceLocation = findViewById(R.id.spn_reference_location); +// ArrayAdapter arrayAdapter = new ArrayAdapter(getActivity(), android.R.layout.simple_spinner_dropdown_item, android.R.id.text1, new String[]{"腾讯", "GPS"}); +// spnBaseLocation.setAdapter(arrayAdapter); +// spnRefrenceLocation.setAdapter(arrayAdapter); +// spnRefrenceLocation.setSelection(1); +// spnBaseLocation.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { +// @Override +// public void onItemSelected(AdapterView adapterView, View view, int i, long l) { +// if (i == 0) { +// LocationLifeCycle.getInstance().setMainLocationFrom(LocationLifeCycle.LOCATION_FROM.TENCENT); +// } else if (i==1) { +// LocationLifeCycle.getInstance().setMainLocationFrom(LocationLifeCycle.LOCATION_FROM.ORIGIN); +// } +// } +// +// @Override +// public void onNothingSelected(AdapterView adapterView) { +// +// } +// }); +// +// spnRefrenceLocation.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { +// @Override +// public void onItemSelected(AdapterView adapterView, View view, int i, long l) { +// if (i == 0) { +// LocationLifeCycle.getInstance().setReferenceLocationFrom(LocationLifeCycle.LOCATION_FROM.TENCENT); +// } else if (i==1) { +// LocationLifeCycle.getInstance().setReferenceLocationFrom(LocationLifeCycle.LOCATION_FROM.ORIGIN); +// } +// } +// +// @Override +// public void onNothingSelected(AdapterView adapterView) { +// +// } +// }); } /** @@ -501,12 +501,12 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen public void selectNaviType(Constant.NAV_TYPE nav_type) { // 显示导航类型选择的对话框 Constant.currentNaviType = nav_type; - NaviUtils.getInstance().startNav(getActivity(), new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()), new LatLng(endPoint.getY(), endPoint.getX())); + NaviUtils.getInstance().startNav(getActivity(), new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()), new LatLng(endPoint.getY(), endPoint.getX())); } }); } else { // 已选择导航方式 - NaviUtils.getInstance().startNav(getActivity(), new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()), new LatLng(endPoint.getY(), endPoint.getX())); + NaviUtils.getInstance().startNav(getActivity(), new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()), new LatLng(endPoint.getY(), endPoint.getX())); } } @@ -1314,13 +1314,10 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen @Override public void onDestroy() { + super.onDestroy(); if (EventBus.getDefault().isRegistered(this)) { EventBus.getDefault().unregister(this); } - super.onDestroy(); - if (mapView != null) { - mapView.onDestroy(); - } if (treasureBuilder != null) { treasureBuilder.append(TimestampUtil.time()).append(",").append("onDestroy"); treasureBuilder.append("\r\n"); @@ -1336,6 +1333,9 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen } removableScreenMarker.clear(); } + if (mapView != null) { + mapView.onDestroy(); + } } @Override diff --git a/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java b/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java index e73822a..24cbb66 100644 --- a/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java +++ b/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java @@ -2,9 +2,9 @@ package com.navinfo.outdoor.http; public class HttpInterface { // public static final String IP = "http://172.23.138.133:9999/m4";//测试接口-IP - public static final String IPm = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发接口-外网 - public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试接口-外网 - public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口 + public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发接口-外网 + public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试接口-外网 + public static final String IP3 = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口 public static final String USER_PATH = "/user/";//我的 public static final String MSG_LIST_PATH = "/msgList/";//发现 public static final String USER_LOGIN_PATH = "/userlogin/";//登录 diff --git a/app/src/main/java/com/navinfo/outdoor/util/LocationLifeCycle.java b/app/src/main/java/com/navinfo/outdoor/util/LocationLifeCycle.java index 9921d63..ccfecff 100644 --- a/app/src/main/java/com/navinfo/outdoor/util/LocationLifeCycle.java +++ b/app/src/main/java/com/navinfo/outdoor/util/LocationLifeCycle.java @@ -69,7 +69,7 @@ public class LocationLifeCycle implements DefaultLifecycleObserver { DefaultLifecycleObserver.super.onDestroy(owner); locationChangedListenerList.clear(); locationChangedListenerList = null; - TalentLocationUtils.getInstance(mContext).stopLocation(); + stopTencentLocation(); GPSUtils.getInstance(mContext).unRegisterAllListener(); if (EventBus.getDefault().isRegistered(this)) { EventBus.getDefault().unregister(this); diff --git a/app/src/main/java/com/navinfo/outdoor/util/NaviUtils.java b/app/src/main/java/com/navinfo/outdoor/util/NaviUtils.java index cf90bde..b45b677 100644 --- a/app/src/main/java/com/navinfo/outdoor/util/NaviUtils.java +++ b/app/src/main/java/com/navinfo/outdoor/util/NaviUtils.java @@ -31,6 +31,7 @@ import com.tencent.map.navi.car.CarRouteSearchOptions; import com.tencent.map.navi.car.TencentCarNaviManager; import com.tencent.map.navi.data.AttachedLocation; import com.tencent.map.navi.data.CalcRouteResult; +import com.tencent.map.navi.data.IdleRangeInfo; import com.tencent.map.navi.data.NaviPoi; import com.tencent.map.navi.data.NaviTts; import com.tencent.map.navi.data.NavigationData; @@ -44,6 +45,7 @@ import com.tencent.map.navi.ride.TencentRideNaviManager; import com.tencent.map.navi.ui.car.CarNaviInfoPanel; import com.tencent.map.navi.walk.TencentWalkNaviManager; import com.tencent.map.navi.walk.WalkNaviView; +import com.tencent.map.ui.NaviView; import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; import com.tencent.tencentmap.mapsdk.maps.TencentMap; import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; @@ -122,10 +124,12 @@ public class NaviUtils { selectNaviTypeDialog.show(); } - public TencentNaviManager obitainnaviManager(Activity mContext, Constant.NAV_TYPE nav_type, com.tencent.map.ui.c naviView) { + public TencentNaviManager obitainnaviManager(Activity mContext, Constant.NAV_TYPE nav_type, NaviView naviView) { if (nav_type == Constant.NAV_TYPE.CAR) { // 驾车 CarNaviView carNaviView = (CarNaviView) naviView; - naviManager = new TencentCarNaviManager(mContext); + if (naviManager==null||!naviManager.isNavigating()) { + naviManager = new TencentCarNaviManager(mContext); + } carNaviView.setVisibility(View.VISIBLE); naviManager.addNaviView(carNaviView); CarNaviInfoPanel carNaviInfoPanel = carNaviView.showNaviInfoPanel(); @@ -154,13 +158,6 @@ public class NaviUtils { // 请求重新规划路径 XLog.d("Car已偏航"); naviTts.setText("您已偏航,重新计算路径信息"); -// com.github.lazylibrary.util.ToastUtils.showToast(mContext, "您已偏航,重新规划路线!"); -// try { -// NaviUtils.getInstance().reSearchRoute(naviManager, new NaviPoi(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude())); -// } catch (Exception e) { -// e.printStackTrace(); -// com.github.lazylibrary.util.ToastUtils.showToast(mContext, "出现异常:"+e.getMessage()); -// } } @Override @@ -234,10 +231,17 @@ public class NaviUtils { public int onVoiceBroadcast(NaviTts naviTts) { return 0; } + + @Override + public void onEnterIdleSection(IdleRangeInfo idleRangeInfo) { + + } }); } else if (nav_type == Constant.NAV_TYPE.RIDE) { // 骑行 RideNaviView rideNaviView = (RideNaviView) naviView; - naviManager = new TencentRideNaviManager(mContext); + if (naviManager==null||!naviManager.isNavigating()) { + naviManager = new TencentRideNaviManager(mContext); + } rideNaviView.setVisibility(View.VISIBLE); ((TencentRideNaviManager)naviManager).addTencentNaviListener(rideNaviView); CarNaviInfoPanel carNaviInfoPanel = rideNaviView.showNaviInfoPanel(); @@ -338,7 +342,9 @@ public class NaviUtils { }); } else { WalkNaviView walkNaviView = (WalkNaviView) naviView; - naviManager = new TencentWalkNaviManager(mContext); + if (naviManager==null||!naviManager.isNavigating()) { + naviManager = new TencentWalkNaviManager(mContext); + } walkNaviView.setVisibility(View.VISIBLE); ((TencentWalkNaviManager)naviManager).addTencentNaviListener(walkNaviView); CarNaviInfoPanel carNaviInfoPanel = walkNaviView.showNaviInfoPanel(); @@ -440,12 +446,8 @@ public class NaviUtils { } }); } - if (tencentMap == null) { - tencentMap = naviView.getMap(); - } - if (this.mContext == null) { - this.mContext = mContext; - } + this.tencentMap = naviView.getMap(); + this.mContext = mContext; // 开启语音播报 naviManager.setInternalTtsEnabled(true); @@ -467,7 +469,7 @@ public class NaviUtils { if (nav_type == Constant.NAV_TYPE.CAR) { // 驾车模式 TencentCarNaviManager carNaviManager = (TencentCarNaviManager)naviManager; CarRouteSearchOptions options = CarRouteSearchOptions.create(); - NaviPoi newStart = new NaviPoi(start.getLatitude()-0.04, start.getLongitude()); + NaviPoi newStart = new NaviPoi(start.getLatitude(), start.getLongitude()); carNaviManager.searchRoute(newStart, end, new ArrayList<>(), options, routeSearchCallback); } else if (nav_type == Constant.NAV_TYPE.RIDE) { // 骑行模式 TencentRideNaviManager rideNaviManager = (TencentRideNaviManager)naviManager; @@ -475,7 +477,7 @@ public class NaviUtils { rideNaviManager.searchRoute(start, end, options, routeSearchCallback); } else { // 步行模式 TencentWalkNaviManager walkNaviManager = (TencentWalkNaviManager) naviManager; - NaviPoi newStart = new NaviPoi(start.getLatitude()-0.04, start.getLongitude()); + NaviPoi newStart = new NaviPoi(start.getLatitude(), start.getLongitude()); walkNaviManager.searchRoute(newStart, end, routeSearchCallback); } } @@ -536,14 +538,20 @@ public class NaviUtils { try { // 自动开始导航 if (Constant.currentNaviType == Constant.NAV_TYPE.CAR) { - ((TencentCarNaviManager)naviManager).startNavi(0); -// ((TencentCarNaviManager)naviManager).startSimulateNavi(0); + if (!((TencentCarNaviManager)naviManager).isNavigating()) { + //((TencentCarNaviManager)naviManager).startNavi(0); + ((TencentCarNaviManager)naviManager).startSimulateNavi(0); + } } else if (Constant.currentNaviType == Constant.NAV_TYPE.RIDE) { - ((TencentRideNaviManager)naviManager).startNavi(0); -// ((TencentRideNaviManager)naviManager).startSimulateNavi(0); + if (!((TencentRideNaviManager)naviManager).isNavigating()) { +// ((TencentRideNaviManager)naviManager).startNavi(0); + ((TencentRideNaviManager)naviManager).startSimulateNavi(0); + } } else { - ((TencentWalkNaviManager)naviManager).startNavi(0); -// ((TencentWalkNaviManager)naviManager).startSimulateNavi(0); + if (!((TencentWalkNaviManager)naviManager).isNavigating()) { +// ((TencentWalkNaviManager)naviManager).startNavi(0); + ((TencentWalkNaviManager)naviManager).startSimulateNavi(0); + } } } catch (Exception e) { diff --git a/app/src/main/java/com/navinfo/outdoor/util/TalentLocationUtils.java b/app/src/main/java/com/navinfo/outdoor/util/TalentLocationUtils.java index 4f97287..a1e998c 100644 --- a/app/src/main/java/com/navinfo/outdoor/util/TalentLocationUtils.java +++ b/app/src/main/java/com/navinfo/outdoor/util/TalentLocationUtils.java @@ -76,6 +76,7 @@ public class TalentLocationUtils implements TencentLocationListener { public void stopLocation() { // 停止定位服务 if (isLocationStart) { + isLocationStart = false; locationManager.removeUpdates(this); locationManager = null; locationRequest = null; diff --git a/app/src/main/res/layout/treasure_fragment.xml b/app/src/main/res/layout/treasure_fragment.xml index c916da9..5ef9794 100644 --- a/app/src/main/res/layout/treasure_fragment.xml +++ b/app/src/main/res/layout/treasure_fragment.xml @@ -193,14 +193,14 @@ android:orientation="vertical" app:layout_constraintRight_toRightOf="@id/cb_map_type" app:layout_constraintBottom_toTopOf="@id/cb_map_type"> - - + + + + + + + + diff --git a/build.gradle b/build.gradle index 9d90b9e..1f7f169 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,10 @@ buildscript { ext.kotlin_version = '1.5.10' repositories { //友盟 检测bug + //腾讯地图 + maven{ + url "https://oss.sonatype.org/content/groups/public" + } maven { url 'https://repo1.maven.org/maven2/' } maven{ url 'https://maven.aliyun.com/repository/google'} maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'} @@ -12,10 +16,9 @@ buildscript { maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} maven { url "https://jitpack.io" } maven { url "https://repo.spring.io/libs-release/" } - //腾讯地图 - maven{ - url "https://oss.sonatype.org/content/groups/public" - } + maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} + //友盟 检测bug + maven { url 'https://repo1.maven.org/maven2/' } jcenter() mavenCentral() google() @@ -36,6 +39,10 @@ buildscript { allprojects { repositories { //友盟 检测bug + //腾讯地图 + maven{ + url "https://oss.sonatype.org/content/groups/public" + } maven { url 'https://repo1.maven.org/maven2/' } maven{ url 'https://maven.aliyun.com/repository/google'} maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'} @@ -44,10 +51,9 @@ allprojects { maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} maven { url "https://jitpack.io" } maven { url "https://repo.spring.io/libs-release/" } - //腾讯地图 - maven{ - url "https://oss.sonatype.org/content/groups/public" - } + maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} + //友盟 检测bug + maven { url 'https://repo1.maven.org/maven2/' } jcenter() mavenCentral() google()