fix: 修改导航功能横竖屏切换
This commit is contained in:
commit
d5090bcd3d
@ -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'
|
||||
|
@ -60,7 +60,7 @@
|
||||
tools:targetApi="n">
|
||||
<!-- <activity-->
|
||||
<!-- android:name=".NaviActivity"-->
|
||||
<!-- android:exported="true">-->
|
||||
<!-- android:exported="false">-->
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="android.app.lib_name"-->
|
||||
<!-- android:value="" />-->
|
||||
@ -92,7 +92,8 @@
|
||||
<!-- android:value="EWWBZ-2PB62-6JXUL-CEX7G-N7UE6-XRB4V" /> -->
|
||||
<meta-data
|
||||
android:name="TencentMapSDK"
|
||||
android:value="7UEBZ-TWAYK-5JFJM-A5SJI-FA4U6-3IBMX" /> <!-- 今日头屏幕适配 -->
|
||||
android:value="7UEBZ-TWAYK-5JFJM-A5SJI-FA4U6-3IBMX" />
|
||||
<!-- 今日头屏幕适配 -->
|
||||
<meta-data
|
||||
android:name="design_width_in_dp"
|
||||
android:value="360" />
|
||||
@ -155,13 +156,13 @@
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.NaviCarActivity"
|
||||
android:screenOrientation="landscape" />
|
||||
android:screenOrientation="sensor" />
|
||||
<activity
|
||||
android:name=".activity.NaviRideActivity"
|
||||
android:screenOrientation="landscape" />
|
||||
android:screenOrientation="sensor" />
|
||||
<activity
|
||||
android:name=".activity.NaviWalkActivity"
|
||||
android:screenOrientation="landscape" />
|
||||
android:screenOrientation="sensor" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
|
@ -109,6 +109,7 @@ import com.tencent.map.navi.TencentNaviManager;
|
||||
import com.tencent.map.navi.TencentRouteSearchCallback;
|
||||
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.ParallelRoadStatus;
|
||||
@ -1134,6 +1135,11 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
public int onVoiceBroadcast(NaviTts naviTts) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnterIdleSection(IdleRangeInfo idleRangeInfo) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
return polyline;
|
||||
|
@ -32,6 +32,7 @@ import com.navinfo.outdoor.http.HttpInterface;
|
||||
import com.navinfo.outdoor.room.PoiDatabase;
|
||||
import com.navinfo.outdoor.util.BackHandlerHelper;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.MyTecentLocationSource;
|
||||
import com.navinfo.outdoor.util.NaviUtils;
|
||||
import com.navinfo.outdoor.util.NoSlideViewPager;
|
||||
|
||||
@ -120,30 +121,8 @@ public class HomeActivity extends BaseActivity {
|
||||
boolean result = handler.sendEmptyMessageDelayed(0x101, 1000*60*(int)(10*Math.random()));
|
||||
Log.d("HomeActivity", "作弊检查:"+result);
|
||||
|
||||
LogConfiguration logConfiguration = new LogConfiguration.Builder()
|
||||
// .enableStackTrace(5)
|
||||
.enableBorder()
|
||||
.tag("XLog").build();
|
||||
Printer androidPrinter = new AndroidPrinter(true); // 通过 android.util.Log 打印日志的打印器
|
||||
Printer consolePrinter = new ConsolePrinter(); // 通过 System.out 打印日志到控制台的打印器
|
||||
Printer filePrinter = new FilePrinter // 打印日志到文件的打印器
|
||||
.Builder(Constant.LOG_FOLDER) // 指定保存日志文件的路径
|
||||
.fileNameGenerator(new LevelFileNameGenerator()) // 指定日志文件名生成器,默认为 ChangelessFileNameGenerator("log")
|
||||
.flattener(new ClassicFlattener())
|
||||
.build();
|
||||
// 初始化XLog
|
||||
XLog.init( // 初始化 XLog
|
||||
logConfiguration, // 指定日志配置,如果不指定,会默认使用 new LogConfiguration.Builder().build()
|
||||
androidPrinter, // 添加任意多的打印器。如果没有添加任何打印器,会默认使用 AndroidPrinter(Android)/ConsolePrinter(java)
|
||||
consolePrinter,
|
||||
filePrinter);
|
||||
|
||||
// 注册位置更新的lifeCycle
|
||||
getLifecycle().addObserver(LocationLifeCycle.getInstance());
|
||||
// 尝试定位
|
||||
LocationLifeCycle.getInstance().init(getApplicationContext());
|
||||
// 开始获取腾讯定位信息
|
||||
LocationLifeCycle.getInstance().startTencentLocation();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
@ -21,6 +21,14 @@ import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.lifecycle.ProcessLifecycleOwner;
|
||||
|
||||
import com.elvishew.xlog.LogConfiguration;
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.elvishew.xlog.flattener.ClassicFlattener;
|
||||
import com.elvishew.xlog.printer.AndroidPrinter;
|
||||
import com.elvishew.xlog.printer.ConsolePrinter;
|
||||
import com.elvishew.xlog.printer.Printer;
|
||||
import com.elvishew.xlog.printer.file.FilePrinter;
|
||||
import com.elvishew.xlog.printer.file.naming.LevelFileNameGenerator;
|
||||
import com.github.lazylibrary.util.AppUtils;
|
||||
import com.hjq.permissions.OnPermissionCallback;
|
||||
import com.hjq.permissions.Permission;
|
||||
@ -136,6 +144,29 @@ public class MainActivity extends BaseActivity {
|
||||
HttpInterface.initHttpInter(Constant.USHERED);
|
||||
// 检查版本
|
||||
initCheckVersion();
|
||||
|
||||
LogConfiguration logConfiguration = new LogConfiguration.Builder()
|
||||
// .enableStackTrace(5)
|
||||
.enableBorder()
|
||||
.tag("XLog").build();
|
||||
Printer androidPrinter = new AndroidPrinter(true); // 通过 android.util.Log 打印日志的打印器
|
||||
Printer consolePrinter = new ConsolePrinter(); // 通过 System.out 打印日志到控制台的打印器
|
||||
Printer filePrinter = new FilePrinter // 打印日志到文件的打印器
|
||||
.Builder(Constant.LOG_FOLDER) // 指定保存日志文件的路径
|
||||
.fileNameGenerator(new LevelFileNameGenerator()) // 指定日志文件名生成器,默认为 ChangelessFileNameGenerator("log")
|
||||
.flattener(new ClassicFlattener())
|
||||
.build();
|
||||
// 初始化XLog
|
||||
XLog.init( // 初始化 XLog
|
||||
logConfiguration, // 指定日志配置,如果不指定,会默认使用 new LogConfiguration.Builder().build()
|
||||
androidPrinter, // 添加任意多的打印器。如果没有添加任何打印器,会默认使用 AndroidPrinter(Android)/ConsolePrinter(java)
|
||||
consolePrinter,
|
||||
filePrinter);
|
||||
|
||||
// 尝试定位
|
||||
LocationLifeCycle.getInstance().init(getApplicationContext());
|
||||
// 开始获取腾讯定位信息
|
||||
LocationLifeCycle.getInstance().startTencentLocation();
|
||||
} else {
|
||||
initTime();
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.navinfo.outdoor.activity;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.navinfo.outdoor.R;
|
||||
@ -21,8 +23,7 @@ import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
public class NaviCarActivity extends BaseActivity {
|
||||
private CarNaviView carNaviView;
|
||||
private LifecycleObserver lifecycleObserver;
|
||||
private FusionGeoLocationAdapter geoAdapter;
|
||||
private GeoLocationObserver geoLocationObserver;
|
||||
private NaviCarViewModel naviCarViewModel;
|
||||
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
@ -35,36 +36,23 @@ public class NaviCarActivity extends BaseActivity {
|
||||
carNaviView = findViewById(R.id.carnaviview);
|
||||
lifecycleObserver = new NaviLifeCycle(carNaviView);
|
||||
getLifecycle().addObserver(lifecycleObserver);
|
||||
if (naviCarViewModel == null) {
|
||||
naviCarViewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(NaviCarViewModel.class);
|
||||
}
|
||||
TencentNaviManager naviManager = NaviUtils.getInstance().obitainnaviManager(this, Constant.currentNaviType, carNaviView);
|
||||
if (naviCarViewModel.getNaviManager() == null) {
|
||||
naviCarViewModel.setNaviManager(naviManager);
|
||||
} else {
|
||||
naviCarViewModel.getNaviManager().addNaviView(carNaviView);
|
||||
}
|
||||
// 获取起终点
|
||||
LatLng startLatlng = (LatLng) getIntent().getExtras().get("start");
|
||||
LatLng endLatlng = (LatLng) getIntent().getExtras().get("end");
|
||||
try {
|
||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviManager, new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviCarViewModel.getNaviManager(), new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// geoAdapter = FusionGeoLocationAdapter.getInstance(this);
|
||||
// // 添加定位监听
|
||||
// geoLocationObserver = new GeoLocationObserver() {
|
||||
//
|
||||
// @Override
|
||||
// public void onGeoLocationChanged(TencentGeoLocation tencentGeoLocation) {
|
||||
// // 定位数据回调
|
||||
// XLog.d("用户点击地图,模拟当前位置为"+tencentGeoLocation.toString());
|
||||
// }
|
||||
// };
|
||||
// geoAdapter.addLocationObserver(geoLocationObserver, 1000); // 定位回调频率,推荐1s
|
||||
|
||||
// // 用户点击获取位置信息
|
||||
// carNaviView.getMap().setOnMapClickListener(new TencentMap.OnMapClickListener() {
|
||||
// @Override
|
||||
// public void onMapClick(LatLng latLng) {
|
||||
// TencentLocation tencentLocation = TencentLocationObtain.obtainTecentLocation(latLng);
|
||||
// geoLocationObserver.onGeoLocationChanged(new TencentGeoLocation(tencentLocation, 0, "ok", System.currentTimeMillis()));
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -72,8 +60,6 @@ public class NaviCarActivity extends BaseActivity {
|
||||
super.onDestroy();
|
||||
getLifecycle().removeObserver(lifecycleObserver);
|
||||
// 如果当前正在导航,自动停止
|
||||
NaviUtils.getInstance().stopNavi();
|
||||
|
||||
// geoAdapter.removeLocationObserver(geoLocationObserver);
|
||||
naviCarViewModel.getNaviManager().removeAllNaviViews();
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.navinfo.outdoor.activity;
|
||||
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.navinfo.outdoor.util.NaviUtils;
|
||||
import com.tencent.map.navi.TencentNaviManager;
|
||||
|
||||
public class NaviCarViewModel extends ViewModel {
|
||||
private TencentNaviManager naviManager;
|
||||
public void setNaviManager(TencentNaviManager naviManager) {
|
||||
this.naviManager = naviManager;
|
||||
}
|
||||
|
||||
public TencentNaviManager getNaviManager() {
|
||||
return naviManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCleared() {
|
||||
super.onCleared();
|
||||
NaviUtils.getInstance().stopNavi();
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.navinfo.outdoor.activity;
|
||||
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
@ -11,11 +12,14 @@ import com.tencent.map.navi.TencentNaviManager;
|
||||
import com.tencent.map.navi.car.CarNaviView;
|
||||
import com.tencent.map.navi.data.NaviPoi;
|
||||
import com.tencent.map.navi.ride.RideNaviView;
|
||||
import com.tencent.map.navi.ride.TencentRideNaviManager;
|
||||
import com.tencent.map.navi.walk.TencentWalkNaviManager;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
public class NaviRideActivity extends BaseActivity {
|
||||
private RideNaviView rideNaviView;
|
||||
private LifecycleObserver lifecycleObserver;
|
||||
private NaviCarViewModel naviCarViewModel;
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
return R.layout.activity_navi_ride;
|
||||
@ -27,12 +31,21 @@ public class NaviRideActivity extends BaseActivity {
|
||||
rideNaviView = findViewById(R.id.ridenaviview);
|
||||
lifecycleObserver = new NaviLifeCycle(rideNaviView);
|
||||
getLifecycle().addObserver(lifecycleObserver);
|
||||
if (naviCarViewModel == null) {
|
||||
naviCarViewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(NaviCarViewModel.class);
|
||||
}
|
||||
TencentNaviManager naviManager = NaviUtils.getInstance().obitainnaviManager(this, Constant.currentNaviType, rideNaviView);
|
||||
if (naviCarViewModel.getNaviManager() == null) {
|
||||
naviCarViewModel.setNaviManager(naviManager);
|
||||
} else {
|
||||
((TencentRideNaviManager)naviCarViewModel.getNaviManager()).addTencentNaviListener(rideNaviView);
|
||||
}
|
||||
|
||||
// 获取起终点
|
||||
LatLng startLatlng = (LatLng) getIntent().getExtras().get("start");
|
||||
LatLng endLatlng = (LatLng) getIntent().getExtras().get("end");
|
||||
try {
|
||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviManager, new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviCarViewModel.getNaviManager(), new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -43,6 +56,7 @@ public class NaviRideActivity extends BaseActivity {
|
||||
super.onDestroy();
|
||||
getLifecycle().removeObserver(lifecycleObserver);
|
||||
// 如果当前正在导航,自动停止
|
||||
NaviUtils.getInstance().stopNavi();
|
||||
naviCarViewModel.getNaviManager().removeAllNaviViews();
|
||||
((TencentRideNaviManager)naviCarViewModel.getNaviManager()).removeTencentNaviListener(rideNaviView);
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.navinfo.outdoor.activity;
|
||||
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
@ -10,12 +11,15 @@ import com.navinfo.outdoor.util.NaviUtils;
|
||||
import com.tencent.map.navi.TencentNaviManager;
|
||||
import com.tencent.map.navi.data.NaviPoi;
|
||||
import com.tencent.map.navi.ride.RideNaviView;
|
||||
import com.tencent.map.navi.walk.TencentWalkNaviManager;
|
||||
import com.tencent.map.navi.walk.WalkNaviView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
public class NaviWalkActivity extends BaseActivity {
|
||||
private WalkNaviView walkNaviView;
|
||||
private LifecycleObserver lifecycleObserver;
|
||||
private NaviCarViewModel naviCarViewModel;
|
||||
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
return R.layout.activity_navi_walk;
|
||||
@ -27,12 +31,20 @@ public class NaviWalkActivity extends BaseActivity {
|
||||
walkNaviView = findViewById(R.id.walknaviview);
|
||||
lifecycleObserver = new NaviLifeCycle(walkNaviView);
|
||||
getLifecycle().addObserver(lifecycleObserver);
|
||||
if (naviCarViewModel == null) {
|
||||
naviCarViewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(NaviCarViewModel.class);
|
||||
}
|
||||
TencentNaviManager naviManager = NaviUtils.getInstance().obitainnaviManager(this, Constant.currentNaviType, walkNaviView);
|
||||
if (naviCarViewModel.getNaviManager() == null) {
|
||||
naviCarViewModel.setNaviManager(naviManager);
|
||||
} else {
|
||||
((TencentWalkNaviManager)naviCarViewModel.getNaviManager()).addTencentNaviListener(walkNaviView);
|
||||
}
|
||||
// 获取起终点
|
||||
LatLng startLatlng = (LatLng) getIntent().getExtras().get("start");
|
||||
LatLng endLatlng = (LatLng) getIntent().getExtras().get("end");
|
||||
try {
|
||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviManager, new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviCarViewModel.getNaviManager(), new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -43,6 +55,7 @@ public class NaviWalkActivity extends BaseActivity {
|
||||
super.onDestroy();
|
||||
getLifecycle().removeObserver(lifecycleObserver);
|
||||
// 如果当前正在导航,自动停止
|
||||
NaviUtils.getInstance().stopNavi();
|
||||
naviCarViewModel.getNaviManager().removeAllNaviViews();
|
||||
((TencentWalkNaviManager)naviCarViewModel.getNaviManager()).removeTencentNaviListener(walkNaviView);
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ import com.lzy.okgo.interceptor.HttpLoggingInterceptor;
|
||||
import com.lzy.okgo.model.HttpHeaders;
|
||||
import com.tencent.map.navi.TencentNavi;
|
||||
import com.tencent.navi.surport.utils.DeviceUtils;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapInitializer;
|
||||
import com.umeng.commonsdk.UMConfigure;
|
||||
import com.umeng.message.IUmengRegisterCallback;
|
||||
import com.umeng.message.MsgConstant;
|
||||
@ -51,6 +52,9 @@ public class UserApplication extends Application {
|
||||
initOkGo();
|
||||
//创建一个线程池
|
||||
fixedThreadPool = Executors.newSingleThreadExecutor(); // 使用单线程线程池
|
||||
|
||||
TencentMapInitializer.setAgreePrivacy(true);
|
||||
TencentNavi.setUserAgreePrivacy(true);
|
||||
// 初始化腾讯导航
|
||||
TencentNavi.Config config = new TencentNavi.Config();
|
||||
// 记录设备标识,反馈导航问题时请提供该设备标识以及发生问题的时间
|
||||
|
@ -5,12 +5,12 @@ import androidx.lifecycle.DefaultLifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.tencent.map.navi.car.CarNaviView;
|
||||
import com.tencent.map.ui.c;
|
||||
import com.tencent.map.ui.NaviView;
|
||||
|
||||
public class NaviLifeCycle implements DefaultLifecycleObserver {
|
||||
private com.tencent.map.ui.c naviView;
|
||||
private NaviView naviView;
|
||||
|
||||
public NaviLifeCycle(c naviView) {
|
||||
public NaviLifeCycle(NaviView naviView) {
|
||||
this.naviView = naviView;
|
||||
}
|
||||
|
||||
|
@ -417,43 +417,43 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
lastClickTime = System.currentTimeMillis();
|
||||
}
|
||||
});
|
||||
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) {
|
||||
|
||||
}
|
||||
});
|
||||
// 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
|
||||
|
@ -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/";//登录
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
||||
|
@ -76,6 +76,7 @@ public class TalentLocationUtils implements TencentLocationListener {
|
||||
|
||||
public void stopLocation() { // 停止定位服务
|
||||
if (isLocationStart) {
|
||||
isLocationStart = false;
|
||||
locationManager.removeUpdates(this);
|
||||
locationManager = null;
|
||||
locationRequest = null;
|
||||
|
@ -193,14 +193,14 @@
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintRight_toRightOf="@id/cb_map_type"
|
||||
app:layout_constraintBottom_toTopOf="@id/cb_map_type">
|
||||
<Spinner
|
||||
android:id="@+id/spn_main_location"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"></Spinner>
|
||||
<Spinner
|
||||
android:id="@+id/spn_reference_location"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"></Spinner>
|
||||
<!-- <Spinner-->
|
||||
<!-- android:id="@+id/spn_main_location"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"></Spinner>-->
|
||||
<!-- <Spinner-->
|
||||
<!-- android:id="@+id/spn_reference_location"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"></Spinner>-->
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
22
build.gradle
22
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user