diff --git a/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java
index 678397e..a9774ab 100644
--- a/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java
+++ b/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java
@@ -122,7 +122,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
private SystemTTS systemTTS;
private StringBuilder picturesBuilder;
private LatLng startLatLine, endLatLine;
- private TextView tvTitle;
+ private TextView tvTitle, tvConvert/*照片已转换为webp的张数*/;
private GPSUtils gpsUtils;
private Location gpsLocation;
private boolean isMapSlide = false;
@@ -133,6 +133,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
private int type = 0;
private int radioPicture = 0;
private int videoIndex = -1;
+ private int convertIndex = 0;
private int startVideoIndex = -1;
@SuppressLint("SimpleDateFormat")
private SimpleDateFormat formatter;
@@ -140,6 +141,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
@Override
public boolean handleMessage(@NonNull Message msg) {
if (msg.what == 0x101) {
+ System.out.println("收到拍照按钮请求");
camera.takePicture();
} else if (msg.what == 0x102) {
if (imageView != null) {
@@ -151,6 +153,8 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
}
capturePicture.setChecked(false);
stopTimer();
+ } else if (msg.what == 0x104) {
+ tvConvert.setText("转换成功:"+(++msg.arg1));
}
return false;
}
@@ -182,6 +186,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
} else {
videoIndex = videoIndex - 1;
}
+ convertIndex = videoIndex;
}
}
formatter = new SimpleDateFormat("yyyyMMdd HHmmss");
@@ -204,22 +209,17 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
});
RadioGroup radioGroupPicture = findViewById(R.id.radio_group_picture);
RadioButton radioBtnHand = findViewById(R.id.radio_btn_hand);
+ RadioButton radioBtnHalfSec = findViewById(R.id.radio_btn_half_sec);
RadioButton radioBtnAuto = findViewById(R.id.radio_btn_auto);
RadioButton radioBtnAutoSec = findViewById(R.id.radio_btn_auto_sec);
if (type == 3) {//poiVideo 1秒
ivPicVideoImage.setVisibility(View.VISIBLE);
ivPicRoadImage.setVisibility(View.GONE);
radioPicture = 3;
- radioBtnAutoSec.setTextColor(Color.parseColor("#FFEB3B"));
- radioBtnHand.setTextColor(Color.WHITE);
- radioBtnAuto.setTextColor(Color.WHITE);
} else if (type == 4) {//道路2秒
ivPicRoadImage.setVisibility(View.VISIBLE);
ivPicVideoImage.setVisibility(View.GONE);
radioPicture = 3;
- radioBtnAutoSec.setTextColor(Color.parseColor("#FFEB3B"));
- radioBtnAuto.setTextColor(Color.WHITE);
- radioBtnHand.setTextColor(Color.WHITE);
}
radioGroupPicture.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
@@ -230,27 +230,24 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
isOration = false;
capturePicture.setText("拍摄");
capturePicture.setChecked(false);
- radioBtnHand.setTextColor(Color.parseColor("#FFEB3B"));
- radioBtnAuto.setTextColor(Color.WHITE);
- radioBtnAutoSec.setTextColor(Color.WHITE);
stopTimer();
break;
case R.id.radio_btn_auto://自动1秒:
radioPicture = 2;
capturePicture.setText("开始采集");
capturePicture.setChecked(false);
- radioBtnAuto.setTextColor(Color.parseColor("#FFEB3B"));
- radioBtnHand.setTextColor(Color.WHITE);
- radioBtnAutoSec.setTextColor(Color.WHITE);
stopTimer();
break;
case R.id.radio_btn_auto_sec://自动2 秒
radioPicture = 3;
capturePicture.setText("开始采集");
capturePicture.setChecked(false);
- radioBtnAutoSec.setTextColor(Color.parseColor("#FFEB3B"));
- radioBtnAuto.setTextColor(Color.WHITE);
- radioBtnHand.setTextColor(Color.WHITE);
+ stopTimer();
+ break;
+ case R.id.radio_btn_half_sec://自动0.5 秒
+ radioPicture = 4;
+ capturePicture.setText("开始采集");
+ capturePicture.setChecked(false);
stopTimer();
break;
}
@@ -267,6 +264,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
camera = findViewById(R.id.camera);
camera.setOnClickListener(this);
tvTitle = findViewById(R.id.tv_title);
+ tvConvert = findViewById(R.id.tv_convert);
imageView = findViewById(R.id.image_view);
imageView.setOnClickListener(this);
capturePicture = findViewById(R.id.capture_picture);
@@ -311,8 +309,9 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
camera.addCameraListener(new CameraListener() {
@Override
public void onPictureTaken(@NonNull PictureResult result) {
- if (result.getData() != null && result != null && result.getData().length > 0) {
+ if (result != null && result.getData() != null && result.getData().length > 0) {
super.onPictureTaken(result);
+ System.out.println("收到拍照按钮jieguo");
isBack = true;
// 如果当前手机是竖向,则不
if (isOration) {
@@ -331,13 +330,22 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
isOration = false;
}
}
+
File file = new File(finalVideoPath);
- result.toFile(file, new FileCallback() {
- @Override
- public void onFileReady(@Nullable File file) {
- UserApplication.fixedThreadPool.execute(new Jpg2WebpRunnable(/*result, */file, 0, booleanExtra));
- }
- });
+ 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) {
+ UserApplication.fixedThreadPool.execute(new Jpg2WebpRunnable(/*result, */file, 0, booleanExtra, currentIndex));
+ }
+ });
+ }
} else {
isBack = false;
if (isOration) {
@@ -373,41 +381,42 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
class Jpg2WebpRunnable implements Runnable {
//private PictureResult pictureResult;
private File file;
- private int count;
+ private int count;/*线程重复执行的次数*/
private boolean isBoolean;
+ private int index;
// 该转换执行次数,如果连续3次执行失败,则不再转换
- public Jpg2WebpRunnable(/*PictureResult pictureResult,*/ File file, int count, boolean isBoolean) {
+ public Jpg2WebpRunnable(/*PictureResult pictureResult,*/ File file, int count, boolean isBoolean, int index/*照片的索引*/) {
//this.pictureResult = pictureResult;
this.file = file;
this.count = count;
this.isBoolean = isBoolean;
+ this.index = index;
}
@Override
public void run() {
if (file.exists() && file != null) {
- initWeb(file, count, isBoolean);
- if (count <= 0) { // 不是重新转换webp流程
- runOnUiThread(new Runnable() {
- @SuppressLint("SetTextI18n")
- @Override
- public void run() {
- if (PicturesActivity.this != null) {
- if (file.exists()) {
- initMarker(isBoolean);
- videoIndex = Integer.parseInt(file.getName().replace(".webp", ""));
- finalVideoPath = Objects.requireNonNull(file.getParentFile()).getAbsolutePath() + "/" + (videoIndex + 1) + ".webp";
- tvTitle.setText("保存成功:" + (videoIndex + 1));
- }
- if (radioPicture == 1 && handler != null) {
- Message message = new Message();
- message.what = 0x103;
- handler.sendMessage(message);
- }
- }
+ if (initWeb(file, count, isBoolean, index)) {
+ if (PicturesActivity.this != null&&handler != null) {
+ if (radioPicture == 1) {
+ Message message = new Message();
+ message.what = 0x103;
+ handler.sendMessage(message);
+ } else {
+ Message message = new Message();
+ message.what = 0x104;
+ message.arg1 = index;
+ handler.sendMessage(message);
}
- });
+ }
+// runOnUiThread(new Runnable() {
+// @SuppressLint("SetTextI18n")
+// @Override
+// public void run() {
+//
+// }
+// });
}
} else {
isBack = false;
@@ -428,7 +437,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
}
}
- private void initWeb(File file, int count, boolean isBoolean) {
+ private boolean initWeb(File file, int count, boolean isBoolean, int index) {
try {
count++;
WebPNative webPNative = new WebPNative();
@@ -437,7 +446,8 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
if (!bitmap.isRecycled()) {
bitmap.recycle();
}
- initMarkerPaper();
+ initMarkerPaper(index);
+ return true;
} catch (RuntimeException e) {
e.printStackTrace();
//如果是写入txt记录失败,上传失败记录
@@ -447,9 +457,10 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
UMCrashManager.reportCrash(this, e);
if (count < 3) {
//当尝试次数小于3次,则加入转换队列,尝试重新转换
- UserApplication.fixedThreadPool.execute(new Jpg2WebpRunnable(/*result, */file, count, isBoolean));
+ UserApplication.fixedThreadPool.execute(new Jpg2WebpRunnable(/*result, */file, count, isBoolean, index));
}
}
+ return false;
}
private void initLine() {
@@ -782,8 +793,8 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
}
@SuppressLint("SetTextI18n")
- public void initMarkerPaper() {
- int endVideoIndex = videoIndex == -1 ? 0 : (videoIndex + 1);
+ public void initMarkerPaper(int index) {
+ int endVideoIndex = index == -1 ? 0 : (index + 1);
if (startVideoIndex == endVideoIndex) {
return;
}
@@ -792,8 +803,8 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
StringBuilder sb = new StringBuilder();
sb.append(formatter.format(new Date())); // 记录当前时
sb.append(",");
- sb.append(videoIndex == -1 ? 0 : (videoIndex + 1));//個數
- startVideoIndex = videoIndex == -1 ? 0 : (videoIndex + 1);
+ sb.append(index == -1 ? 0 : (index + 1));//個數
+ startVideoIndex = index == -1 ? 0 : (index + 1);
sb.append(",");
sb.append(Constant.currentLocation.getLatitude());
sb.append(",");
@@ -990,6 +1001,8 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
timer.schedule(timerTask, 0, 1000);
} else if (radioPicture == 3) {
timer.schedule(timerTask, 0, 2000);
+ } else if (radioPicture == 4) {
+ timer.schedule(timerTask, 0, 500);
}
}
diff --git a/app/src/main/res/color/rbtn_text_color_selector.xml b/app/src/main/res/color/rbtn_text_color_selector.xml
new file mode 100644
index 0000000..79a1a87
--- /dev/null
+++ b/app/src/main/res/color/rbtn_text_color_selector.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_pictures.xml b/app/src/main/res/layout/activity_pictures.xml
index ec9c896..9fe0cab 100644
--- a/app/src/main/res/layout/activity_pictures.xml
+++ b/app/src/main/res/layout/activity_pictures.xml
@@ -61,15 +61,32 @@
app:layout_constraintWidth_default="percent"
app:layout_constraintWidth_percent="0.4" />
-
+ app:layout_constraintTop_toTopOf="parent"
+ android:orientation="vertical">
+
+
+
+
+ android:textColor="@color/rbtn_text_color_selector" />
+
+
+ android:textColor="@color/rbtn_text_color_selector" />
+ android:textColor="@color/rbtn_text_color_selector" />