修改导航界面为横向
This commit is contained in:
commit
8b8866d3fb
@ -11,9 +11,9 @@ android {
|
||||
defaultConfig {
|
||||
applicationId "com.navinfo.outdoor"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 32
|
||||
versionCode 40
|
||||
versionName "8.221219"
|
||||
targetSdkVersion 30
|
||||
versionCode 41
|
||||
versionName "8.230109"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
lintOptions {
|
||||
|
@ -150,13 +150,13 @@
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.NaviCarActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
android:screenOrientation="landscape" />
|
||||
<activity
|
||||
android:name=".activity.NaviRideActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
android:screenOrientation="landscape" />
|
||||
<activity
|
||||
android:name=".activity.NaviWalkActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
android:screenOrientation="landscape" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
|
@ -157,12 +157,14 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@ -1301,83 +1303,113 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
/**
|
||||
* 结束采集,对照片归档
|
||||
* */
|
||||
private boolean hasFinishTask = false; // 当前是否包含已完成任务未处理完
|
||||
private int finishTaskCount = 0;
|
||||
private boolean wantBack = false; // 用户是否想要退出当前界面,如果当前有正在处理的图片转移任务,会阻挡用户退出,此时该值状态置为true,当照片处理完后,可以对话框提示用户退出
|
||||
private void finishRoadTask(Map<Integer, RoadMatchEntity> finishEntityMap) {
|
||||
hasFinishTask = true;
|
||||
Observable.fromIterable(finishEntityMap.values())
|
||||
.subscribeOn(Schedulers.io()).observeOn(Schedulers.computation())
|
||||
.filter(roadMatchEntity -> roadMatchEntity!=null)
|
||||
.map(roadMatchEntity -> {
|
||||
// 判断是否已领取,未领取则调用领取数据接口
|
||||
PoiEntity poiEntity = poiDao.getTaskIdPoiEntity(roadMatchEntity.getId());
|
||||
if (poiEntity == null) {
|
||||
// 数据库中不存在,尝试再次领取
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePictureActivity.this, translateRoadMatchEntity(roadMatchEntity));
|
||||
// 调用网络领取任务
|
||||
receiverRoadTask(roadMatchEntity).subscribe(receiveObserver);
|
||||
}
|
||||
if (finishEntityMap!=null&&!finishEntityMap.isEmpty()) {
|
||||
finishTaskCount++;
|
||||
|
||||
List<LocationRecorder> recorderList = recorderDao.getLocationRecorderByTime(roadMatchEntity.getStartMatchTime(), roadMatchEntity.getEndMathchTime());
|
||||
File recorderFolder = new File(Constant.PICTURE_FOLDER+"/"+poiEntity.getId());
|
||||
if (!recorderFolder.exists()) {
|
||||
recorderFolder.mkdirs();
|
||||
}
|
||||
// 编辑paper.txt
|
||||
// 复制图片文件
|
||||
File paperFile = new File(recorderFolder.getAbsolutePath(), "paper.txt");
|
||||
for (int i = 0; i < recorderList.size(); i++) {
|
||||
File originImg = new File(recorderList.get(i).getImgFileName());
|
||||
File destFile = new File(recorderFolder.getAbsolutePath()+"/"+i+".jpg");
|
||||
if (!destFile.exists()) {
|
||||
FileUtils.copyFile(originImg.getAbsolutePath(), destFile.getAbsolutePath());
|
||||
Observable.fromIterable(finishEntityMap.values())
|
||||
.subscribeOn(Schedulers.io()).observeOn(Schedulers.computation())
|
||||
.filter(roadMatchEntity -> roadMatchEntity!=null)
|
||||
.map(roadMatchEntity -> {
|
||||
// 判断是否已领取,未领取则调用领取数据接口
|
||||
PoiEntity poiEntity = poiDao.getTaskIdPoiEntity(roadMatchEntity.getId());
|
||||
if (poiEntity == null) {
|
||||
// 数据库中不存在,尝试再次领取
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePictureActivity.this, translateRoadMatchEntity(roadMatchEntity));
|
||||
// 调用网络领取任务
|
||||
receiverRoadTask(roadMatchEntity).subscribe(receiveObserver);
|
||||
}
|
||||
FileUtils.writeFile(paperFile.getAbsolutePath(), recorderList.get(i).toString(picFormatter ,i), true);
|
||||
}
|
||||
|
||||
return poiEntity;
|
||||
})
|
||||
.doOnNext(poiEntity -> {
|
||||
// 网络提交数据
|
||||
if (poiEntity!=null) {
|
||||
// 提交数据,更新状态
|
||||
roadSaveWork(poiEntity);
|
||||
List<LocationRecorder> recorderList = recorderDao.getLocationRecorderByTime(roadMatchEntity.getStartMatchTime(), roadMatchEntity.getEndMathchTime());
|
||||
File recorderFolder = new File(Constant.PICTURE_FOLDER+"/"+poiEntity.getId());
|
||||
if (!recorderFolder.exists()) {
|
||||
recorderFolder.mkdirs();
|
||||
}
|
||||
// 编辑paper.txt
|
||||
// 复制图片文件
|
||||
File paperFile = new File(recorderFolder.getAbsolutePath(), "paper.txt");
|
||||
for (int i = 0; i < recorderList.size(); i++) {
|
||||
File originImg = new File(recorderList.get(i).getImgFileName());
|
||||
File destFile = new File(recorderFolder.getAbsolutePath()+"/"+i+".jpg");
|
||||
if (!destFile.exists()) {
|
||||
FileUtils.copyFile(originImg.getAbsolutePath(), destFile.getAbsolutePath());
|
||||
}
|
||||
FileUtils.writeFile(paperFile.getAbsolutePath(), recorderList.get(i).toString(picFormatter ,i), true);
|
||||
}
|
||||
|
||||
return poiEntity;
|
||||
})
|
||||
.doOnNext(poiEntity -> {
|
||||
// 网络提交数据
|
||||
if (poiEntity!=null) {
|
||||
// 提交数据,更新状态
|
||||
roadSaveWork(poiEntity);
|
||||
/*poiEntity.setTaskStatus(3);
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePictureActivity.this, poiEntity);*/
|
||||
}
|
||||
})
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.onErrorResumeNext(new Function<Throwable, ObservableSource<? extends PoiEntity>>() {
|
||||
@Override
|
||||
public ObservableSource<? extends PoiEntity> apply(Throwable throwable) throws Exception {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.subscribe(new Consumer<PoiEntity>() {
|
||||
@Override
|
||||
public void accept(PoiEntity poiEntity) {
|
||||
finishEntityMap.remove(poiEntity.getTaskId());
|
||||
}
|
||||
})
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.onErrorResumeNext(Observable.empty())
|
||||
.subscribe(new Consumer<PoiEntity>() {
|
||||
@Override
|
||||
public void accept(PoiEntity poiEntity) {
|
||||
// // 已经处理过该任务,将其从finish列表中移除
|
||||
// if (poiEntity!=null) {
|
||||
// finishEntityMap.remove(poiEntity.getTaskId());
|
||||
// }
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) {
|
||||
// 此处异常可能是服务返回的数据无法解析,但http正常返回了,因此可能为程序问题,不再重复尝试上报
|
||||
systemTTS.playText("注意,领取任务失败!");
|
||||
XLog.e("完成失败:"+throwable.getMessage());
|
||||
ToastUtils.Message(AutoTakePictureActivity.this, throwable.getMessage());
|
||||
finishTaskCount--;
|
||||
if (finishTaskCount == 0) {
|
||||
showExitDialog(true);
|
||||
}
|
||||
}
|
||||
}, new Action() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
// 重新绘制网络任务和本地任务
|
||||
initRoadLine2Map();
|
||||
finishTaskCount--;
|
||||
if (finishTaskCount == 0) {
|
||||
showExitDialog(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void showExitDialog(boolean hasError) {
|
||||
StringBuilder dialogMessage = new StringBuilder("任务数据处理完成,是否退出当前界面");
|
||||
if (hasError) {
|
||||
dialogMessage.append("(注意,其中有部分任务处理失败)");
|
||||
}
|
||||
MessageDialog.show(AutoTakePictureActivity.this, "退出当前界面", dialogMessage)
|
||||
.setOkButton("确定", new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) {
|
||||
// 此处异常可能是服务返回的数据无法解析,但http正常返回了,因此可能为程序问题,不再重复尝试上报
|
||||
systemTTS.playText("注意,领取任务失败!");
|
||||
XLog.e("完成失败:"+throwable.getMessage());
|
||||
ToastUtils.Message(AutoTakePictureActivity.this, throwable.getMessage());
|
||||
hasFinishTask = false;
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
AutoTakePictureActivity.this.finish();
|
||||
return false;
|
||||
}
|
||||
}, new Action() {
|
||||
})
|
||||
.setCancelButton("取消", new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
// 重新绘制网络任务和本地任务
|
||||
initRoadLine2Map();
|
||||
// finishEntityMap.clear();
|
||||
hasFinishTask = false;
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
baseDialog.doDismiss();
|
||||
wantBack = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void roadSaveWork(PoiEntity poiEntity) throws IOException {
|
||||
@ -1681,8 +1713,9 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
if (hasFinishTask) {
|
||||
if (finishTaskCount>0) {
|
||||
MessageDialog.show(this, "提示", "后台正在处理已拍摄完成的任务,请稍后再退出当前界面");
|
||||
wantBack = true;
|
||||
return;
|
||||
}
|
||||
MessageDialog.show(this, "提示", "退出自动采集模式?", "是", "否").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user