fix: 修改了拍照界面出现的定位不存在导致的程序崩溃的问题

This commit is contained in:
xiaoyan 2023-02-21 11:11:18 +08:00
parent f7943db1c0
commit 88dd96f572
3 changed files with 35 additions and 9 deletions

View File

@ -12,8 +12,8 @@ android {
applicationId "com.navinfo.outdoor"
minSdkVersion 24
targetSdkVersion 30
versionCode 47
versionName "8.230216"
versionCode 48
versionName "8.230221"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {

View File

@ -699,6 +699,8 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
0)); //目标旋转角 0~360° (正北方为0)
tencentMap.animateCamera(cameraSigma);
} else {
ToastUtils.Message(this, "当前定位方式无法获取位置信息!");
}
setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE);
break;
@ -706,8 +708,10 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
imgLocationType.setSelected(!imgLocationType.isSelected());
if (imgLocationType.isSelected()) { // 选中状态切换为GPS为主定位
LocationLifeCycle.getInstance().setMainLocationFrom(LocationLifeCycle.LOCATION_FROM.ORIGIN);
ToastUtils.Message(PicturesActivity.this, "切换为GPS定位");
} else {
LocationLifeCycle.getInstance().setMainLocationFrom(LocationLifeCycle.LOCATION_FROM.TENCENT);
ToastUtils.Message(PicturesActivity.this, "切换为网络定位");
}
break;
}
@ -946,11 +950,20 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
sb.append(index == -1 ? 0 : index);//個數
startVideoIndex = index == -1 ? 0 : index;
sb.append(",");
sb.append(LocationLifeCycle.getInstance().getMainLocation().getLatitude());
sb.append(",");
sb.append(LocationLifeCycle.getInstance().getMainLocation().getLongitude());
sb.append(",");
sb.append(LocationLifeCycle.getInstance().getMainLocation().getBearing());
if (LocationLifeCycle.getInstance().getMainLocation()!=null) {
sb.append(LocationLifeCycle.getInstance().getMainLocation().getLatitude());
sb.append(",");
sb.append(LocationLifeCycle.getInstance().getMainLocation().getLongitude());
sb.append(",");
sb.append(LocationLifeCycle.getInstance().getMainLocation().getBearing());
} else {
sb.append(LocationLifeCycle.getInstance().getTencentLocation().getLatitude());
sb.append(",");
sb.append(LocationLifeCycle.getInstance().getTencentLocation().getLongitude());
sb.append(",");
sb.append(LocationLifeCycle.getInstance().getTencentLocation().getBearing());
ToastUtils.Message(PicturesActivity.this, "主定位方式无法获取位置信息,使用腾讯定位记录当前位置!");
}
sb.append(",");
int gpsRssi = GPSUtils.getInstance(PicturesActivity.this).getSateliteCount();
if (gpsRssi == 0) {
@ -1015,7 +1028,10 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
private boolean isSpeedLimitTips = false;
private void initSpeed() {
if (isSpeedLimitTips == true) {
if (!systemTTS.isSpeaking()) {
isSpeedLimitTips = false;
}
if (isSpeedLimitTips == true || LocationLifeCycle.getInstance().getMainLocation() == null) {
return;
}
float speed = LocationLifeCycle.getInstance().getMainLocation().getSpeed();///
@ -1144,7 +1160,11 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
*/
public void initMarker(boolean isOration) {
LatLng latLng = null;
latLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude());
if (LocationLifeCycle.getInstance().getMainLocation()!=null) {
latLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude());
} else {
latLng = new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude());
}
BitmapDescriptor pileDescriptor = BitmapDescriptorFactory
.fromResource(R.drawable.circle);
Marker marker = tencentMap.addMarker(new MarkerOptions(latLng)

View File

@ -97,5 +97,11 @@ public class SystemTTS extends UtteranceProgressListener implements TTS, TextToS
}
public boolean isSpeaking() {
if (textToSpeech!=null) {
return textToSpeech.isSpeaking();
}
return false;
}
}