From 839c96e638251149ab0e36e1fc9a9637ddfd9c22 Mon Sep 17 00:00:00 2001 From: md Date: Tue, 3 Aug 2021 16:54:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B91=E3=80=812=E3=80=813?= =?UTF-8?q?=E7=BA=A7bug(=E9=83=A8=E5=88=86)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 2 - .../outdoor/activity/PictureActivity.java | 8 +- .../outdoor/activity/PicturesActivity.java | 505 ++++++++++++++++-- .../fragment/ChargingPileFragment.java | 164 +++--- .../outdoor/fragment/PoiVideoFragment.java | 19 +- .../outdoor/fragment/RoadFragment.java | 7 +- app/src/main/res/layout/activity_camera.xml | 195 ------- app/src/main/res/layout/activity_picture.xml | 9 - app/src/main/res/layout/activity_pictures.xml | 55 +- .../main/res/layout/poi_video_fragment.xml | 1 - app/src/main/res/layout/switch_map.xml | 8 - 12 files changed, 601 insertions(+), 374 deletions(-) delete mode 100644 app/src/main/res/layout/activity_camera.xml diff --git a/app/build.gradle b/app/build.gradle index a78f9ee..43917f5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8e005d2..2322cb3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -43,8 +43,6 @@ android:supportsRtl="true" android:theme="@style/Theme.WhiteScreen"> diff --git a/app/src/main/java/com/navinfo/outdoor/activity/PictureActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/PictureActivity.java index 0511726..887272e 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/PictureActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/PictureActivity.java @@ -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; 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 5bc2803..64d3e72 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java @@ -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 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 + 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(); + } } }); - // tencentMap = ivMap.getMap(); - //获取地图UI 设置对象 -// UiSettings uiSettings = tencentMap.getUiSettings(); -// //设置logo的大小 -// uiSettings.setLogoScale(0.7f); + // 修改相机的宽高为屏幕宽高的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; // + } } } \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java index ec9730a..348a586 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java @@ -78,7 +78,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC private CheckBox checkBoxLife, checkBoxRight; private Spinner spinnerType, spinnerScutcheon, spinnerStake; String[] type = new String[]{"地上五层", "地上四层", "地上三层", "地上二层", "地上一层", "地下一层", "地下二层", "地下三层", "地下四层", "地下五层"}; - String[] scutcheon = new String[]{"存在","不存在"}; + String[] scutcheon = new String[]{"存在", "不存在"}; String[] stake = new String[]{"可以使用", "不可使用", "维修中", "建设中", "规划中"}; private ArrayAdapter adapterType, adapterScutcheon, adapterStake; private RelativeLayout rlPanorama, rlCoding, rlEquipment, rlFacility, rlUsable, rlAvailable, rlParking, rlNumber, rlScutcheon, rlDevice; @@ -87,7 +87,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC private int cp_floor = 1; private int sign_exist = 0; private int cp_availableState = 0; - private String buffer1="",buffer2="",buffer3="",buffer4="",buffer5=""; + private String buffer1 = "", buffer2 = "", buffer3 = "", buffer4 = "", buffer5 = ""; private StringBuffer openType = new StringBuffer(); private CheckBox checkButton1, checkButton2, checkButton3, checkButton4, checkButton5; private String pid; @@ -171,14 +171,14 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC checkBoxLife.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if (isChecked){ + if (isChecked) { checkBoxLife.setText("保存"); checkBoxLife.setTextColor(Color.WHITE); Message obtain = Message.obtain(); obtain.what = Constant.MAIN_CHARGING_PILE; obtain.obj = latLng; EventBus.getDefault().post(obtain); - }else { + } else { checkBoxLife.setText("编辑"); checkBoxLife.setTextColor(Color.BLACK); Message obtain = Message.obtain(); @@ -195,11 +195,11 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { - buffer1="1,"; - buffer2=""; - buffer3=""; - buffer4=""; - buffer5=""; + buffer1 = "1,"; + buffer2 = ""; + buffer3 = ""; + buffer4 = ""; + buffer5 = ""; checkButton2.setChecked(false); checkButton3.setChecked(false); checkButton4.setChecked(false); @@ -212,10 +212,10 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { - buffer2="2,"; + buffer2 = "2,"; checkButton1.setChecked(false); - }else { - buffer2=""; + } else { + buffer2 = ""; } } }); @@ -224,10 +224,10 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { - buffer3="3,"; + buffer3 = "3,"; checkButton1.setChecked(false); - }else { - buffer3=""; + } else { + buffer3 = ""; } } }); @@ -236,10 +236,10 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { - buffer4="4,"; + buffer4 = "4,"; checkButton1.setChecked(false); - }else { - buffer4=""; + } else { + buffer4 = ""; } } }); @@ -248,10 +248,10 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { - buffer5="5,"; + buffer5 = "5,"; checkButton1.setChecked(false); - }else { - buffer5=""; + } else { + buffer5 = ""; } } }); @@ -398,9 +398,9 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC btnSaveLocal = findViewById(R.id.btn_save_local); btnSaveLocal.setOnClickListener(this::onClick); //展示数据 - initShowPileSharePre(); + initShowPileSharePre(); - onLongDelPic(); + onLongDelPic(); } @@ -549,17 +549,13 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC private void initShowPileSharePre() { station = getArguments().getString("station"); - if (station!=null){ + if (station != null) { 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 = new LatLng(); + latLng.setLatitude(Constant.currentLocation.getLatitude()); + latLng.setLongitude(Constant.currentLocation.getLongitude()); } // 添加信息: ChargingPileEntity chargingPileEntity = (ChargingPileEntity) getArguments().getSerializable("chargingPileEntity"); @@ -573,7 +569,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC latLng = GeometryTools.createLatLng(p); } String memo = chargingPileEntity.getMemo(); - if (memo != null&&!memo.equals("")) { + if (memo != null && !memo.equals("")) { editDescribe.setText(memo); } String fid = chargingPileEntity.getFid(); @@ -685,7 +681,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC spinnerScutcheon.setEnabled(false);//设备标牌下拉框 rlEquipment.setEnabled(false);//(蓝色色)设备标牌 rlFacility.setEnabled(false);//(白色)设备标牌 - spinnerStake.setEnabled(false);//桩可用状态 + spinnerStake.setEnabled(false);//桩可用状态 rlUsable.setEnabled(false);//(蓝色)可用状态 rlAvailable.setEnabled(false);//(白色)可用状态 rlParking.setEnabled(false);//(蓝色)停车位编号 @@ -720,12 +716,12 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC if (all) { //保存数据库: ChargingPileEntity chargingPileEntity = new ChargingPileEntity(); - ArrayList photoBean = new ArrayList<>(); + ArrayList photoBean = new ArrayList<>(); if (latLng == null || latLng.equals("")) { Toast.makeText(getActivity(), "请确定点位", Toast.LENGTH_SHORT).show(); return; } else { - String encode = Geohash.getInstance().encode(latLng.latitude,latLng.longitude); + String encode = Geohash.getInstance().encode(latLng.latitude, latLng.longitude); chargingPileEntity.setP(encode); // poiEntity.setX(String.valueOf(latLng.longitude)); // poiEntity.setY(String.valueOf(latLng.latitude)); @@ -753,7 +749,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC photoBean.add(tagCoding); } String tagEquipment = (String) ivEquipment.getTag(); - if (tagEquipment == null ) { + if (tagEquipment == null) { Toast.makeText(getActivity(), "请拍照 设备标牌", Toast.LENGTH_SHORT).show(); return; } else { @@ -768,14 +764,14 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC photoBean.add(tagFacility); } } else { - if (tagFacility != null ) { + if (tagFacility != null) { photoBean.add(tagFacility); } } String tagScutcheon = (String) ivScutcheon.getTag(); if (sign_exist == 1) { - if (tagScutcheon == null ) { + if (tagScutcheon == null) { Toast.makeText(getActivity(), "请拍照 设备编码", Toast.LENGTH_SHORT).show(); return; } else { @@ -805,29 +801,29 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC photoBean.add(tagAvailable); } String tagParking = (String) ivParking.getTag(); - if (tagParking == null ) { + if (tagParking == null) { Toast.makeText(getActivity(), "请拍照 停车位编号", Toast.LENGTH_SHORT).show(); return; } else { photoBean.add(tagPanorama); } String tagNumber = (String) ivNumber.getTag(); - if (tagNumber != null ) { + if (tagNumber != null) { photoBean.add(tagNumber); } chargingPileEntity.setPhotos(photoBean); - if ("".equals(buffer1)&&"".equals(buffer2)&&"".equals(buffer3)&&"".equals(buffer4)&&"".equals(buffer5)) { + if ("".equals(buffer1) && "".equals(buffer2) && "".equals(buffer3) && "".equals(buffer4) && "".equals(buffer5)) { Toast.makeText(getActivity(), "开放状态未勾选", Toast.LENGTH_SHORT).show(); return; } - if (buffer1!=null&&!buffer1.equals("")&&buffer1.length()>0){ - openType.delete(0,openType.length()); + if (buffer1 != null && !buffer1.equals("") && buffer1.length() > 0) { + openType.delete(0, openType.length()); openType.append(buffer1); String charAt = openType.deleteCharAt(openType.length() - 1).toString(); chargingPileEntity.setCp_openType(charAt); - }else { - openType.delete(0,openType.length()); + } else { + openType.delete(0, openType.length()); openType.append(buffer2); openType.append(buffer3); openType.append(buffer4); @@ -858,7 +854,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC getActivity().runOnUiThread(new Runnable() { @Override public void run() { - if (result[0]!=0) { + if (result[0] != 0) { ToastUtil.showShort(getActivity(), "充电桩保存成功"); Message obtain = Message.obtain(); @@ -992,43 +988,43 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC private void phoneList() { phoneLists = new ArrayList<>(); String ivPanoramaTag = (String) ivPanorama.getTag(); - if (ivPanoramaTag!=null){ + if (ivPanoramaTag != null) { phoneLists.add(new File(ivPanoramaTag)); } String ivCodingTag = (String) ivCoding.getTag(); - if (ivCodingTag!=null){ + if (ivCodingTag != null) { phoneLists.add(new File(ivCodingTag)); } String ivEquipmentTag = (String) ivEquipment.getTag(); - if (ivEquipmentTag!=null){ + if (ivEquipmentTag != null) { phoneLists.add(new File(ivEquipmentTag)); } String ivFacilityTag = (String) ivFacility.getTag(); - if (ivFacilityTag!=null){ + if (ivFacilityTag != null) { phoneLists.add(new File(ivFacilityTag)); } - String ivUsableTag = (String) ivUsable.getTag(); - if (ivUsableTag!=null){ + String ivUsableTag = (String) ivUsable.getTag(); + if (ivUsableTag != null) { phoneLists.add(new File(ivUsableTag)); } String ivAvailableTag = (String) ivAvailable.getTag(); - if (ivAvailableTag!=null){ + if (ivAvailableTag != null) { phoneLists.add(new File(ivAvailableTag)); } String ivParkingTag = (String) ivParking.getTag(); - if (ivParkingTag!=null){ + if (ivParkingTag != null) { phoneLists.add(new File(ivParkingTag)); } - String ivNumberTag = (String) ivNumber.getTag(); - if (ivNumberTag!=null){ + String ivNumberTag = (String) ivNumber.getTag(); + if (ivNumberTag != null) { phoneLists.add(new File(ivNumberTag)); } String ivDeviceTag = (String) ivDevice.getTag(); - if (ivDeviceTag!=null){ + if (ivDeviceTag != null) { phoneLists.add(new File(ivDeviceTag)); } String ivScutcheonTag = (String) ivScutcheon.getTag(); - if (ivScutcheonTag!=null){ + if (ivScutcheonTag != null) { phoneLists.add(new File(ivScutcheonTag)); } } @@ -1055,53 +1051,53 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC ChargingPileEntity chargingPileEntity = new ChargingPileEntity(); ArrayList photo = new ArrayList<>(); if (latLng != null) { - chargingPileEntity.setP(latLng.latitude+","+latLng.longitude); + chargingPileEntity.setP(latLng.latitude + "," + latLng.longitude); } String name = tvNameContent.getText().toString().trim();//名称 - if (name != null &&!name.equals("")) { + if (name != null && !name.equals("")) { chargingPileEntity.setName(name); } if (cp_floor != 0) { chargingPileEntity.setCp_floor(cp_floor); } String tagPanorama = (String) ivPanorama.getTag(); - if (tagPanorama != null &&!tagPanorama.equals("")) { + if (tagPanorama != null && !tagPanorama.equals("")) { photo.add(tagPanorama); } String tagCoding = (String) ivCoding.getTag(); - if (tagCoding != null&&!tagCoding.equals("")) { + if (tagCoding != null && !tagCoding.equals("")) { photo.add(tagCoding); } String tagEquipment = (String) ivEquipment.getTag(); - if (tagEquipment != null&&!tagEquipment.equals("")) { + if (tagEquipment != null && !tagEquipment.equals("")) { photo.add(tagEquipment); } String tagFacility = (String) ivFacility.getTag(); - if (tagFacility != null&&!tagFacility.equals("")) { + if (tagFacility != null && !tagFacility.equals("")) { photo.add(tagFacility); } String tagScutcheon = (String) ivScutcheon.getTag(); - if (tagScutcheon != null&&!tagScutcheon.equals("")) { + if (tagScutcheon != null && !tagScutcheon.equals("")) { photo.add(tagScutcheon); } String tagDevice = (String) ivDevice.getTag(); - if (tagDevice != null&&!tagDevice.equals("")) { + if (tagDevice != null && !tagDevice.equals("")) { photo.add(tagDevice); } String tagUsable = (String) ivUsable.getTag(); - if (tagUsable != null &&!tagUsable.equals("")) { + if (tagUsable != null && !tagUsable.equals("")) { photo.add(tagUsable); } String tagAvailable = (String) ivAvailable.getTag(); - if (tagAvailable != null&&!tagAvailable.equals("")) { + if (tagAvailable != null && !tagAvailable.equals("")) { photo.add(tagAvailable); } String tagParking = (String) ivParking.getTag(); - if (tagParking != null&&!tagParking.equals("")) { + if (tagParking != null && !tagParking.equals("")) { photo.add(tagPanorama); } String tagNumber = (String) ivNumber.getTag(); - if (tagNumber != null&&!tagNumber.equals("")) { + if (tagNumber != null && !tagNumber.equals("")) { photo.add(tagNumber); } chargingPileEntity.setPhotos(photo); @@ -1114,15 +1110,15 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC if (pid != null) { chargingPileEntity.setFid(pid); } - if (buffer1!=null&&!buffer1.equals("")){ + if (buffer1 != null && !buffer1.equals("")) { chargingPileEntity.setCp_openType(buffer1); - }else { + } else { openType.reverse(); openType.append(buffer2); openType.append(buffer3); openType.append(buffer4); openType.append(buffer5); - if (openType!=null&&!"".equals(openType)&&openType.length()>0) { + if (openType != null && !"".equals(openType) && openType.length() > 0) { String charAt = openType.deleteCharAt(openType.length() - 1).toString(); chargingPileEntity.setCp_openType(charAt); } else { @@ -1132,7 +1128,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC String newChargingPileEntity = new Gson().toJson(chargingPileEntity); //以键值对的形式添加新值。 edit.putString("chargingPileEntity", newChargingPileEntity); - if (station!=null){ + if (station != null) { edit.putString("poiEntity", station); } //提交新值。必须执行,否则前面的操作都无效。 @@ -1146,7 +1142,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC if (requestCode == 101 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 - takePhotoPath1 = PhotoPathUtil.getTakePhotoPath(data, "a",Geohash.getInstance().encode(latLng.latitude,latLng.longitude)); + takePhotoPath1 = PhotoPathUtil.getTakePhotoPath(data, "a", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); ivPanorama.setTag(takePhotoPath1); ivPanorama.setImageBitmap(bitmap);//显示图像 /* int height = bitmap.getHeight(); @@ -1167,7 +1163,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC } else if (requestCode == 102 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 - takePhotoPath2 = PhotoPathUtil.getTakePhotoPath(data, "b",Geohash.getInstance().encode(latLng.latitude,latLng.longitude)); + takePhotoPath2 = PhotoPathUtil.getTakePhotoPath(data, "b", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); ivCoding.setTag(takePhotoPath2); ivCoding.setImageBitmap(bitmap);//显示图像 /* int height = bitmap.getHeight(); @@ -1188,7 +1184,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC } else if (requestCode == 103 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 - takePhotoPath3 = PhotoPathUtil.getTakePhotoPath(data, "c",Geohash.getInstance().encode(latLng.latitude,latLng.longitude)); + takePhotoPath3 = PhotoPathUtil.getTakePhotoPath(data, "c", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); ivEquipment.setImageBitmap(bitmap);//显示图像 ivEquipment.setTag(takePhotoPath3); /* int height = bitmap.getHeight(); @@ -1209,7 +1205,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC } else if (requestCode == 104 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 - takePhotoPath4 = PhotoPathUtil.getTakePhotoPath(data, "c",Geohash.getInstance().encode(latLng.latitude,latLng.longitude)); + takePhotoPath4 = PhotoPathUtil.getTakePhotoPath(data, "c", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); ivFacility.setTag(takePhotoPath4); ivFacility.setImageBitmap(bitmap);//显示图像 /* int height = bitmap.getHeight(); @@ -1230,7 +1226,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC } else if (requestCode == 105 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 - takePhotoPath5 = PhotoPathUtil.getTakePhotoPath(data, "c",Geohash.getInstance().encode(latLng.latitude,latLng.longitude)); + takePhotoPath5 = PhotoPathUtil.getTakePhotoPath(data, "c", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); ivScutcheon.setTag(takePhotoPath5); ivScutcheon.setImageBitmap(bitmap);//显示图像 /* int height = bitmap.getHeight(); @@ -1251,7 +1247,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC } else if (requestCode == 106 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 - takePhotoPath6 = PhotoPathUtil.getTakePhotoPath(data, "c",Geohash.getInstance().encode(latLng.latitude,latLng.longitude)); + takePhotoPath6 = PhotoPathUtil.getTakePhotoPath(data, "c", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); ivDevice.setTag(takePhotoPath6); ivDevice.setImageBitmap(bitmap);//显示图像 /* int height = bitmap.getHeight(); @@ -1272,7 +1268,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC } else if (requestCode == 107 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 - takePhotoPath7 = PhotoPathUtil.getTakePhotoPath(data, "d",Geohash.getInstance().encode(latLng.latitude,latLng.longitude)); + takePhotoPath7 = PhotoPathUtil.getTakePhotoPath(data, "d", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); ivUsable.setTag(takePhotoPath7); ivUsable.setImageBitmap(bitmap);//显示图像 /* int height = bitmap.getHeight(); @@ -1293,7 +1289,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC } else if (requestCode == 108 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 - takePhotoPath8 = PhotoPathUtil.getTakePhotoPath(data, "d",Geohash.getInstance().encode(latLng.latitude,latLng.longitude)); + takePhotoPath8 = PhotoPathUtil.getTakePhotoPath(data, "d", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); ivAvailable.setTag(takePhotoPath8); ivAvailable.setImageBitmap(bitmap);//显示图像 /* int height = bitmap.getHeight(); @@ -1314,7 +1310,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC } else if (requestCode == 109 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 - takePhotoPath9 = PhotoPathUtil.getTakePhotoPath(data, "e",Geohash.getInstance().encode(latLng.latitude,latLng.longitude)); + takePhotoPath9 = PhotoPathUtil.getTakePhotoPath(data, "e", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); ivParking.setImageBitmap(bitmap);//显示图像 ivParking.setTag(takePhotoPath9); /* int height = bitmap.getHeight(); @@ -1335,7 +1331,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC } else if (requestCode == 110 && resultCode == RESULT_OK) { Bundle extras = data.getExtras();//从Intent中获取附加值 Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像 - takePhotoPath10 = PhotoPathUtil.getTakePhotoPath(data, "e",Geohash.getInstance().encode(latLng.latitude,latLng.longitude)); + takePhotoPath10 = PhotoPathUtil.getTakePhotoPath(data, "e", Geohash.getInstance().encode(latLng.latitude, latLng.longitude)); ivNumber.setImageBitmap(bitmap);//显示图像 ivNumber.setTag(takePhotoPath10); /* int height = bitmap.getHeight(); diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java index 9f1910c..293a0aa 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java @@ -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 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) { - dismissLoadingDialog(); - initPoiSaveLocal(true); + 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 .post(HttpInterface.POI_VIDEO_UPLOAD_PIC) diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java index 07d5835..1b537bd 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java @@ -261,18 +261,20 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList startActivityForResult(intent, 0x101); break; case R.id.road_upload: + showLoadingDialog(); ArrayList 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); } }); diff --git a/app/src/main/res/layout/activity_camera.xml b/app/src/main/res/layout/activity_camera.xml deleted file mode 100644 index 2cc92db..0000000 --- a/app/src/main/res/layout/activity_camera.xml +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - -