修改1、2、3级bug(部分)

This commit is contained in:
md 2021-08-03 16:54:33 +08:00
parent eccc2fdadb
commit 839c96e638
12 changed files with 601 additions and 374 deletions

View File

@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
// ndkVersion '23.0.7123448'
ndkVersion '23.0.7123448'
defaultConfig {
applicationId "com.navinfo.outdoor"

View File

@ -43,8 +43,6 @@
android:supportsRtl="true"
android:theme="@style/Theme.WhiteScreen">
<activity android:name=".activity.PicturesActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|navigation"
android:screenOrientation="portrait"
>
</activity>

View File

@ -96,7 +96,7 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
private TextureMapView ivMap;
private CheckBox captureVideo; // 拍摄视频
private Button btnVideo, stopVideo;
private ImageView ivPic;
private String finalVideoPath; // 摄像后最终保存的文件名
private File tmpFile; // 合并文件的临时文件路径
private Timer timer;
@ -131,7 +131,6 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
ivMap = (TextureMapView) findViewById(R.id.iv_map);
ivPic = findViewById(R.id.iv_pic);
btnVideo = findViewById(R.id.btn_video);
btnVideo.setOnClickListener(this::onClick);
btnSwitch = (Button) findViewById(R.id.btn_switch);
@ -443,7 +442,6 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
}
public void btnSwich() {
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
System.out.println("width-display :" + dm.widthPixels);
@ -457,7 +455,7 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
layerChange.removeAllViews();
if (widthMap > widthCamera) {
ivPic.setVisibility(View.VISIBLE);
layoutParamsCamera.width = dm.widthPixels;
layoutParamsCamera.height = dm.heightPixels;
layoutParamsMap.height = heightCamera;
@ -467,7 +465,7 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
layerChange.addView(camera);
layerChange.addView(ivMap);
} else {
ivPic.setVisibility(View.GONE);
layoutParamsMap.height = dm.heightPixels;
layoutParamsMap.width = dm.widthPixels;
layoutParamsCamera.height = heightMap;

View File

@ -5,116 +5,543 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.os.Message;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.FrameLayout;
import android.widget.Toast;
import com.github.lazylibrary.util.DensityUtil;
import com.github.lazylibrary.util.FileUtils;
import com.navinfo.outdoor.R;
import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseActivity;
import com.navinfo.outdoor.util.AWMp4ParserHelper;
import com.navinfo.outdoor.util.MyTecentLocationSource;
import com.otaliastudios.cameraview.CameraException;
import com.otaliastudios.cameraview.CameraListener;
import com.otaliastudios.cameraview.CameraLogger;
import com.otaliastudios.cameraview.CameraView;
import com.otaliastudios.cameraview.FileCallback;
import com.otaliastudios.cameraview.PictureResult;
import com.otaliastudios.cameraview.VideoResult;
import com.otaliastudios.cameraview.controls.Engine;
import com.otaliastudios.cameraview.controls.Mode;
import com.otaliastudios.cameraview.size.AspectRatio;
import com.otaliastudios.cameraview.size.SizeSelector;
import com.otaliastudios.cameraview.size.SizeSelectors;
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
import com.tencent.tencentmap.mapsdk.maps.MapView;
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
import com.tencent.tencentmap.mapsdk.maps.TextureMapView;
import com.tencent.tencentmap.mapsdk.maps.UiSettings;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import static com.navinfo.outdoor.R.drawable.location;
import static com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE;
public class PicturesActivity extends BaseActivity implements View.OnClickListener {
private static final CameraLogger LOG = CameraLogger.create("Picture");
private com.otaliastudios.cameraview.CameraView cameraView;
private android.widget.Button capuretVideo;
private android.widget.Button btnStopVideo;
// private MapView ivMap;
// private TencentMap tencentMap;
private CameraView camera;
private long captureTime = 0;
private android.widget.Button btnSwitch;
private TencentMap tencentMap;
private MyLocationStyle locationStyle;
private TextureMapView ivMap;
private CheckBox captureVideo; // 拍摄视频
private Button btnVideo, stopVideo;
private String finalVideoPath; // 摄像后最终保存的文件名
private File tmpFile; // 合并文件的临时文件路径
private Timer timer;
private CsvTimerTask timerTask; // 执行定时写入csv文件的task
private DateFormat formatter;
private final long period = 1; // 记录csv文件的间隔时间单位为秒
private ViewGroup layerChange; // 切换地图和相机的父控件
private boolean isFinishActivity = false; // 是否需要关闭当前activity
@Override
protected int getLayout() {
EventBus.getDefault().register(this);
tmpFile = new File(Constant.PICTURE_FOLDER, "temp.mp4");
formatter = new SimpleDateFormat("yyyyMMdd HHmmss");
return R.layout.activity_pictures;
}
//
@Override
protected void initView() {
super.initView();
cameraView = (CameraView) findViewById(R.id.cameraView);
capuretVideo = (Button) findViewById(R.id.capuretVideo);
capuretVideo.setOnClickListener(this::onClick);
btnStopVideo = (Button) findViewById(R.id.btn_stop_video);
btnStopVideo.setOnClickListener(this::onClick);
// ivMap = findViewById(R.id.iv_map);
cameraView.setLifecycleOwner(this);
cameraView.setEngine(Engine.CAMERA1);
cameraView.setMode(Mode.VIDEO);
cameraView.addCameraListener(new CameraListener() {
if (getIntent()!=null) {
finalVideoPath = getIntent().getStringExtra(Constant.INTENT_VIDEO_PATH);
}
if (finalVideoPath == null) {
finalVideoPath = Constant.PICTURE_FOLDER+"/final.mp4";
}
layerChange = findViewById(R.id.layer_change);
timer = new Timer();
// this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
ivMap = (TextureMapView) findViewById(R.id.iv_map);
btnVideo = findViewById(R.id.btn_video);
btnVideo.setOnClickListener(this::onClick);
btnSwitch = (Button) findViewById(R.id.btn_switch);
btnSwitch.setOnClickListener(this::onClick);
// capturePicture = (ImageButton) findViewById(R.id.capturePicture);
// capturePicture.setOnClickListener(this::onClick);
//相机记录器
CameraLogger.setLogLevel(CameraLogger.LEVEL_VERBOSE);
camera = findViewById(R.id.camera);
camera.setOnClickListener(this::onClick);
captureVideo = findViewById(R.id.capuretVideo);
captureVideo.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) { // 开始采集设置按钮文字内容为结束采集
captureVideo.setText("暂停采集");
// stopVideo.setEnabled(false);// 开始采集视频后禁用停止采集的按钮必须暂停采集后才可点击停止采集
startTakenVideo(); // 开始采集视频
} else {
stopTakenVideo();
captureVideo.setText("开始采集");
}
}
});
stopVideo = findViewById(R.id.btn_stop_video);
stopVideo.setOnClickListener(this::onClick);
//拍照权限
camera.setLifecycleOwner(this);
camera.setEngine(Engine.CAMERA1);
// camera.setVideoBitRate(5);
camera.setPreviewFrameRate(5); // 设置预览视频的帧率
// 设置视频可用的宽高size
SizeSelector width = SizeSelectors.maxWidth(1920);
SizeSelector height = SizeSelectors.maxHeight(1440);
SizeSelector dimensions = SizeSelectors.and(width, height); // Matches sizes bigger than 1000x2000.
// 获取屏幕信息
int[] density = DensityUtil.getDeviceInfo(this);
int x=1920, y=1440;
if (density!=null&&density.length>1) {
x = (density[0]>=density[1]?density[0]:density[1]);
y = (density[0]>=density[1]?density[1]:density[0]);
}
SizeSelector ratio = SizeSelectors.aspectRatio(AspectRatio.of(x, y), 0); // Matches 1:1 sizes.
SizeSelector result = SizeSelectors.or(
SizeSelectors.and(ratio, dimensions), // Try to match both constraints
ratio, // If none is found, at least try to match the aspect ratio
SizeSelectors.biggest() // If none is found, take the biggest
);
camera.setVideoSize(result);
camera.setVideoBitRate(1920*1440);
// camera.setAudioBitRate();
//获取地图
tencentMap = ivMap.getMap();
//获取地图UI 设置对象
UiSettings uiSettings = tencentMap.getUiSettings();
//设置logo的大小
uiSettings.setLogoScale(0.7f);
// uiSettings.setAllGesturesEnabled(false);
setLocMarkerStyle(); // 设置当前位置显示样式
// camera.addFrameProcessor(new FrameProcessor() {
// @Override
// public void process(@NonNull Frame frame) {
// Log.e("PictureActivity", frame.getTime()+"");
// }
// });
//相机预览监听
camera.addCameraListener(new CameraListener() {
@Override
public void onPictureTaken(@NonNull @NotNull PictureResult result) {
super.onPictureTaken(result);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
String format = formatter.format(calendar.getTime());
//文件
File file = new File(Constant.PICTURE_FOLDER, format + ".jpg");
result.toFile(file, new FileCallback() {
@Override
public void onFileReady(@Nullable @org.jetbrains.annotations.Nullable File file) {
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();
captureTime = callbackTime - 300;
Log.d("captureTime", captureTime + "");
}
//录像监听
@Override
public void onVideoTaken(@NonNull @NotNull VideoResult result) {
super.onVideoTaken(result);
Toast.makeText(PicturesActivity.this, "停止摄像", Toast.LENGTH_SHORT).show();
finish();
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();
}
}
});
// tencentMap = ivMap.getMap();
//获取地图UI 设置对象
// UiSettings uiSettings = tencentMap.getUiSettings();
// //设置logo的大小
// uiSettings.setLogoScale(0.7f);
}
}).start();
}
@Override
public void onCameraError(@NonNull @NotNull CameraException exception) {
super.onCameraError(exception);
Toast.makeText(PicturesActivity.this, exception.toString(), Toast.LENGTH_SHORT).show();
}
@Override
public void 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();
}
}
});
// 修改相机的宽高为屏幕宽高的1/3
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
FrameLayout.LayoutParams layoutParamsMap = (FrameLayout.LayoutParams) ivMap.getLayoutParams();//相机的宽高
layoutParamsMap.height = dm.widthPixels/3;
layoutParamsMap.width = dm.heightPixels/3;
ivMap.setLayoutParams(layoutParamsMap);
}
private void message(String content, Boolean important) {
if (important) {
LOG.w(content);
Toast.makeText(this, content, Toast.LENGTH_SHORT).show();
} else {
LOG.i(content);
Toast.makeText(this, content, Toast.LENGTH_SHORT).show();
}
}
@Override
protected void initData() {
super.initData();
camera.setMode(Mode.VIDEO);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.capuretVideo:
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
String format = formatter.format(calendar.getTime());
//文件
File file = new File(Constant.PICTURE_FOLDER, format + ".mp4");
cameraView.takeVideo(file, 15000);
// case R.id.capuretVideo:
// DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// Calendar calendar = Calendar.getInstance();
// calendar.setTimeInMillis(System.currentTimeMillis());
// String format = formatter.format(calendar.getTime());
// //文件
// File file = new File(Constant.PICTURE_FOLDER, format + ".mp4");
// cameraView.takeVideo(file, 15000);
// break;
case R.id.btn_stop_video:
if (timerTask!=null){
timerTask.cancel();
Intent intent = new Intent();
intent.putExtra(Constant.INTENT_VIDEO_PATH, finalVideoPath);
setResult(0x101, intent);
}else {
Toast.makeText(this, "本段视频没有计时!", Toast.LENGTH_SHORT).show();
}
if (camera.isTakingVideo()) {
isFinishActivity = true;
camera.stopVideo();
} else {
finish();
}
break;
case R.id.btn_switch:
btnSwich();
break;
}
}
/**
* 开始采集
*/
private void startTakenVideo() {
if (camera.isTakingVideo()) {
Toast.makeText(this, "已经在拍摄中...", Toast.LENGTH_SHORT).show();
return;
}
DateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
String formatVideoName = formatter.format(calendar.getTime());
//文件
File file = new File(Constant.PICTURE_FOLDER, formatVideoName + ".mp4");
if (file.exists()) {
try {
FileOutputStream fo = new FileOutputStream(file);
FileDescriptor fileDescriptor = fo.getFD();
camera.takeVideo(fileDescriptor);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else {
camera.takeVideo(file);
}
}
private void stopTakenVideo() {
if (camera.isTakingVideo()) {
camera.stopVideo();
}
}
private Bitmap getBitMap(int resourceId) {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId);
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int newWidth = 55;
int newHeight = 55;
float widthScale = ((float) newWidth) / width;
float heightScale = ((float) newHeight) / height;
Matrix matrix = new Matrix();
matrix.postScale(widthScale, heightScale);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
return bitmap;
}
/**
* 设置定位图标样式
*/
private void setLocMarkerStyle() {
tencentMap.setLocationSource(new MyTecentLocationSource(this));
tencentMap.setMyLocationEnabled(true);
locationStyle = new MyLocationStyle();
locationStyle = locationStyle.myLocationType(LOCATION_TYPE_LOCATION_ROTATE);
//创建图标
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(location));
locationStyle.icon(bitmapDescriptor);
//设置定位圆形区域的边框宽度;
locationStyle.fillColor(getResources().getColor(android.R.color.transparent));
locationStyle.strokeWidth(1);
tencentMap.setMyLocationStyle(locationStyle);
}
public void btnSwich() {
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
System.out.println("width-display :" + dm.widthPixels);
System.out.println("heigth-display :" + dm.heightPixels);
FrameLayout.LayoutParams layoutParamsMap = (FrameLayout.LayoutParams) ivMap.getLayoutParams();//地图的宽高
int heightMap = ivMap.getMeasuredHeight();
int widthMap = ivMap.getMeasuredWidth();
FrameLayout.LayoutParams layoutParamsCamera = (FrameLayout.LayoutParams) camera.getLayoutParams();//相机的宽高
int heightCamera = camera.getMeasuredHeight();
int widthCamera = camera.getMeasuredWidth();
layerChange.removeAllViews();
if (widthMap > widthCamera) {
layoutParamsCamera.width = dm.widthPixels;
layoutParamsCamera.height = dm.heightPixels;
layoutParamsMap.height = heightCamera;
layoutParamsMap.width = widthCamera;
camera.setLayoutParams(layoutParamsCamera);
ivMap.setLayoutParams(layoutParamsMap);
layerChange.addView(camera);
layerChange.addView(ivMap);
} else {
layoutParamsMap.height = dm.heightPixels;
layoutParamsMap.width = dm.widthPixels;
layoutParamsCamera.height = heightMap;
layoutParamsCamera.width = widthMap;
camera.setLayoutParams(layoutParamsCamera);
ivMap.setLayoutParams(layoutParamsMap);
layerChange.addView(ivMap);
layerChange.addView(camera);
}
}
@Override
protected void onResume() {
super.onResume();
cameraView.open();
// ivMap.onResume();
camera.open();
}
@Override
protected void onPause() {
super.onPause();
cameraView.close();
// ivMap.onPause();
camera.close();
}
@Override
protected void onDestroy() {
super.onDestroy();
cameraView.destroy();
// ivMap.onDestroy();
stopTakenVideo();
camera.destroy();
timer.cancel();
if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this);
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMessageMainThread(Message msg) {
switch (msg.what) {
case Constant.EVENT_WHAT_LOCATION_CHANGE: // 用户位置更新
if (tencentMap!=null) {
CameraUpdate cameraSigma =
CameraUpdateFactory.newCameraPosition(new CameraPosition(
new LatLng(Constant.currentLocation.getLatitude(),Constant.currentLocation.getLongitude()), //中心点坐标地图目标经纬度
16, //目标缩放级别
0, //目标倾斜角
0)); //目标旋转角 0~360° (正北方为0)
tencentMap.animateCamera(cameraSigma);
}
break;
}
}
/**
* 记录视频拍摄的时间及经纬度
*/
private class CsvTimerTask extends TimerTask {
private File csvFile;
private long currentVideoTime; // 记录当前的视频时间
public CsvTimerTask(File csvFile) {
this.csvFile = csvFile;
if (!csvFile.exists()) {
csvFile.getParentFile().mkdirs();
}
}
public void setCurrentVideoTime(long currentVideoTime) {
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");
FileUtils.writeFile(csvFile.getAbsolutePath(), sb.toString(), true);
currentVideoTime = currentVideoTime+period; //
}
}
}

