修改导航界面为横向

This commit is contained in:
xiaoyan 2023-01-09 14:54:27 +08:00
commit 8b8866d3fb
3 changed files with 103 additions and 70 deletions

View File

@ -11,9 +11,9 @@ android {
defaultConfig { defaultConfig {
applicationId "com.navinfo.outdoor" applicationId "com.navinfo.outdoor"
minSdkVersion 24 minSdkVersion 24
targetSdkVersion 32 targetSdkVersion 30
versionCode 40 versionCode 41
versionName "8.221219" versionName "8.230109"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
lintOptions { lintOptions {

View File

@ -150,13 +150,13 @@
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity <activity
android:name=".activity.NaviCarActivity" android:name=".activity.NaviCarActivity"
android:screenOrientation="portrait" /> android:screenOrientation="landscape" />
<activity <activity
android:name=".activity.NaviRideActivity" android:name=".activity.NaviRideActivity"
android:screenOrientation="portrait" /> android:screenOrientation="landscape" />
<activity <activity
android:name=".activity.NaviWalkActivity" android:name=".activity.NaviWalkActivity"
android:screenOrientation="portrait" /> android:screenOrientation="landscape" />
<provider <provider
android:name="androidx.core.content.FileProvider" android:name="androidx.core.content.FileProvider"

View File

@ -157,12 +157,14 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; 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) { private void finishRoadTask(Map<Integer, RoadMatchEntity> finishEntityMap) {
hasFinishTask = true; if (finishEntityMap!=null&&!finishEntityMap.isEmpty()) {
Observable.fromIterable(finishEntityMap.values()) finishTaskCount++;
.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);
}
List<LocationRecorder> recorderList = recorderDao.getLocationRecorderByTime(roadMatchEntity.getStartMatchTime(), roadMatchEntity.getEndMathchTime()); Observable.fromIterable(finishEntityMap.values())
File recorderFolder = new File(Constant.PICTURE_FOLDER+"/"+poiEntity.getId()); .subscribeOn(Schedulers.io()).observeOn(Schedulers.computation())
if (!recorderFolder.exists()) { .filter(roadMatchEntity -> roadMatchEntity!=null)
recorderFolder.mkdirs(); .map(roadMatchEntity -> {
} // 判断是否已领取未领取则调用领取数据接口
// 编辑paper.txt PoiEntity poiEntity = poiDao.getTaskIdPoiEntity(roadMatchEntity.getId());
// 复制图片文件 if (poiEntity == null) {
File paperFile = new File(recorderFolder.getAbsolutePath(), "paper.txt"); // 数据库中不存在尝试再次领取
for (int i = 0; i < recorderList.size(); i++) { InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePictureActivity.this, translateRoadMatchEntity(roadMatchEntity));
File originImg = new File(recorderList.get(i).getImgFileName()); // 调用网络领取任务
File destFile = new File(recorderFolder.getAbsolutePath()+"/"+i+".jpg"); receiverRoadTask(roadMatchEntity).subscribe(receiveObserver);
if (!destFile.exists()) {
FileUtils.copyFile(originImg.getAbsolutePath(), destFile.getAbsolutePath());
} }
FileUtils.writeFile(paperFile.getAbsolutePath(), recorderList.get(i).toString(picFormatter ,i), true);
}
return poiEntity; List<LocationRecorder> recorderList = recorderDao.getLocationRecorderByTime(roadMatchEntity.getStartMatchTime(), roadMatchEntity.getEndMathchTime());
}) File recorderFolder = new File(Constant.PICTURE_FOLDER+"/"+poiEntity.getId());
.doOnNext(poiEntity -> { if (!recorderFolder.exists()) {
// 网络提交数据 recorderFolder.mkdirs();
if (poiEntity!=null) { }
// 提交数据更新状态 // 编辑paper.txt
roadSaveWork(poiEntity); // 复制图片文件
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); /*poiEntity.setTaskStatus(3);
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePictureActivity.this, poiEntity);*/ InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePictureActivity.this, poiEntity);*/
} finishEntityMap.remove(poiEntity.getTaskId());
}) }
.observeOn(AndroidSchedulers.mainThread()) })
.onErrorResumeNext(new Function<Throwable, ObservableSource<? extends PoiEntity>>() { .observeOn(AndroidSchedulers.mainThread())
@Override .onErrorResumeNext(Observable.empty())
public ObservableSource<? extends PoiEntity> apply(Throwable throwable) throws Exception { .subscribe(new Consumer<PoiEntity>() {
return null; @Override
} public void accept(PoiEntity poiEntity) {
})
.subscribe(new Consumer<PoiEntity>() {
@Override
public void accept(PoiEntity poiEntity) {
// // 已经处理过该任务将其从finish列表中移除 // // 已经处理过该任务将其从finish列表中移除
// if (poiEntity!=null) { // if (poiEntity!=null) {
// finishEntityMap.remove(poiEntity.getTaskId()); // 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 @Override
public void accept(Throwable throwable) { public boolean onClick(BaseDialog baseDialog, View v) {
// 此处异常可能是服务返回的数据无法解析但http正常返回了因此可能为程序问题不再重复尝试上报 AutoTakePictureActivity.this.finish();
systemTTS.playText("注意,领取任务失败!"); return false;
XLog.e("完成失败:"+throwable.getMessage());
ToastUtils.Message(AutoTakePictureActivity.this, throwable.getMessage());
hasFinishTask = false;
} }
}, new Action() { })
.setCancelButton("取消", new OnDialogButtonClickListener() {
@Override @Override
public void run() throws Exception { public boolean onClick(BaseDialog baseDialog, View v) {
// 重新绘制网络任务和本地任务 baseDialog.doDismiss();
initRoadLine2Map(); wantBack = false;
// finishEntityMap.clear(); return false;
hasFinishTask = false;
} }
}); })
.show();
} }
private void roadSaveWork(PoiEntity poiEntity) throws IOException { private void roadSaveWork(PoiEntity poiEntity) throws IOException {
@ -1681,8 +1713,9 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
@Override @Override
public void onBackPressed() { public void onBackPressed() {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
if (hasFinishTask) { if (finishTaskCount>0) {
MessageDialog.show(this, "提示", "后台正在处理已拍摄完成的任务,请稍后再退出当前界面"); MessageDialog.show(this, "提示", "后台正在处理已拍摄完成的任务,请稍后再退出当前界面");
wantBack = true;
return; return;
} }
MessageDialog.show(this, "提示", "退出自动采集模式?", "", "").setOnOkButtonClickListener(new OnDialogButtonClickListener() { MessageDialog.show(this, "提示", "退出自动采集模式?", "", "").setOnOkButtonClickListener(new OnDialogButtonClickListener() {