fix: 修改连续拍照txt与照片名称不匹配的问题

This commit is contained in:
xiaoyan 2022-08-17 16:23:55 +08:00
parent 08a542f5ec
commit 02215187e7
2 changed files with 74 additions and 34 deletions

View File

@ -10,7 +10,7 @@ android {
minSdkVersion 24
targetSdkVersion 30
versionCode 26
versionName "8.220815"
versionName "8.220816"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {

View File

@ -103,10 +103,21 @@ import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import static com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE;
import static com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
/**
* 拍照
* poi录像 道路
@ -133,7 +144,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
private GPSUtils gpsUtils;
private Location gpsLocation;
private boolean isMapSlide = false;
private boolean isOration = true;
private boolean isOration = true; // 当前是否为自动拍照模式
private boolean isTerminus = false;
private boolean isBack = true;
private int initCount;
@ -359,13 +370,14 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
synchronized (finalVideoPath) {
// 生成点位marker
initMarker(booleanExtra);
int currentIndex = videoIndex = Integer.parseInt(file.getName().replace(".webp", ""));
// 下一张照片的路径
finalVideoPath = Objects.requireNonNull(file.getParentFile()).getAbsolutePath() + "/" + (videoIndex + 1) + ".webp";
tvTitle.setText("拍摄成功:" + (videoIndex + 1));
result.toFile(file, new FileCallback() {
@Override
public void onFileReady(@Nullable File file) {
int currentIndex = videoIndex = Integer.parseInt(file.getName().replace(".webp", ""));
// 下一张照片的路径
finalVideoPath = Objects.requireNonNull(file.getParentFile()).getAbsolutePath() + "/" + (videoIndex + 1) + ".webp";
tvTitle.setText("拍摄成功:" + (videoIndex + 1));
UserApplication.fixedThreadPool.execute(new Jpg2WebpRunnable(/*result, */file, 0, booleanExtra, currentIndex));
}
});
@ -603,16 +615,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_stop_picture:
if (isOration) {
stopTimer();
}
picturesBuilder.append(TimestampUtil.time()).append(",").append("onClick 点击了结束采集 ,");
Intent intent = new Intent();
finalVideoPath = Objects.requireNonNull(paperFile.getParentFile()).getAbsolutePath() + "/" + videoIndex + ".webp";
intent.putExtra(Constant.INTENT_PICTURES_PATH, finalVideoPath);
intent.putExtra(Constant.INTENT_BOOLEAN,booleanExtra);
setResult(0x111, intent);
PicturesActivity.this.finish();
exit();
break;
case R.id.image_view:
picturesBuilder.append(TimestampUtil.time()).append(",").append("onClick 点击了切换的窗口 ,");
@ -869,7 +872,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
@SuppressLint("SetTextI18n")
public void initMarkerPaper(int index) {
int endVideoIndex = index == -1 ? 0 : (index + 1);
int endVideoIndex = index == -1 ? 0 : index;
if (startVideoIndex == endVideoIndex) {
return;
}
@ -878,8 +881,8 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
StringBuilder sb = new StringBuilder();
sb.append(formatter.format(new Date())); // 记录当前时
sb.append(",");
sb.append(index == -1 ? 0 : (index + 1));//個數
startVideoIndex = index == -1 ? 0 : (index + 1);
sb.append(index == -1 ? 0 : index);//個數
startVideoIndex = index == -1 ? 0 : index;
sb.append(",");
sb.append(Constant.currentLocation.getLatitude());
sb.append(",");
@ -1018,9 +1021,6 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
@Override
public void onBackPressed() {
if (isOration) {
stopTimer();
}
String tvIndex = tvTitle.getText().toString();
String message = null;
if (tvIndex.equals("")) {
@ -1032,17 +1032,55 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
MessageDialog.show(this, "提示", message, "", "").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
picturesBuilder.append(TimestampUtil.time()).append(",").append("onClick 点击了结束采集 ,");
Intent intent = new Intent();
finalVideoPath = Objects.requireNonNull(paperFile.getParentFile()).getAbsolutePath() + "/" + videoIndex + ".webp";
intent.putExtra(Constant.INTENT_PICTURES_PATH, finalVideoPath);
setResult(0x111, intent);
PicturesActivity.this.finish();
baseDialog.doDismiss();
exit();
return false;
}
});
}
private void exit() {
Observable.create(new ObservableOnSubscribe<String>() {
@Override
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
stopTimer();
handler.removeMessages(0x101); // 如果handler中存在缓存的拍摄请求也清空
picturesBuilder.append(TimestampUtil.time()).append(",").append("onClick 点击了结束采集 ,");
emitter.onComplete();
}
})
.subscribeOn(Schedulers.io())
.delay(2, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
showLoadingDialog("正在保存照片...");
}
@Override
public void onNext(String s) {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
dismissLoadingDialog();
Intent intent = new Intent();
finalVideoPath = Objects.requireNonNull(paperFile.getParentFile()).getAbsolutePath() + "/" + videoIndex + ".webp";
intent.putExtra(Constant.INTENT_PICTURES_PATH, finalVideoPath);
setResult(0x111, intent);
PicturesActivity.this.finish();
handler = null;
}
});
}
/**
* 腾讯轨迹点
*/
@ -1076,12 +1114,14 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
timerTask = new TimerTask() {
@Override
public void run() {
if (radioPicture == 1) {
camera.takePictureSnapshot();
} else {
Message message = new Message();
message.what = 0x101;
handler.sendMessage(message);
if (handler!=null) {
if (radioPicture == 1) {
camera.takePictureSnapshot();
} else {
Message message = new Message();
message.what = 0x101;
handler.sendMessage(message);
}
}
}
};