修改录像功能

This commit is contained in:
wangdongsheng 2021-08-23 17:06:59 +08:00
parent a5f91bf1b0
commit 7a68019c7f
6 changed files with 149 additions and 236 deletions

View File

@ -212,7 +212,8 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
* app:cameraVideoSizeMaxWidth="2000" * app:cameraVideoSizeMaxWidth="2000"
* app:cameraVideoSizeMaxArea="2000000" * app:cameraVideoSizeMaxArea="2000000"
*/ */
camera.setVideoBitRate(2000000);
camera.setVideoBitRate(2100000);
//获取地图 //获取地图
tencentMap = ivMap.getMap(); tencentMap = ivMap.getMap();

View File

@ -93,78 +93,64 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
private MyLocationStyle locationStyle; private MyLocationStyle locationStyle;
private TextureMapView ivMap; private TextureMapView ivMap;
private Button stopPicture; private Button stopPicture;
private CsvTimerTask timerTask;
private List<Removable> removables; private List<Removable> removables;
private PoiEntity poiEntity; private PoiEntity poiEntity;
private Polyline polyline; private Polyline polyline;
private String finalVideoPath; // 摄像后最终保存的文件名 private String finalVideoPath; // 摄像后最终保存的文件名
// private File tmpFile; // 合并文件的临时文件路径
private Timer timer;
// private CsvTimerTask timerTask; // 执行定时写入csv文件的task
// private DateFormat formatter;
private final long period = 2; // 记录csv文件的间隔时间单位为秒
private ViewGroup layerChange; // 切换地图和相机的父控件 private ViewGroup layerChange; // 切换地图和相机的父控件
// private boolean isFinishActivity = false; // 是否需要关闭当前activity
private CheckBox capturePicture;//拍照 private CheckBox capturePicture;//拍照
private ArrayList<File> pictureList; private ArrayList<File> pictureList;
private Handler handler = new Handler(new Handler.Callback() { private Handler handler = new Handler(new Handler.Callback() {
@Override @Override
public boolean handleMessage(@NonNull Message msg) { public boolean handleMessage(@NonNull Message msg) {
if (msg.what == 0 && listenerPicture) { if (msg.what == 0x101 && listenerPicture) {
File file = (File) msg.obj; File file = (File) msg.obj;
pictureList.add(file); pictureList.add(file);
if (camera.isTakingPicture()) { camera.takePicture();
camera.destroy(); } else if (msg.what == 0x102) {
} else {
if (timerTask != null) {
timerTask.cancel();
}
camera.takePicture();
}
} else if (msg.what == 1) {
if (btnSwitch != null) { if (btnSwitch != null) {
btnSwitch.setEnabled(true); btnSwitch.setEnabled(true);
} }
} else if (msg.what == 0x103) {
File file = (File) msg.obj;
pictureList.add(file);
listenerPicture = false;
capturePicture.setText("开始采集");
capturePicture.setChecked(false);
} }
return false; return false;
} }
}); });
private boolean listenerPicture = true; private boolean listenerPicture = false;
private SimpleDateFormat formatter;
private File paperFile;
private int type;
private int videoIndex;
@Override @Override
protected int getLayout() { protected int getLayout() {
/* EventBus.getDefault().register(this); EventBus.getDefault().register(this);
tmpFile = new File(Constant.PICTURE_FOLDER, "temp.mp4");
formatter = new SimpleDateFormat("yyyyMMdd HHmmss");*/
return R.layout.activity_pictures; return R.layout.activity_pictures;
} }
@Override @Override
protected void initView() { protected void initView() {
super.initView(); super.initView();
/* if (getIntent()!=null) {
}*/
pictureList = new ArrayList<>(); pictureList = new ArrayList<>();
removables = new ArrayList<>();//存储轨迹的marker removables = new ArrayList<>();//存储轨迹的marker
layerChange = findViewById(R.id.layer_change); layerChange = findViewById(R.id.layer_change);
if (getIntent() != null) { if (getIntent() != null) {
poiEntity = (PoiEntity) getIntent().getSerializableExtra("poiEntity"); poiEntity = (PoiEntity) getIntent().getSerializableExtra("poiEntity");
finalVideoPath = getIntent().getStringExtra(Constant.INTENT_VIDEO_PATH); type = getIntent().getIntExtra("type", 0);
finalVideoPath = getIntent().getStringExtra(Constant.INTENT_JPG_PATH);
File file = new File(finalVideoPath);
paperFile = new File(file.getParentFile().getAbsoluteFile() + "/" + "paper.txt");
} }
formatter = new SimpleDateFormat("yyyyMMdd HHmmss");
timer = new Timer();
// this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
ivMap = (TextureMapView) findViewById(R.id.iv_map); ivMap = (TextureMapView) findViewById(R.id.iv_map);
btnSwitch = (Button) findViewById(R.id.btn_switch); btnSwitch = (Button) findViewById(R.id.btn_switch);
btnSwitch.setOnClickListener(this::onClick); btnSwitch.setOnClickListener(this::onClick);
// capturePicture = (ImageButton) findViewById(R.id.capturePicture);
// capturePicture.setOnClickListener(this::onClick);
//相机记录器 //相机记录器
CameraLogger.setLogLevel(CameraLogger.LEVEL_VERBOSE); CameraLogger.setLogLevel(CameraLogger.LEVEL_VERBOSE);
camera = findViewById(R.id.camera); camera = findViewById(R.id.camera);
@ -180,6 +166,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
} else { } else {
listenerPicture = false; listenerPicture = false;
capturePicture.setText("开始采集"); capturePicture.setText("开始采集");
} }
} }
}); });
@ -192,47 +179,51 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
UiSettings uiSettings = tencentMap.getUiSettings(); UiSettings uiSettings = tencentMap.getUiSettings();
//设置logo的大小 //设置logo的大小
uiSettings.setLogoScale(0.7f); uiSettings.setLogoScale(0.7f);
// uiSettings.setAllGesturesEnabled(false);
setLocMarkerStyle(); // 设置当前位置显示样式 setLocMarkerStyle(); // 设置当前位置显示样式
initLine(); initLine();
// camera.addFrameProcessor(new FrameProcessor() {
// @Override
// public void process(@NonNull Frame frame) {
// Log.e("PictureActivity", frame.getTime()+"");
// }
// });
//相机预览监听 //相机预览监听
camera.addCameraListener(new CameraListener() { camera.addCameraListener(new CameraListener() {
@Override @Override
public void onPictureTaken(@NonNull @NotNull PictureResult result) { public void onPictureTaken(@NonNull @NotNull PictureResult result) {
super.onPictureTaken(result); if (listenerPicture) {
//文件 super.onPictureTaken(result);
File file = new File(finalVideoPath); //文件
result.toFile(file, new FileCallback() { File file = new File(finalVideoPath);
@Override result.toFile(file, new FileCallback() {
public void onFileReady(@Nullable @org.jetbrains.annotations.Nullable File file) { @Override
Message message = new Message(); public void onFileReady(@Nullable @org.jetbrains.annotations.Nullable File file) {
message.what = 0; if (listenerPicture) {
message.obj = file; if (file.exists()) {
handler.sendMessageDelayed(message, 2000); videoIndex = Integer.parseInt(file.getName().replace(".jpg", ""));
File finalVideoFile = new File(finalVideoPath); finalVideoPath = file.getParentFile().getAbsolutePath() + "/" + (videoIndex + 1) + ".jpg";
if (finalVideoFile.exists()&&listenerPicture) { }
timerTask = new CsvTimerTask(new File(finalVideoPath + ".txt")); initMarkerPaper();
timer.schedule(timerTask, 0, period * 1000); Message message = new Message();
int videoIndex = Integer.parseInt(finalVideoFile.getName().replace(".jpg", "")); if (type == 3) {
finalVideoPath = finalVideoFile.getParentFile().getAbsolutePath() + "/" + (videoIndex + 1) + ".jpg"; message.what = 0x103;
message.obj = file;
handler.sendMessageDelayed(message, 0);
Toast.makeText(PicturesActivity.this, "保存成功:" + file.getPath(), Toast.LENGTH_SHORT).show();
} else {
message.what = 0x101;
message.obj = file;
Toast.makeText(PicturesActivity.this, "保存成功" + file.getPath(), Toast.LENGTH_SHORT).show();
handler.sendMessageDelayed(message, 2000);
}
}
} }
Toast.makeText(PicturesActivity.this, "保存成功:" + file.getPath(), Toast.LENGTH_SHORT).show();
});
if (camera.isTakingVideo()) {
message("Captured while taking video. Size=" + result.getSize(), false);
} }
}); long callbackTime = System.currentTimeMillis();
if (camera.isTakingVideo()) { captureTime = callbackTime - 300;
message("Captured while taking video. Size=" + result.getSize(), false); Log.d("captureTime", captureTime + "");
} }
long callbackTime = System.currentTimeMillis();
captureTime = callbackTime - 300;
Log.d("captureTime", captureTime + "");
} }
//录像监听 //录像监听
@ -240,46 +231,6 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
public void onVideoTaken(@NonNull @NotNull VideoResult result) { public void onVideoTaken(@NonNull @NotNull VideoResult result) {
super.onVideoTaken(result); super.onVideoTaken(result);
Toast.makeText(PicturesActivity.this, "暂停摄像", Toast.LENGTH_SHORT).show(); Toast.makeText(PicturesActivity.this, "暂停摄像", Toast.LENGTH_SHORT).show();
//showLoadingDialog();
/* new Thread(new Runnable() {
@Override
public void run() {
if (result!=null) {
File currentFile = result.getFile();
if (finalVideoPath!=null) { // 有指定的视频文件名称合并文件
if (new File(finalVideoPath).exists()) {
List<String> spliteFileList = new ArrayList<>();
spliteFileList.add(finalVideoPath);
spliteFileList.add(currentFile.getAbsolutePath());
try {
AWMp4ParserHelper.getInstance().mergeVideos(spliteFileList, tmpFile.getAbsolutePath());
if (tmpFile.exists()) {
File finalVideoFile = new File(finalVideoPath);
finalVideoFile.delete();
currentFile.delete();
tmpFile.renameTo(finalVideoFile);
} else {
Toast.makeText(PicturesActivity.this, "视频合并失败!", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
Log.e("PictureActivity", e.getMessage());
}
} else {
currentFile.renameTo(new File(finalVideoPath));
}
}
}
runOnUiThread(new Runnable() {
@Override
public void run() {
dismissLoadingDialog();
if (isFinishActivity) {
PicturesActivity.this.finish();
}
}
});
}
}).start();*/
} }
@Override @Override
@ -291,29 +242,6 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
@Override @Override
public void onVideoRecordingStart() { public void onVideoRecordingStart() {
super.onVideoRecordingStart(); super.onVideoRecordingStart();
/* *//**
* 获取当前视频的时间记录csv文件时使用
* *//*
long currentTime = AWMp4ParserHelper.getInstance().getVedioTotalTime(new File(finalVideoPath));
timerTask = new CsvTimerTask(new File(finalVideoPath + ".txt"));
// 开始采集每隔2秒实时记录位置信息视频时间以及设备时间
if (currentTime == 0) {
timer.schedule(timerTask, 0, period * 1000);
} else {
timerTask.setCurrentVideoTime(currentTime / 1000 + 1);
timer.schedule(timerTask, 1, period * 1000);
}
}
@Override
public void onVideoRecordingEnd() {
super.onVideoRecordingEnd();
/* if (timerTask!=null){
timerTask.cancel();
}else {
// Toast.makeText(PictureActivity.this, "请先拍照", Toast.LENGTH_SHORT).show();
}*/
} }
}); });
@ -378,18 +306,17 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.btn_stop_picture: case R.id.btn_stop_picture:
if (timerTask != null) { listenerPicture = false;
timerTask.cancel();
}
Intent intent = new Intent(); Intent intent = new Intent();
intent.putExtra(Constant.INTENT_PICTURES_PATH, pictureList); finalVideoPath = paperFile.getParentFile().getAbsolutePath() + "/" +videoIndex+ ".jpg";
intent.putExtra(Constant.INTENT_PICTURES_PATH, finalVideoPath);
setResult(0x102, intent); setResult(0x102, intent);
finish(); finish();
break; break;
case R.id.btn_switch: case R.id.btn_switch:
v.setEnabled(false); v.setEnabled(false);
handler.sendEmptyMessageDelayed(1, 2000); // 利用handler延迟发送更改状态信息 handler.sendEmptyMessageDelayed(0x102, 2000); // 利用handler延迟发送更改状态信息
btnSwich(); btnSwich();
break; break;
} }
@ -488,14 +415,11 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
if (polyline != null) { if (polyline != null) {
polyline.remove(); polyline.remove();
} }
if (timerTask != null) { listenerPicture = false;
timerTask.cancel();
}
for (int i = 0; i < removables.size(); i++) { for (int i = 0; i < removables.size(); i++) {
removables.get(i).remove(); removables.get(i).remove();
} }
removables.clear(); removables.clear();
// timer.cancel();
if (EventBus.getDefault().isRegistered(this)) { if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this); EventBus.getDefault().unregister(this);
} }
@ -519,43 +443,29 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
} }
} }
/** public void initMarkerPaper() {
* 记录视频拍摄的时间及经纬度 // 记录当前时间视频时间以及当前经纬度信息
*/ StringBuffer sb = new StringBuffer();
private class CsvTimerTask extends TimerTask { sb.append(formatter.format(new Date())); // 记录当前时
private File csvFile; sb.append(",");
private long currentVideoTime; // 记录当前的视频时间 sb.append(videoIndex);//個數
sb.append(",");
public CsvTimerTask(File csvFile) { sb.append(Constant.currentLocation.getLatitude());
this.csvFile = csvFile; sb.append(",");
if (!csvFile.exists()) { sb.append(Constant.currentLocation.getLongitude());
csvFile.getParentFile().mkdirs(); sb.append(",");
} if (Constant.currentLocation.getBearing() != 0) {
} sb.append(Constant.currentLocation.getBearing());
} else {
public void setCurrentVideoTime(long currentVideoTime) { sb.append(Constant.currentLocation.getDirection());
this.currentVideoTime = currentVideoTime;
}
@Override
public void run() {
// 记录当前时间视频时间以及当前经纬度信息
StringBuffer sb = new StringBuffer();
// sb.append(formatter.format(new Date())); // 记录当前时间
sb.append(",");
sb.append(currentVideoTime);// 记录视频时间
sb.append(",");
sb.append(Constant.currentLocation.getLatitude());
sb.append(",");
sb.append(Constant.currentLocation.getLongitude());
sb.append("\r\n");
LatLng latLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude());
BitmapDescriptor pileDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.circle);
Marker marker = tencentMap.addMarker(new MarkerOptions(latLng).icon(pileDescriptor).alpha(0.9f)
.flat(true)
.clockwise(false));
removables.add(marker);
FileUtils.writeFile(csvFile.getAbsolutePath(), sb.toString(), true);
} }
sb.append("\r\n");
LatLng latLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude());
BitmapDescriptor pileDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.circle);
Marker marker = tencentMap.addMarker(new MarkerOptions(latLng).icon(pileDescriptor).alpha(0.9f)
.flat(true)
.clockwise(false));
removables.add(marker);
FileUtils.writeFile(paperFile.getAbsolutePath(), sb.toString(), true);
} }
} }

View File

@ -165,6 +165,7 @@ public class Constant {
public static MapView treasureMap; public static MapView treasureMap;
public static final String INTENT_VIDEO_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置 public static final String INTENT_VIDEO_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置
public static final String INTENT_JPG_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的图片保存位置
public static final String INTENT_PICTURES_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置 public static final String INTENT_PICTURES_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置
public static final String INTENT_VIDEO_ORATATION = "INTENT_VIDEO_ORATATION"; // 视频拍摄时屏幕方向 0-强制横屏 其他-任意 public static final String INTENT_VIDEO_ORATATION = "INTENT_VIDEO_ORATATION"; // 视频拍摄时屏幕方向 0-强制横屏 其他-任意

View File

@ -29,7 +29,6 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.core.widget.NestedScrollView; import androidx.core.widget.NestedScrollView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.github.lazylibrary.util.FileUtils;
import com.github.lazylibrary.util.StringUtils; import com.github.lazylibrary.util.StringUtils;
import com.github.lazylibrary.util.ZipUtil; import com.github.lazylibrary.util.ZipUtil;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -40,23 +39,17 @@ import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialog.util.BaseDialog; import com.kongzue.dialog.util.BaseDialog;
import com.kongzue.dialog.util.DialogSettings; import com.kongzue.dialog.util.DialogSettings;
import com.kongzue.dialog.v3.MessageDialog; import com.kongzue.dialog.v3.MessageDialog;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams; import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.model.Response;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.FragmentManagement; import com.navinfo.outdoor.activity.FragmentManagement;
import com.navinfo.outdoor.activity.PictureActivity; import com.navinfo.outdoor.activity.PictureActivity;
import com.navinfo.outdoor.activity.PicturesActivity; import com.navinfo.outdoor.activity.PicturesActivity;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseDrawerFragment; import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.bean.Info;
import com.navinfo.outdoor.bean.OtherUploadPicBean; import com.navinfo.outdoor.bean.OtherUploadPicBean;
import com.navinfo.outdoor.bean.PoiSaveBean;
import com.navinfo.outdoor.bean.PoiVideoBean; import com.navinfo.outdoor.bean.PoiVideoBean;
import com.navinfo.outdoor.bean.RoadExtend;
import com.navinfo.outdoor.bean.UnPolygonTaskBean; import com.navinfo.outdoor.bean.UnPolygonTaskBean;
import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.DialogCallback;
import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder; import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.room.ChargingPileEntity; import com.navinfo.outdoor.room.ChargingPileEntity;
@ -71,17 +64,13 @@ import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng; import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import com.tencent.tencentmap.mapsdk.maps.model.Marker; import com.tencent.tencentmap.mapsdk.maps.model.Marker;
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import java.io.File; import java.io.File;
import java.io.Serializable;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -92,12 +81,10 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
private TextView tvPictures; private TextView tvPictures;
private EditText etRoadName; private EditText etRoadName;
private ImageView ivPoiVideoPicture; private ImageView ivPoiVideoPicture;
private RadioButton rbCar; private RadioGroup rgType;
private RadioButton rbBicycle; private RadioButton rbCar, rbBicycle, rbWalking, rbManual;
private RadioButton rbWalking;
private EditText etDesc; private EditText etDesc;
private Button btnRoadSave; private Button btnRoadSave;
private RadioGroup rgType;
private PoiDatabase poiDatabase; private PoiDatabase poiDatabase;
private PoiDao poiDao; private PoiDao poiDao;
private Button btnPoiVideoUpload; private Button btnPoiVideoUpload;
@ -107,7 +94,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
private LatLng latLng; private LatLng latLng;
private Marker markerPoiVideo; private Marker markerPoiVideo;
private TextView tvPicture; private TextView tvPicture;
private int isRequest; private int isRequest;
public static PoiVideoFragment newInstance(Bundle bundle) { public static PoiVideoFragment newInstance(Bundle bundle) {
PoiVideoFragment fragment = new PoiVideoFragment(); PoiVideoFragment fragment = new PoiVideoFragment();
@ -178,9 +165,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} }
etRoadName = (EditText) findViewById(R.id.et_poi_video_name); etRoadName = (EditText) findViewById(R.id.et_poi_video_name);
ivPoiVideoPicture = (ImageView) findViewById(R.id.iv_poi_video_picture); ivPoiVideoPicture = (ImageView) findViewById(R.id.iv_poi_video_picture);
rbCar = (RadioButton) findViewById(R.id.rb_car);
rbBicycle = (RadioButton) findViewById(R.id.rb_bicycle);
rbWalking = (RadioButton) findViewById(R.id.rb_walking);
etDesc = (EditText) findViewById(R.id.et_desc); etDesc = (EditText) findViewById(R.id.et_desc);
fmPoiVideoPic = findViewById(R.id.fm_poi_video_picture); fmPoiVideoPic = findViewById(R.id.fm_poi_video_picture);
btnRoadSave = (Button) findViewById(R.id.btn_poi_video_save); btnRoadSave = (Button) findViewById(R.id.btn_poi_video_save);
@ -188,22 +173,26 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload); btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
btnPoiVideoUpload.setOnClickListener(this::onClick); btnPoiVideoUpload.setOnClickListener(this::onClick);
rgType = (RadioGroup) findViewById(R.id.rg_type); rgType = (RadioGroup) findViewById(R.id.rg_type);
/* fmPoiVideoPic.setOnClickListener(new View.OnClickListener() { rbCar =findViewById(R.id.rb_car);
rbBicycle =findViewById(R.id.rb_bicycle);
rbWalking =findViewById(R.id.rb_walking);
rbManual = findViewById(R.id.rb_manual);
rgType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override @Override
public void onClick(View v) { public void onCheckedChanged(RadioGroup group, int checkedId) {
if (v.getTag() == null || ((List<File>) v.getTag()).size() == 0) {
Toast.makeText(getActivity(), "还没有拍摄视频!", Toast.LENGTH_SHORT).show();
return;
}
File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath()); switch (checkedId) {
Intent intent = new Intent(getContext(), PictureActivity.class); case R.id.rb_car:
// intent.putExtra("uuId", showPoiEntity.getId()); case R.id.rb_bicycle:
intent.putExtra("poiEntity", showPoiEntity); case R.id.rb_walking:
intent.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath()); tvPicture.setVisibility(View.VISIBLE);
startActivityForResult(intent, 0x101); break;
case R.id.rb_manual:
tvPicture.setVisibility(View.GONE);
break;
}
} }
});*/ });
fmPoiVideoPic.setOnLongClickListener(new View.OnLongClickListener() { fmPoiVideoPic.setOnLongClickListener(new View.OnLongClickListener() {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
@ -247,6 +236,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} }
int work_type = showPoiEntity.getWork_type(); int work_type = showPoiEntity.getWork_type();
showPictureType(work_type); showPictureType(work_type);
if (work_type==3){
tvPicture.setVisibility(View.GONE);
}
String describe = showPoiEntity.getMemo();//任务描述 String describe = showPoiEntity.getMemo();//任务描述
if (describe != null && !describe.equals("")) { if (describe != null && !describe.equals("")) {
etDesc.setText(describe + ""); etDesc.setText(describe + "");
@ -266,8 +258,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
isImageLoad = true; isImageLoad = true;
} }
} }
fmPoiVideoPic.setTag(videoFileListByUUID); fmPoiVideoPic.setTag(videoFileListByUUID);
} }
} }
} else if (record_way == 2) {//连拍 } else if (record_way == 2) {//连拍
@ -276,7 +268,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
boolean isImageLoad = false; boolean isImageLoad = false;
List<File> pictureFileListByUUID = AWMp4ParserHelper.getInstance().getJPGFileListByUUID(showPoiEntity.getId()); List<File> pictureFileListByUUID = AWMp4ParserHelper.getInstance().getJPGFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < pictureFileListByUUID.size(); i++) { for (int i = 0; i < pictureFileListByUUID.size(); i++) {
if (pictureFileListByUUID.get(i).getPath().contains("0.jpg") && !pictureFileListByUUID.get(i).getPath().contains("0.jpg.txt")) { if (pictureFileListByUUID.get(i).getPath().contains("0.jpg") && !pictureFileListByUUID.get(i).getPath().contains("paper.txt")) {
if (pictureFileListByUUID.get(i).exists() && !isImageLoad) { if (pictureFileListByUUID.get(i).exists() && !isImageLoad) {
// 使用glide加载视频的第一帧 // 使用glide加载视频的第一帧
Glide.with(getActivity()).load(pictureFileListByUUID.get(i)).into(ivPoiVideoPicture); Glide.with(getActivity()).load(pictureFileListByUUID.get(i)).into(ivPoiVideoPicture);
@ -325,18 +317,15 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
initPoiSaveLocal(false); initPoiSaveLocal(false);
break; break;
case R.id.tv_pictures://拍照 case R.id.tv_pictures://拍照
tvPicture.setEnabled(false);
Intent intents = new Intent(getContext(), PicturesActivity.class); Intent intents = new Intent(getContext(), PicturesActivity.class);
File filePath = AWMp4ParserHelper.getInstance().obtainJPGFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath()); File filePath = AWMp4ParserHelper.getInstance().obtainJPGFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intents.putExtra(Constant.INTENT_VIDEO_PATH, filePath.getAbsolutePath()); intents.putExtra(Constant.INTENT_JPG_PATH, filePath.getAbsolutePath());
int pictureType = getPictureType();
intents.putExtra("type",pictureType);
intents.putExtra("poiEntity", showPoiEntity); intents.putExtra("poiEntity", showPoiEntity);
startActivityForResult(intents, 0x102); startActivityForResult(intents, 0x102);
break; break;
case R.id.tv_picture://录像 case R.id.tv_picture://录像
tvPictures.setEnabled(false);
// 根据用户点击的时间为视频名称赋值
// DateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
// String videoFormatName = formatter.format(new Date());
Intent intent = new Intent(getContext(), PictureActivity.class); Intent intent = new Intent(getContext(), PictureActivity.class);
File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath()); File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intent.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath()); intent.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath());
@ -552,6 +541,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0x101 && resultCode == 0x101) { if (requestCode == 0x101 && resultCode == 0x101) {
tvPictures.setEnabled(false);
isRequest = 0x101; isRequest = 0x101;
if (data != null && data.hasExtra(Constant.INTENT_VIDEO_PATH)) { if (data != null && data.hasExtra(Constant.INTENT_VIDEO_PATH)) {
String videoPath = data.getStringExtra(Constant.INTENT_VIDEO_PATH); String videoPath = data.getStringExtra(Constant.INTENT_VIDEO_PATH);
@ -563,11 +553,13 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} }
} }
} else if (requestCode == 0x102 && resultCode == 0x102) { } else if (requestCode == 0x102 && resultCode == 0x102) {
isRequest =0x102; tvPicture.setEnabled(false);
isRequest = 0x102;
if (data != null && data.hasExtra(Constant.INTENT_PICTURES_PATH)) { if (data != null && data.hasExtra(Constant.INTENT_PICTURES_PATH)) {
ArrayList<File> serializableExtra = (ArrayList<File>) data.getSerializableExtra(Constant.INTENT_PICTURES_PATH); String videoPath = data.getStringExtra(Constant.INTENT_PICTURES_PATH);
if (serializableExtra != null) { File pictureFile = new File(videoPath);
Glide.with(getActivity()).load(serializableExtra.get(0)).into(ivPoiVideoPicture); if (pictureFile.exists()) {
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(pictureFile).toString(), ivPoiVideoPicture, 500);
List<File> pictureFileListByUUID = AWMp4ParserHelper.getInstance().getJPGFileListByUUID(showPoiEntity.getId()); List<File> pictureFileListByUUID = AWMp4ParserHelper.getInstance().getJPGFileListByUUID(showPoiEntity.getId());
fmPoiVideoPic.setTag(pictureFileListByUUID); fmPoiVideoPic.setTag(pictureFileListByUUID);
} }
@ -611,6 +603,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
return 1; return 1;
} else if (rbWalking != null && rbWalking.isChecked()) { } else if (rbWalking != null && rbWalking.isChecked()) {
return 2; return 2;
} else if (rbManual !=null &&rbManual.isChecked()){
return 3;
} }
return -1; return -1;
} }
@ -626,6 +620,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
case 2: case 2:
rbWalking.setChecked(true); rbWalking.setChecked(true);
break; break;
case 3:
rbManual.setChecked(true);
break;
} }
} }
@ -748,7 +745,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
poiEntity.setCreateTime(format); poiEntity.setCreateTime(format);
poiEntity.setType(3); poiEntity.setType(3);
poiEntity.setTaskStatus(2); poiEntity.setTaskStatus(2);
if (isRequest==0x101){ if (isRequest == 0x101) {
if (fmPoiVideoPic.getTag() == null) { if (fmPoiVideoPic.getTag() == null) {
List<File> videoFileListByUUID = AWMp4ParserHelper.getInstance().getVideoFileListByUUID(showPoiEntity.getId()); List<File> videoFileListByUUID = AWMp4ParserHelper.getInstance().getVideoFileListByUUID(showPoiEntity.getId());
if (videoFileListByUUID != null) { if (videoFileListByUUID != null) {
@ -766,7 +763,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} }
poiEntity.setRecord_way(1);//录像 poiEntity.setRecord_way(1);//录像
} }
}else if (isRequest==0x102){ } else if (isRequest == 0x102) {
if (fmPoiVideoPic.getTag() == null) { if (fmPoiVideoPic.getTag() == null) {
List<File> pictureFileListByUUID = AWMp4ParserHelper.getInstance().getJPGFileListByUUID(showPoiEntity.getId()); List<File> pictureFileListByUUID = AWMp4ParserHelper.getInstance().getJPGFileListByUUID(showPoiEntity.getId());
if (pictureFileListByUUID != null) { if (pictureFileListByUUID != null) {

View File

@ -11,8 +11,8 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.otaliastudios.cameraview.CameraView <com.otaliastudios.cameraview.CameraView
android:id="@+id/camera" android:id="@+id/camera"
app:cameraVideoSizeMaxWidth="2000" app:cameraVideoSizeMaxWidth="2500"
app:cameraVideoSizeMaxArea="2000000" app:cameraVideoSizeMaxArea="2750000"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:keepScreenOn="true" android:keepScreenOn="true"

View File

@ -15,19 +15,21 @@
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
</include> </include>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/nested_scroll_view" android:id="@+id/nested_scroll_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
>
<TextView <TextView
android:id="@+id/tv_message" android:id="@+id/tv_message"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -38,7 +40,7 @@
android:textColor="@color/black" android:textColor="@color/black"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/> app:layout_constraintTop_toTopOf="parent" />
<LinearLayout <LinearLayout
android:id="@+id/ll_name" android:id="@+id/ll_name"
@ -122,13 +124,14 @@
android:layout_weight="1" android:layout_weight="1"
android:text="步行" android:text="步行"
android:textColor="@color/test_color_selector" /> android:textColor="@color/test_color_selector" />
<!-- <RadioButton-->
<!-- android:id="@+id/rb_manual"--> <RadioButton
<!-- android:layout_width="0dp"--> android:id="@+id/rb_manual"
<!-- android:layout_weight="1"--> android:layout_width="0dp"
<!-- android:textColor="@color/test_color_selector"--> android:layout_height="wrap_content"
<!-- android:layout_height="wrap_content"--> android:layout_weight="1"
<!-- android:text="手动"/>--> android:text="手动"
android:textColor="@color/test_color_selector" />
</RadioGroup> </RadioGroup>
</LinearLayout> </LinearLayout>
@ -160,6 +163,7 @@
android:text="录像" android:text="录像"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="15sp" /> android:textSize="15sp" />
<TextView <TextView
android:id="@+id/tv_pictures" android:id="@+id/tv_pictures"
style="@style/user_style" style="@style/user_style"