View File

@ -553,13 +553,9 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
poiEntity = new Gson().fromJson(station, PoiEntity.class);
pid = poiEntity.getId();
taskId = poiEntity.getTaskId();
String x = poiEntity.getX();
String y = poiEntity.getY();
if (x != null && y != null) {
latLng = new LatLng();
latLng.setLatitude(Double.parseDouble(y));
latLng.setLongitude(Double.parseDouble(x));
}
latLng.setLatitude(Constant.currentLocation.getLatitude());
latLng.setLongitude(Constant.currentLocation.getLongitude());
}
// 添加信息
ChargingPileEntity chargingPileEntity = (ChargingPileEntity) getArguments().getSerializable("chargingPileEntity");

View File

@ -271,33 +271,39 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
// 根据用户点击的时间为视频名称赋值
DateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String videoFormatName = formatter.format(new Date());
Intent intent = new Intent(getContext(), PictureActivity.class);
Intent intent = new Intent(getContext(), PicturesActivity.class);
intent.putExtra(Constant.INTENT_VIDEO_PATH, Constant.PICTURE_FOLDER + "/" + videoFormatName + ".mp4");
startActivityForResult(intent, 0x101);
break;
case R.id.btn_poi_video_upload:
showLoadingDialog();
ArrayList<File> videoFileList = new ArrayList<>();
if (ivPoiVideoPicture.getTag() != null) {
showLoadingDialog();
File videoFile = (File) ivPoiVideoPicture.getTag();
videoFileList.add(videoFile);
File file = new File(videoFile.getPath()+".txt");
videoFileList.add(file);
fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
ZipUtil.zipFiles(videoFileList, fileZip, null);
new Thread(new Runnable() {
@Override
public void run() {
ZipUtil.zipFiles(videoFileList, fileZip, null);
PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId());
if (poiDaoPoiEntity == null || poiDaoPoiEntity.getTaskStatus() == 1 || poiDaoPoiEntity.getTaskStatus() == 2 || poiDaoPoiEntity.getTaskStatus() == 0) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
dismissLoadingDialog();
initPoiSaveLocal(true);
}
});
} else {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
dismissLoadingDialog();
poiVideoUpload(poiDaoPoiEntity.getBodyId(), fileZip);
}
});
@ -306,6 +312,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
}
}).start();
}else {
dismissLoadingDialog();
Toast.makeText(getContext(), "请录像", Toast.LENGTH_SHORT).show();
return;
}
@ -314,7 +321,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
}
public void initPoiSaveLocal(boolean isLocal) {
XXPermissions.with(getContext())
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
.request(new OnPermissionCallback() {
@ -441,6 +447,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
Toast.makeText(getActivity(), "未压缩完成", Toast.LENGTH_SHORT).show();
return;
}
showLoadingDialog();
OkGo
// 请求方式和请求url
.<OtherUploadPicBean>post(HttpInterface.POI_VIDEO_UPLOAD_PIC)

View File

@ -261,18 +261,20 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
startActivityForResult(intent, 0x101);
break;
case R.id.road_upload:
showLoadingDialog();
ArrayList<File> videoFileList = new ArrayList<>();
if (ivRoadPicture.getTag() != null) {
showLoadingDialog();
File videoFile = (File) ivRoadPicture.getTag();
videoFileList.add(videoFile);
File file = new File(videoFile.getPath() + ".txt");
videoFileList.add(file);
fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
ZipUtil.zipFiles(videoFileList, fileZip, null);
new Thread(new Runnable() {
@Override
public void run() {
ZipUtil.zipFiles(videoFileList, fileZip, null);
PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId());
if (poiDaoPoiEntity == null || poiDaoPoiEntity.getTaskStatus() == 1 || poiDaoPoiEntity.getTaskStatus() == 2 || poiDaoPoiEntity.getTaskStatus() == 0) {
dismissLoadingDialog();
@ -281,6 +283,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
dismissLoadingDialog();
poiVideoUpload(poiDaoPoiEntity.getBodyId(), fileZip);
}
});

View File

@ -1,195 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF444444">
<com.otaliastudios.cameraview.CameraView
android:id="@+id/camera"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:keepScreenOn="true"
app:cameraAudio="on"
app:cameraAutoFocusMarker="@string/cameraview_default_autofocus_marker"
app:cameraEngine="camera2"
app:cameraExperimental="true"
app:cameraFacing="back"
app:cameraFlash="auto"
app:cameraGestureLongTap="none"
app:cameraGesturePinch="zoom"
app:cameraGestureScrollHorizontal="filterControl1"
app:cameraGestureScrollVertical="exposureCorrection"
app:cameraGestureTap="autoFocus"
app:cameraGrid="off"
app:cameraMode="picture"
app:cameraPlaySounds="true"
app:cameraPreview="glSurface"
app:layout_constraintBottom_toTopOf="@id/ll_caiji"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:layout_editor_absoluteX="-76dp">
</com.otaliastudios.cameraview.CameraView>
<com.tencent.tencentmap.mapsdk.maps.MapView
android:id="@+id/iv_map"
android:layout_width="300dp"
android:layout_height="183dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btn_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:text="切换"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
app:layout_constraintTop_toBottomOf="@id/btn_switch"
app:layout_constraintRight_toRightOf="@id/btn_switch"
android:id="@+id/btn_video"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="停止" />
<ImageView
android:id="@+id/iv_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/take_pic_arrow"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- <LinearLayout-->
<!-- android:id="@+id/ll_iv"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="bottom"-->
<!-- android:orientation="horizontal"-->
<!-- android:padding="16dp"-->
<!-- android:weightSum="4"-->
<!-- app:layout_constraintBottom_toBottomOf="parent">-->
<!-- <Space-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="1dp"-->
<!-- android:layout_weight="1" />-->
<LinearLayout
android:id="@+id/ll_caiji"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:layout_marginBottom="20dp"
app:layout_constraintBottom_toBottomOf="parent">
<Button
android:id="@+id/capuretVideo"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="开始采集"
android:layout_marginRight="10dp"
style="@style/user_data_style"/>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="结束采集"
android:layout_marginLeft="10dp"
android:background="@drawable/uploding_shape"
android:textColor="@color/colorBlue"/>
<ImageButton
android:id="@+id/capturePicture"
android:layout_width="56dp"
android:layout_height="56dp"
android:visibility="gone"
android:background="?attr/selectableItemBackgroundBorderless"
app:srcCompat="@drawable/ic_photo" />
</LinearLayout>
<!-- <Space-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="1dp"-->
<!-- android:layout_weight="1" />-->
<!-- <Space-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="1dp"-->
<!-- android:layout_weight="1" />-->
<!-- <Space-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="1dp"-->
<!-- android:layout_weight="1" />-->
<!-- <Space-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="1dp"-->
<!-- android:layout_weight="1" />-->
<!-- <LinearLayout-->
<!-- android:id="@+id/capturePictureSnapshot"-->
<!-- android:layout_width="56dp"-->
<!-- android:layout_height="56dp"-->
<!-- android:background="?attr/selectableItemBackgroundBorderless"-->
<!-- android:gravity="center"-->
<!-- android:orientation="vertical"-->
<!-- android:visibility="gone">-->
<!-- <ImageView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:srcCompat="@drawable/ic_photo" />-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="SNAP"-->
<!-- android:textColor="@android:color/white"-->
<!-- android:textSize="10sp"-->
<!-- android:textStyle="bold" />-->
<!-- </LinearLayout>-->
<!-- <ImageButton-->
<!-- android:id="@+id/capuretVideo"-->
<!-- android:layout_width="56dp"-->
<!-- android:layout_height="56dp"-->
<!-- android:background="?attr/selectableItemBackgroundBorderless"-->
<!-- app:srcCompat="@drawable/ic_video" />-->
<!-- <LinearLayout-->
<!-- android:id="@+id/captureVideoSnapshot"-->
<!-- android:layout_width="56dp"-->
<!-- android:layout_height="56dp"-->
<!-- android:orientation="vertical"-->
<!-- android:background="?attr/selectableItemBackgroundBorderless"-->
<!-- android:gravity="center" >-->
<!-- <ImageView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:srcCompat="@drawable/ic_video"/>-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:textColor="@android:color/white"-->
<!-- android:textStyle="bold"-->
<!-- android:textSize="10sp"-->
<!-- android:text="SNAP"/>-->
<!-- </LinearLayout>-->
<!-- </LinearLayout>-->
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -40,15 +40,6 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btn_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="停止"
android:visibility="gone"
app:layout_constraintRight_toRightOf="@id/btn_switch"
app:layout_constraintTop_toBottomOf="@id/btn_switch" />
<ImageView
android:id="@+id/iv_pic"
android:layout_width="wrap_content"

View File

@ -6,21 +6,30 @@
android:layout_height="match_parent"
android:background="#FF444444"
tools:context=".activity.PicturesActivity">
<com.otaliastudios.cameraview.CameraView
android:id="@+id/cameraView"
<FrameLayout
android:id="@+id/layer_change"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
/>
android:layout_height="match_parent">
<com.otaliastudios.cameraview.CameraView
android:id="@+id/camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.tencent.tencentmap.mapsdk.maps.TextureMapView
android:id="@+id/iv_map"
android:layout_width="200dp"
android:layout_height="157dp"
app:layout_constraintHeight_default="percent"
app:layout_constraintHeight_percent="0.4"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_default="percent"
app:layout_constraintWidth_percent="0.4" />
</FrameLayout>
<!-- <com.tencent.tencentmap.mapsdk.maps.MapView-->
<!-- android:id="@+id/iv_map"-->
<!-- android:layout_width="300dp"-->
<!-- android:layout_height="183dp"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" />-->
<Button
android:id="@+id/btn_switch"
@ -32,23 +41,25 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_pic"
<Button
android:id="@+id/btn_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/take_pic_arrow"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:text="停止"
android:visibility="gone"
app:layout_constraintRight_toRightOf="@id/btn_switch"
app:layout_constraintTop_toBottomOf="@id/btn_switch" />
<Button
<CheckBox
android:id="@+id/capuretVideo"
style="@style/user_data_style"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/user_style"
android:button="@null"
android:gravity="center"
android:padding="@dimen/fab_margin"
android:text="开始采集"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"

View File

@ -150,7 +150,6 @@
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_marginTop="10dp"
app:layout_constraintLeft_toLeftOf="@id/ll_pictures"
app:layout_constraintTop_toBottomOf="@id/ll_pictures" />
<LinearLayout

View File

@ -34,14 +34,6 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btn_video2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="停止"
android:visibility="gone"
app:layout_constraintRight_toRightOf="@id/btn_switch2"
app:layout_constraintTop_toBottomOf="@id/btn_switch2" />
<CheckBox
android:id="@+id/capuretVideo2"