fix: 修改自动采集的bug
This commit is contained in:
parent
258893dc10
commit
0fe733d138
@ -9,8 +9,8 @@ android {
|
||||
applicationId "com.navinfo.outdoor"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 30
|
||||
versionCode 24
|
||||
versionName "8.220728"
|
||||
versionCode 25
|
||||
versionName "8.220809"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
lintOptions {
|
||||
|
@ -102,6 +102,7 @@ import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.Polyline;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.TencentMapGestureListener;
|
||||
import com.umeng.commonsdk.internal.crash.UMCrashManager;
|
||||
import com.umeng.umcrash.UMCrash;
|
||||
import org.locationtech.jts.algorithm.Angle;
|
||||
@ -184,21 +185,23 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
private List<RoadMatchEntity> roadLinkEntityList, roadMatchEntityList;
|
||||
private int satelliteCount; // 卫星颗数
|
||||
private final long UN_MATCH_TIME_MAX=30*1000; // 未匹配到的时间阈值,最长为30秒
|
||||
private static double MATCH_BUFFER_DISTANCE=5e-5; // 匹配途经点用到的buffer距离,此处5米使用简易判断
|
||||
private static double MATCH_START_BUFFER_DISTANCE=50e-5; // 匹配起点用到的buffer距离,此处5米使用简易判断
|
||||
private static double MATCH_BUFFER_DISTANCE=15e-5; // 匹配途经点用到的buffer距离,此处5米使用简易判断
|
||||
private static double MATCH_START_BUFFER_DISTANCE=30e-5; // 匹配起点用到的buffer距离,此处5米使用简易判断
|
||||
private final String tmpPicFoldPath = Constant.PICTURE_FOLDER+"/tmp";
|
||||
private LocationRecorderDao recorderDao;
|
||||
private PoiDao poiDao;
|
||||
private SimpleDateFormat picFormatter = new SimpleDateFormat("yyyyMMdd HHmmss");
|
||||
private Button btnClearMatch, btnStopPicture;
|
||||
private Point lastPositionPoint; // 最近一次的定位,用来过滤距离较近的点位
|
||||
private static int UNMATCH_BUFFER_START_BUFFER = 5/*匹配开始后连续未匹配的个数*/, UNMATCH_BUFFER_MIDDLE_BUFFER = 10/*匹配过程中连续未匹配的个数*/;
|
||||
private static int UNMATCH_BUFFER_START_BUFFER = 5/*匹配开始后连续未匹配的个数*/, UNMATCH_BUFFER_MIDDLE_BUFFER = 20/*匹配过程中连续未匹配的个数*/;
|
||||
private static float UNMATCH_GIVE_UP_DISTANCE_BUFFER = 0.2f/*放弃的距离匹配阈值*/, MATCH_CONFIRM_FINISH_BUFFER=0.9f/*完全匹配的距离阈值*/;
|
||||
private static float UNMATCH_COUNT_BUFFER = UNMATCH_GIVE_UP_DISTANCE_BUFFER/(1-UNMATCH_GIVE_UP_DISTANCE_BUFFER);
|
||||
private static int BRIGHTNESS=40, FRAMENESS=30;
|
||||
private Button btnSetting;
|
||||
private Switch locationSwitch;
|
||||
private boolean locationEnable=true;
|
||||
private ImageView imgViewSettingHook; // 调起隐藏设置的按钮
|
||||
private TencentLocation oldCurrentLocation = null;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@ -237,8 +240,6 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
ivLocation = findViewById(R.id.iv_location);
|
||||
ivLocation.setOnClickListener(this);
|
||||
camera = findViewById(R.id.camera);
|
||||
CameraOptions cameraOptions = camera.getCameraOptions();
|
||||
camera.setPreviewFrameRate(FRAMENESS);
|
||||
camera.setSnapshotMaxWidth(1920);
|
||||
camera.setSnapshotMaxHeight(1440);
|
||||
camera.setOnClickListener(this);
|
||||
@ -376,8 +377,39 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
locationEnable = isChecked;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
imgViewSettingHook = findViewById(R.id.image_view);
|
||||
imgViewSettingHook.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (btnSetting.isShown()) {
|
||||
return;
|
||||
}
|
||||
settingHookClickCount++;
|
||||
if(lastClickTime > 0){
|
||||
long secondClickTime = System.currentTimeMillis();//距离上次开机时间
|
||||
long dtime = secondClickTime - lastClickTime;
|
||||
if(dtime <800){
|
||||
if (settingHookClickCount>8) {
|
||||
Toast.makeText(AutoTakePictureActivity.this, "打开设置功能", Toast.LENGTH_SHORT).show();
|
||||
btnSetting.setVisibility(View.VISIBLE);
|
||||
locationSwitch.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (settingHookClickCount>3) {
|
||||
Toast.makeText(AutoTakePictureActivity.this, "再点击"+(9-settingHookClickCount)+"下打开设置功能", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
} else{
|
||||
lastClickTime = 0;
|
||||
settingHookClickCount = 1;
|
||||
}
|
||||
}
|
||||
lastClickTime = System.currentTimeMillis();
|
||||
}
|
||||
});
|
||||
}
|
||||
private long lastClickTime = 0;
|
||||
private int settingHookClickCount = 1;
|
||||
|
||||
|
||||
@Override
|
||||
@ -397,6 +429,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
tencentMap.addOnMapLoadedCallback(new TencentMap.OnMapLoadedCallback() {
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
tencentMap.setMapFrameRate(30);
|
||||
initRoadLine2Map(); // 获取道路任务,渲染在地图上
|
||||
}
|
||||
});
|
||||
@ -409,17 +442,63 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
});
|
||||
|
||||
tencentMap.addTencentMapGestureListener(new TencentMapGestureListener() {
|
||||
@Override
|
||||
public boolean onDoubleTap(float v, float v1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTap(float v, float v1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onFling(float v, float v1) {
|
||||
setLocMarkerStyle(MyLocationStyle.LOCATION_TYPE_FOLLOW_NO_CENTER);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScroll(float v, float v1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongPress(float v, float v1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDown(float v, float v1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onUp(float v, float v1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapStable() {
|
||||
|
||||
}
|
||||
});
|
||||
camera.addCameraListener(new CameraListener() {
|
||||
@Override
|
||||
public void onPictureTaken(@NonNull PictureResult result) {
|
||||
super.onPictureTaken(result);
|
||||
if (camera == null || camera.getSnapshotSize()==null) {
|
||||
return;
|
||||
}
|
||||
// 获取照片数据
|
||||
if (result != null && result.getData() != null && result.getData().length > 0) {
|
||||
super.onPictureTaken(result);
|
||||
System.out.println("收到拍照按钮jieguo:"+result.getSize().toString());
|
||||
// 道路拍照必须为横向拍照
|
||||
// TODO 测试时先解除竖向拍摄检查
|
||||
if (Objects.requireNonNull(camera.getPictureSize()).getWidth() < camera.getPictureSize().getHeight()) {
|
||||
if (Objects.requireNonNull(camera.getSnapshotSize()).getWidth() < camera.getSnapshotSize().getHeight()) {
|
||||
ToastUtils.Message(AutoTakePictureActivity.this, "不允许竖向拍摄...");
|
||||
systemTTS.playText("不允许竖向拍摄");
|
||||
return;
|
||||
@ -562,7 +641,12 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
if (roadLinkEntityList == null/*没有需要匹配的道路数据*/ || currentPoint == null/*没有位置信息*/) {
|
||||
return;
|
||||
}
|
||||
|
||||
float currentSpeed = getSpeed();
|
||||
double matchStartDistance = MATCH_BUFFER_DISTANCE;
|
||||
// 如果速度大于70,则动态调整起点捕捉范围
|
||||
if (currentSpeed>=70) {
|
||||
matchStartDistance = MATCH_BUFFER_DISTANCE*1.5;
|
||||
}
|
||||
// 此处开始匹配起点
|
||||
List<RoadMatchEntity> matchStartList = roadLinkEntityList.stream().filter(it-> GeometryTools.createGeometry(it.getsPoint()).distance(currentPoint)<MATCH_START_BUFFER_DISTANCE).collect(Collectors.toList());
|
||||
// 判断筛选出的数据是否已经在匹配列表中,如果不存在,需要自动领取该任务、记录开始采集时间
|
||||
@ -586,16 +670,17 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
if (!roadMatchEntityList.isEmpty()) {
|
||||
List<RoadMatchEntity> unMatchList = new ArrayList<>();
|
||||
Map<Integer, RoadMatchEntity> finishEntityMap = new HashMap<>();
|
||||
double finalMatchStartDistance = matchStartDistance;
|
||||
roadMatchEntityList.stream().forEach(
|
||||
roadMatchEntity -> {
|
||||
boolean isMatch=GeometryTools.createGeometry(roadMatchEntity.getGeometry()).distance(currentPoint)<MATCH_BUFFER_DISTANCE; // 当前点位是否可以和link匹配到
|
||||
boolean isMatch=GeometryTools.createGeometry(roadMatchEntity.getGeometry()).distance(currentPoint)< finalMatchStartDistance; // 当前点位是否可以和link匹配到
|
||||
if (isMatch) { // 可以匹配到
|
||||
roadMatchEntity.setMatchCount(roadMatchEntity.getMatchCount()+1);
|
||||
roadMatchEntity.setUnMatchCount(0); // 有匹配的数据,则连续未匹配个数归0
|
||||
roadMatchEntity.getMatchPointList().add(new MyCoordinate(currentPoint.getX(), currentPoint.getY()));
|
||||
// 匹配到终点、或匹配距离超过90%
|
||||
if (roadMatchEntity.getMatchPointList().size()>=2&&GeometryTools.getLineStringByMyCoordinate(roadMatchEntity.getMatchPointList()).getLength()/roadMatchEntity.getLength()>=MATCH_CONFIRM_FINISH_BUFFER
|
||||
|| currentPoint.distance(GeometryTools.createGeometry(roadMatchEntity.getePoint()))<=MATCH_BUFFER_DISTANCE) {
|
||||
|| currentPoint.distance(GeometryTools.createGeometry(roadMatchEntity.getePoint()))<= finalMatchStartDistance) {
|
||||
roadMatchEntity.setEndMathchTime(System.currentTimeMillis());
|
||||
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
|
||||
}
|
||||
@ -744,7 +829,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
/**
|
||||
* 取消领取任务
|
||||
* */
|
||||
private Observable cancelReciverTask(List<RoadMatchEntity> cancelMatchLinkList) {
|
||||
private Observable<PoiEntity> cancelReciverTask(List<RoadMatchEntity> cancelMatchLinkList) {
|
||||
return Observable.fromIterable(cancelMatchLinkList)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.computation())
|
||||
@ -897,6 +982,11 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
}
|
||||
|
||||
private void roadSaveWork(PoiEntity poiEntity) throws IOException {
|
||||
// 设置当前数据状态为本地保存
|
||||
poiEntity.setTaskStatus(2);
|
||||
// 更新数据库中状态
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePictureActivity.this, poiEntity);
|
||||
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("taskId", poiEntity.getTaskId());
|
||||
httpParams.put("name", poiEntity.getName());
|
||||
@ -984,6 +1074,8 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
0)); //目标旋转角 0~360° (正北方为0)
|
||||
tencentMap.animateCamera(cameraSigma);
|
||||
}
|
||||
// 设置当前地图的定位显示模式为跟随
|
||||
setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1016,6 +1108,11 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
locationStyle.fillColor(getResources().getColor(android.R.color.transparent));
|
||||
locationStyle.strokeWidth(1);
|
||||
tencentMap.setMyLocationStyle(locationStyle);
|
||||
if (LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER == type) {
|
||||
ivLocation.setEnabled(false);
|
||||
} else {
|
||||
ivLocation.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void benSwitch() {
|
||||
@ -1055,7 +1152,9 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
ivZoomAdd.setVisibility(View.GONE);
|
||||
ivZoomDel.setVisibility(View.GONE);
|
||||
ivLocation.setVisibility(View.GONE);
|
||||
setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE);
|
||||
setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
|
||||
// 道路水平方向图标显示
|
||||
ivPicRoadImage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
//大图
|
||||
@ -1065,6 +1164,8 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
ivZoomDel.setVisibility(View.VISIBLE);
|
||||
ivLocation.setVisibility(View.VISIBLE);
|
||||
setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
|
||||
// 道路水平方向图标不显示
|
||||
ivPicRoadImage.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1078,6 +1179,13 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
super.onResume();
|
||||
camera.open();
|
||||
tvMapView.onResume();
|
||||
camera.setPreviewFrameRate(FRAMENESS);
|
||||
// CameraOptions cameraOptions = camera.getCameraOptions();
|
||||
// if (FRAMENESS>=cameraOptions.getPreviewFrameRateMinValue()&&FRAMENESS<=cameraOptions.getPreviewFrameRateMaxValue()) {
|
||||
// camera.setPreviewFrameRate(FRAMENESS);
|
||||
// } else {
|
||||
// camera.setPreviewFrameRate(0);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1148,6 +1256,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
stopRecordLocation();
|
||||
camera.destroy();
|
||||
tvMapView.onDestroy();
|
||||
trackLocRemovables.stream().forEach(it->it.remove());
|
||||
@ -1162,6 +1271,9 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
editor.putString("data", gson.toJson(roadMatchEntityList));
|
||||
editor.commit();
|
||||
}
|
||||
if (gpsUtils!=null) {
|
||||
gpsUtils.unRegisterAllListener();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1170,36 +1282,79 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
MessageDialog.show(this, "提示", "退出自动采集模式?", "是", "否").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
if (roadMatchEntityList!=null&&!roadMatchEntityList.isEmpty()) {
|
||||
cancelReciverTask(roadMatchEntityList)
|
||||
.subscribe(new Observer() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
stopRecordLocation();
|
||||
Observable.create(new ObservableOnSubscribe<PoiEntity>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<PoiEntity> emitter) throws Exception {
|
||||
// 查询所有已领取的任务,在返回前全部自动取消领取这些任务
|
||||
List<PoiEntity> receivedPoiEntityList = poiDao.getPoiEntityByTaskStatus(1, 4);
|
||||
if (receivedPoiEntityList!=null&&!receivedPoiEntityList.isEmpty()) {
|
||||
receivedPoiEntityList.stream().forEach(poiEntity -> {
|
||||
emitter.onNext(poiEntity);
|
||||
});
|
||||
}
|
||||
emitter.onComplete();
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.flatMap(
|
||||
poiEntity -> {
|
||||
if (poiEntity!=null) {
|
||||
return sendCancelRequest(poiEntity);
|
||||
} else {
|
||||
return Observable.empty();
|
||||
}
|
||||
}
|
||||
)
|
||||
.filter(poiEntity -> poiEntity!=null)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doFinally(new Action() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
showLoadingDialog("正在删除缓存照片...");
|
||||
}
|
||||
})
|
||||
.observeOn(Schedulers.io())
|
||||
.doOnComplete(new Action() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
// 删除缓存目录
|
||||
FileUtils.deleteFile(tmpPicFoldPath);
|
||||
}
|
||||
})
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doFinally(new Action() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
showLoadingDialog("正在删除缓存照片...");
|
||||
}
|
||||
})
|
||||
.subscribe(new Observer<PoiEntity>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
showLoadingDialog("正在取消已领取的任务...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Object o) {
|
||||
@Override
|
||||
public void onNext(PoiEntity o) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Toast.makeText(AutoTakePictureActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Toast.makeText(AutoTakePictureActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
AutoTakePictureActivity.this.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
// 重新刷新地图
|
||||
initRoadLine2Map();
|
||||
// 执行结束后清空已匹配列表
|
||||
roadMatchEntityList.clear();
|
||||
AutoTakePictureActivity.this.finish();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
AutoTakePictureActivity.this.finish();
|
||||
}
|
||||
@Override
|
||||
public void onComplete() {
|
||||
// // 重新刷新地图
|
||||
// initRoadLine2Map();
|
||||
dismissLoadingDialog();
|
||||
// 执行结束后清空已匹配列表
|
||||
roadMatchEntityList.clear();
|
||||
AutoTakePictureActivity.this.finish();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@ -1401,7 +1556,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
if (msg.what == 0x101) {
|
||||
System.out.println("收到拍照按钮请求");
|
||||
camera.takePictureSnapshot();
|
||||
handler.sendEmptyMessageDelayed(0x101, 1000);
|
||||
handler.sendEmptyMessageDelayed(0x101, 500);
|
||||
} else if (msg.what == 0x102) {
|
||||
} else if (msg.what == 0x103) {
|
||||
RoadMatchEntity roadMatchEntity = (RoadMatchEntity) msg.obj;
|
||||
@ -1465,6 +1620,22 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
}
|
||||
});
|
||||
|
||||
private float getSpeed() {
|
||||
float speed = Constant.currentLocation.getSpeed();//米/秒
|
||||
if (speed != 0) {
|
||||
speed = (speed * 3600 / 1000);//km/h
|
||||
} else {
|
||||
if (oldCurrentLocation != null) {
|
||||
LatLng startLatLng = new LatLng(oldCurrentLocation.getLatitude(), oldCurrentLocation.getLongitude());//旧的坐标
|
||||
LatLng endLatLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude());//新的坐标
|
||||
double geometry = GeometryTools.distanceToDouble(startLatLng, endLatLng);//米
|
||||
speed = (float) (geometry * 3600 / 1000);
|
||||
}
|
||||
oldCurrentLocation = Constant.currentLocation;
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMessageMainThread(Message msg) {
|
||||
if (msg.what == Constant.EVENT_WHAT_LOCATION_CHANGE) { // 用户位置更新
|
||||
|
@ -726,6 +726,8 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
|
||||
ivZoomDel.setVisibility(View.GONE);
|
||||
ivLocation.setVisibility(View.GONE);
|
||||
setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE);
|
||||
// 道路水平方向图标显示
|
||||
ivPicRoadImage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
//大图
|
||||
@ -735,6 +737,8 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
|
||||
ivZoomDel.setVisibility(View.VISIBLE);
|
||||
ivLocation.setVisibility(View.VISIBLE);
|
||||
setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
|
||||
// 道路水平方向图标显示
|
||||
ivPicRoadImage.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -843,6 +847,9 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
|
||||
if (EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
if (gpsUtils!=null) {
|
||||
gpsUtils.unRegisterAllListener();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
@ -945,17 +952,25 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSpeedLimitTips = false;
|
||||
private void initSpeed() {
|
||||
if (isSpeedLimitTips == true) {
|
||||
return;
|
||||
}
|
||||
float speed = Constant.currentLocation.getSpeed();//米/秒
|
||||
if (speed != 0) {
|
||||
float a = (speed * 3600 / 1000);//km/h
|
||||
if (type == 3) {
|
||||
if (a > 40) {//40千米/h
|
||||
systemTTS.stopSpeak();
|
||||
systemTTS.playText("您已超速");
|
||||
isSpeedLimitTips=true;
|
||||
}
|
||||
} else if (type == 4) {
|
||||
if (a > 80) {//80千米/h
|
||||
systemTTS.stopSpeak();
|
||||
systemTTS.playText("您已超速");
|
||||
isSpeedLimitTips=true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -967,24 +982,32 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
|
||||
if (radioPicture == 2) {
|
||||
double speeds = ((geometry / 1) * 3600 / 1000);
|
||||
if (speeds > 40) {//40千米/h
|
||||
systemTTS.stopSpeak();
|
||||
systemTTS.playText("您已超速");
|
||||
isSpeedLimitTips=true;
|
||||
}
|
||||
} else if (radioPicture == 3) {
|
||||
double speeds = ((geometry / 2) * 3600 / 1000);
|
||||
if (speeds > 40) {//40千米/h
|
||||
systemTTS.stopSpeak();
|
||||
systemTTS.playText("您已超速");
|
||||
isSpeedLimitTips=true;
|
||||
}
|
||||
}
|
||||
} else if (type == 4) {
|
||||
if (radioPicture == 2) {
|
||||
double speeds = ((geometry / 1) * 3600 / 1000);
|
||||
if (speeds > 80) { //80千米/h
|
||||
systemTTS.stopSpeak();
|
||||
systemTTS.playText("您已超速");
|
||||
isSpeedLimitTips=true;
|
||||
}
|
||||
} else if (radioPicture == 3) {
|
||||
double speeds = ((geometry / 2) * 3600 / 1000);
|
||||
if (speeds > 80) { //80千米/h
|
||||
systemTTS.stopSpeak();
|
||||
systemTTS.playText("您已超速");
|
||||
isSpeedLimitTips=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.github.lazylibrary.util.StringUtils;
|
||||
import com.jcodecraeer.xrecyclerview.XRecyclerView;
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.activity.WebActivity;
|
||||
@ -80,6 +81,10 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
public void showLoadingDialog() {
|
||||
showLoadingDialog(null);
|
||||
}
|
||||
|
||||
public void showLoadingDialog(String msg) {
|
||||
if (alertDialog!=null) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
@ -91,6 +96,10 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
});
|
||||
//loading样式
|
||||
View view = LayoutInflater.from(this).inflate(R.layout.loading, null);
|
||||
TextView tv = view.findViewById(R.id.progressBar_tx);
|
||||
if (!StringUtils.isBlank(msg)) {
|
||||
tv.setText(msg);
|
||||
}
|
||||
alertDialog.setView(view);
|
||||
alertDialog.setCanceledOnTouchOutside(false);
|
||||
alertDialog.show();
|
||||
|
@ -175,7 +175,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
});
|
||||
private TextView tvTenantGaps;
|
||||
private TencentMarkerUtils tencentMarkerUtils;
|
||||
private Button imgAutoMatchRoad; // 自动匹配道路
|
||||
private ImageView imgAutoMatchRoad; // 自动匹配道路
|
||||
|
||||
public static TreasureFragment newInstance(Bundle bundle) {
|
||||
TreasureFragment fragment = new TreasureFragment();
|
||||
@ -302,45 +302,51 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
});
|
||||
|
||||
imgAutoMatchRoad = findViewById(R.id.iv_auto_match_road);
|
||||
// 如果当前用户的level为1或2,自动采集功能才会开放
|
||||
if (Constant.LEVEL == 1||Constant.LEVEL==2) {
|
||||
imgAutoMatchRoad.setVisibility(View.VISIBLE);
|
||||
}
|
||||
imgAutoMatchRoad.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// 设置亮度和摄像机刷新率
|
||||
CustomDialog.show((AppCompatActivity) getActivity(), R.layout.camera_setting_pre, new CustomDialog.OnBindView() {
|
||||
@Override
|
||||
public void onBind(CustomDialog dialog, View v) {
|
||||
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("pic", Context.MODE_PRIVATE);
|
||||
int brightness = sharedPreferences.getInt("brightness", 40);
|
||||
EditText edtBrightness = v.findViewById(R.id.edt_camera_setting_brightness);
|
||||
edtBrightness.setText(brightness+"");
|
||||
|
||||
int framness = sharedPreferences.getInt("framness", 30);
|
||||
EditText edtFramness = v.findViewById(R.id.edt_camera_setting_framness);
|
||||
edtFramness.setText(framness+"");
|
||||
|
||||
Button btnConfirm = v.findViewById(R.id.btn_camera_setting_confirm);
|
||||
btnConfirm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SharedPreferences.Editor editor = getActivity().getSharedPreferences("pic", Context.MODE_PRIVATE).edit();
|
||||
if (!edtBrightness.getText().toString().isEmpty()) {
|
||||
int b = Integer.parseInt(edtBrightness.getText().toString());
|
||||
editor.putInt("brightness", b);
|
||||
}
|
||||
if (!edtFramness.getText().toString().isEmpty()) {
|
||||
int f = Integer.parseInt(edtFramness.getText().toString());
|
||||
editor.putInt("framness", f);
|
||||
}
|
||||
editor.commit();
|
||||
Toast.makeText(getActivity(), "设置完成", Toast.LENGTH_SHORT).show();
|
||||
|
||||
Intent autoMatchIntent = new Intent(getContext(), AutoTakePictureActivity.class);
|
||||
startActivity(autoMatchIntent);
|
||||
dialog.doDismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
}).setFullScreen(true);
|
||||
Intent autoMatchIntent = new Intent(getContext(), AutoTakePictureActivity.class);
|
||||
startActivity(autoMatchIntent);
|
||||
// // 设置亮度和摄像机刷新率
|
||||
// CustomDialog.show((AppCompatActivity) getActivity(), R.layout.camera_setting_pre, new CustomDialog.OnBindView() {
|
||||
// @Override
|
||||
// public void onBind(CustomDialog dialog, View v) {
|
||||
// SharedPreferences sharedPreferences = getActivity().getSharedPreferences("pic", Context.MODE_PRIVATE);
|
||||
// int brightness = sharedPreferences.getInt("brightness", 40);
|
||||
// EditText edtBrightness = v.findViewById(R.id.edt_camera_setting_brightness);
|
||||
// edtBrightness.setText(brightness+"");
|
||||
//
|
||||
// int framness = sharedPreferences.getInt("framness", 30);
|
||||
// EditText edtFramness = v.findViewById(R.id.edt_camera_setting_framness);
|
||||
// edtFramness.setText(framness+"");
|
||||
//
|
||||
// Button btnConfirm = v.findViewById(R.id.btn_camera_setting_confirm);
|
||||
// btnConfirm.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// SharedPreferences.Editor editor = getActivity().getSharedPreferences("pic", Context.MODE_PRIVATE).edit();
|
||||
// if (!edtBrightness.getText().toString().isEmpty()) {
|
||||
// int b = Integer.parseInt(edtBrightness.getText().toString());
|
||||
// editor.putInt("brightness", b);
|
||||
// }
|
||||
// if (!edtFramness.getText().toString().isEmpty()) {
|
||||
// int f = Integer.parseInt(edtFramness.getText().toString());
|
||||
// editor.putInt("framness", f);
|
||||
// }
|
||||
// editor.commit();
|
||||
// Toast.makeText(getActivity(), "设置完成", Toast.LENGTH_SHORT).show();
|
||||
//
|
||||
// Intent autoMatchIntent = new Intent(getContext(), AutoTakePictureActivity.class);
|
||||
// startActivity(autoMatchIntent);
|
||||
// dialog.doDismiss();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }).setFullScreen(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ public interface PoiDao {
|
||||
// @Query("SELECT * FROM poi WHERE taskStatus=:taskStatus and type=:type and (:isExclusive=-1 or isExclusive=:isExclusive) ")
|
||||
List<PoiEntity> getAllTaskStatus(int taskStatus, int taskStatus1, int type, int type1, int isExclusive, int isExclusive1);
|
||||
|
||||
@Query("SELECT * FROM poi WHERE taskStatus=:taskStatus and type=:type")
|
||||
List<PoiEntity> getPoiEntityByTaskStatus(int taskStatus, int type);
|
||||
|
||||
@Query("SELECT * FROM poi where id=:id")
|
||||
PoiEntity getPoiEntity(String id);
|
||||
|
@ -7,6 +7,7 @@ import android.content.Intent;
|
||||
import android.location.Address;
|
||||
import android.location.Criteria;
|
||||
import android.location.Geocoder;
|
||||
import android.location.GnssStatus;
|
||||
import android.location.GpsSatellite;
|
||||
import android.location.GpsStatus;
|
||||
import android.location.Location;
|
||||
@ -18,6 +19,8 @@ import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -52,7 +55,7 @@ public class GPSUtils {
|
||||
// getLocationData(location);
|
||||
mLocation = mLocationManager.getLastKnownLocation(bestProvider);
|
||||
// 监听状态
|
||||
mLocationManager.addGpsStatusListener(listener);
|
||||
mLocationManager.registerGnssStatusCallback(listener);
|
||||
// 绑定监听,有4个参数
|
||||
// 参数1,设备:有GPS_PROVIDER和NETWORK_PROVIDER两种
|
||||
// 参数2,位置信息更新周期,单位毫秒
|
||||
@ -130,6 +133,10 @@ public class GPSUtils {
|
||||
|
||||
//位置信息变化时触发
|
||||
public void onLocationChanged(Location location) {
|
||||
if (mContext == null) {
|
||||
mLocationManager.removeUpdates(this);
|
||||
return;
|
||||
}
|
||||
mLocation = location;
|
||||
Log.i(TAG, "时间:" + location.getTime());
|
||||
Log.i(TAG, "经度:" + location.getLongitude());
|
||||
@ -183,39 +190,35 @@ public class GPSUtils {
|
||||
|
||||
|
||||
// 状态监听
|
||||
GpsStatus.Listener listener = new GpsStatus.Listener() {
|
||||
public void onGpsStatusChanged(int event) {
|
||||
switch (event) {
|
||||
// 第一次定位
|
||||
case GpsStatus.GPS_EVENT_FIRST_FIX:
|
||||
Log.i(TAG, "第一次定位");
|
||||
break;
|
||||
// 卫星状态改变
|
||||
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
|
||||
Log.i(TAG, "卫星状态改变");
|
||||
GpsStatus gpsStatus = mLocationManager.getGpsStatus(null);
|
||||
// 获取卫星颗数的默认最大值
|
||||
int maxSatellites = gpsStatus.getMaxSatellites();
|
||||
// 创建一个迭代器保存所有卫星
|
||||
Iterator<GpsSatellite> iters = gpsStatus.getSatellites()
|
||||
.iterator();
|
||||
int count = 0;
|
||||
while (iters.hasNext() && count <= maxSatellites) {
|
||||
GpsSatellite s = iters.next();
|
||||
count++;
|
||||
}
|
||||
if (onClickGPSStatus != null) {
|
||||
onClickGPSStatus.onGpsCount(count);
|
||||
}
|
||||
break;
|
||||
//定位启动
|
||||
case GpsStatus.GPS_EVENT_STARTED:
|
||||
Log.i(TAG, "定位启动");
|
||||
break;
|
||||
//定位结束
|
||||
case GpsStatus.GPS_EVENT_STOPPED:
|
||||
Log.i(TAG, "定位结束");
|
||||
break;
|
||||
GnssStatus.Callback listener = new GnssStatus.Callback() {
|
||||
@Override
|
||||
public void onStarted() {
|
||||
super.onStarted();
|
||||
Log.i(TAG, "定位启动");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopped() {
|
||||
super.onStopped();
|
||||
Log.i(TAG, "定位结束");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFirstFix(int ttffMillis) {
|
||||
super.onFirstFix(ttffMillis);
|
||||
Log.i(TAG, "第一次定位");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSatelliteStatusChanged(@NonNull GnssStatus status) {
|
||||
super.onSatelliteStatusChanged(status);
|
||||
if (mContext == null) {
|
||||
mLocationManager.unregisterGnssStatusCallback(this);
|
||||
return;
|
||||
}
|
||||
Log.i(TAG, "卫星状态改变");
|
||||
if (onClickGPSStatus != null) {
|
||||
onClickGPSStatus.onGpsCount(status.getSatelliteCount());
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -229,4 +232,8 @@ public class GPSUtils {
|
||||
void onGpsCount(int count);
|
||||
}
|
||||
|
||||
public void unRegisterAllListener() {
|
||||
mLocationManager.unregisterGnssStatusCallback(listener);
|
||||
mLocationManager.removeUpdates(locationListener);
|
||||
}
|
||||
}
|
||||
|
6
app/src/main/res/drawable/round_bg_gray.xml
Normal file
6
app/src/main/res/drawable/round_bg_gray.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/colorGrays"/>
|
||||
</shape>
|
6
app/src/main/res/drawable/round_bg_white.xml
Normal file
6
app/src/main/res/drawable/round_bg_white.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/white"/>
|
||||
</shape>
|
14
app/src/main/res/drawable/selector_round_bg.xml
Normal file
14
app/src/main/res/drawable/selector_round_bg.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/round_bg_gray"/> <!-- pressed -->
|
||||
<item android:state_focused="true"
|
||||
android:drawable="@drawable/round_bg_gray"/> <!-- focused -->
|
||||
<item android:state_selected="true"
|
||||
android:drawable="@drawable/round_bg_gray"/>
|
||||
<item android:state_checked="true"
|
||||
android:drawable="@drawable/round_bg_gray"/>
|
||||
<item android:state_enabled="false"
|
||||
android:drawable="@drawable/round_bg_gray"/>
|
||||
<item android:drawable="@drawable/round_bg_white" /> <!-- default -->
|
||||
</selector>
|
@ -43,12 +43,13 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_view"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="157dp"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@android:color/transparent"
|
||||
app:layout_constraintHeight_default="percent"
|
||||
app:layout_constraintHeight_percent="0.4"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintWidth_default="percent"
|
||||
app:layout_constraintWidth_percent="0.4" />
|
||||
|
||||
@ -117,7 +118,9 @@
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:src="@mipmap/mine_location"
|
||||
android:background="@drawable/selector_round_bg"
|
||||
android:src="@mipmap/location_auto_pic"
|
||||
android:padding="8dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="@id/iv_zoom_del"
|
||||
app:layout_constraintTop_toBottomOf="@id/iv_zoom_del" />
|
||||
@ -138,6 +141,7 @@
|
||||
android:id="@+id/btn_setting"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:text="设置"
|
||||
android:layout_marginTop="@dimen/default_widget_padding"
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_switch"
|
||||
@ -146,6 +150,7 @@
|
||||
<Switch
|
||||
android:id="@+id/location_switch"
|
||||
android:text="启用定位"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
|
@ -92,7 +92,6 @@
|
||||
android:background="@drawable/atlas_selector"
|
||||
android:button="@null"
|
||||
android:checked="false"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/iv_zoom_del"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/iv_zoom_add" />
|
||||
|
||||
@ -102,7 +101,6 @@
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:src="@mipmap/submit"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/iv_refrish"
|
||||
app:layout_constraintEnd_toEndOf="@+id/cb_map_type"
|
||||
app:layout_constraintLeft_toLeftOf="@id/cb_map_type"
|
||||
app:layout_constraintTop_toTopOf="@+id/iv_zoom_del" />
|
||||
@ -112,19 +110,20 @@
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:src="@mipmap/filter"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/iv_location"
|
||||
app:layout_constraintLeft_toLeftOf="@id/cb_map_type"
|
||||
app:layout_constraintLeft_toLeftOf="@id/iv_submit"
|
||||
app:layout_constraintTop_toTopOf="@+id/iv_refrish" />
|
||||
|
||||
<Button
|
||||
<ImageView
|
||||
android:id="@+id/iv_auto_match_road"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:src="@mipmap/auto_camera"
|
||||
android:background="@drawable/selector_round_bg"
|
||||
android:text="道路自动匹配"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"/>
|
||||
android:visibility="gone"
|
||||
android:padding="8dp"
|
||||
app:layout_constraintLeft_toLeftOf="@id/iv_submit"
|
||||
app:layout_constraintTop_toTopOf="@+id/iv_location"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_zoom_add"
|
||||
|
BIN
app/src/main/res/mipmap-xxhdpi/auto_camera.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/auto_camera.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/location_auto_pic.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/location_auto_pic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
Loading…
x
Reference in New Issue
Block a user