From 7a68019c7f00b725cb4df462816fefe9113e4600 Mon Sep 17 00:00:00 2001 From: wangdongsheng Date: Mon, 23 Aug 2021 17:06:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BD=95=E5=83=8F=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../outdoor/activity/PictureActivity.java | 3 +- .../outdoor/activity/PicturesActivity.java | 258 ++++++------------ .../com/navinfo/outdoor/api/Constant.java | 1 + .../outdoor/fragment/PoiVideoFragment.java | 91 +++--- app/src/main/res/layout/activity_picture.xml | 4 +- .../main/res/layout/poi_video_fragment.xml | 28 +- 6 files changed, 149 insertions(+), 236 deletions(-) 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 e7293c6..b9ec07b 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/PictureActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/PictureActivity.java @@ -212,7 +212,8 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene * app:cameraVideoSizeMaxWidth="2000" * app:cameraVideoSizeMaxArea="2000000" */ - camera.setVideoBitRate(2000000); + + camera.setVideoBitRate(2100000); //获取地图 tencentMap = ivMap.getMap(); 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 f74a87b..4783182 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/PicturesActivity.java @@ -93,78 +93,64 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen private MyLocationStyle locationStyle; private TextureMapView ivMap; private Button stopPicture; - private CsvTimerTask timerTask; private List removables; private PoiEntity poiEntity; private Polyline polyline; - 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 boolean isFinishActivity = false; // 是否需要关闭当前activity private CheckBox capturePicture;//拍照 private ArrayList pictureList; private Handler handler = new Handler(new Handler.Callback() { @Override public boolean handleMessage(@NonNull Message msg) { - if (msg.what == 0 && listenerPicture) { + if (msg.what == 0x101 && listenerPicture) { File file = (File) msg.obj; pictureList.add(file); - if (camera.isTakingPicture()) { - camera.destroy(); - } else { - if (timerTask != null) { - timerTask.cancel(); - } - camera.takePicture(); - } - - } else if (msg.what == 1) { + camera.takePicture(); + } else if (msg.what == 0x102) { if (btnSwitch != null) { 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; } }); - private boolean listenerPicture = true; + private boolean listenerPicture = false; + private SimpleDateFormat formatter; + private File paperFile; + private int type; + private int videoIndex; @Override protected int getLayout() { - /* EventBus.getDefault().register(this); - tmpFile = new File(Constant.PICTURE_FOLDER, "temp.mp4"); - formatter = new SimpleDateFormat("yyyyMMdd HHmmss");*/ + EventBus.getDefault().register(this); return R.layout.activity_pictures; } @Override protected void initView() { super.initView(); - - /* if (getIntent()!=null) { - - }*/ pictureList = new ArrayList<>(); removables = new ArrayList<>();//存储轨迹的marker layerChange = findViewById(R.id.layer_change); if (getIntent() != null) { 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"); } - - timer = new Timer(); - - // this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + formatter = new SimpleDateFormat("yyyyMMdd HHmmss"); ivMap = (TextureMapView) findViewById(R.id.iv_map); 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); @@ -180,6 +166,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen } else { listenerPicture = false; capturePicture.setText("开始采集"); + } } }); @@ -192,47 +179,51 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen UiSettings uiSettings = tencentMap.getUiSettings(); //设置logo的大小 uiSettings.setLogoScale(0.7f); -// uiSettings.setAllGesturesEnabled(false); setLocMarkerStyle(); // 设置当前位置显示样式 initLine(); -// 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); - //文件 - File file = new File(finalVideoPath); - result.toFile(file, new FileCallback() { - @Override - public void onFileReady(@Nullable @org.jetbrains.annotations.Nullable File file) { - Message message = new Message(); - message.what = 0; - message.obj = file; - handler.sendMessageDelayed(message, 2000); - File finalVideoFile = new File(finalVideoPath); - if (finalVideoFile.exists()&&listenerPicture) { - timerTask = new CsvTimerTask(new File(finalVideoPath + ".txt")); - timer.schedule(timerTask, 0, period * 1000); - int videoIndex = Integer.parseInt(finalVideoFile.getName().replace(".jpg", "")); - finalVideoPath = finalVideoFile.getParentFile().getAbsolutePath() + "/" + (videoIndex + 1) + ".jpg"; + if (listenerPicture) { + super.onPictureTaken(result); + //文件 + File file = new File(finalVideoPath); + result.toFile(file, new FileCallback() { + @Override + public void onFileReady(@Nullable @org.jetbrains.annotations.Nullable File file) { + if (listenerPicture) { + if (file.exists()) { + videoIndex = Integer.parseInt(file.getName().replace(".jpg", "")); + finalVideoPath = file.getParentFile().getAbsolutePath() + "/" + (videoIndex + 1) + ".jpg"; + } + initMarkerPaper(); + Message message = new Message(); + if (type == 3) { + 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); } - }); - if (camera.isTakingVideo()) { - message("Captured while taking video. Size=" + result.getSize(), false); + long callbackTime = System.currentTimeMillis(); + captureTime = callbackTime - 300; + 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) { super.onVideoTaken(result); 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 @@ -291,29 +242,6 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen @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(); - }*/ } }); @@ -378,18 +306,17 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen public void onClick(View v) { switch (v.getId()) { case R.id.btn_stop_picture: - if (timerTask != null) { - timerTask.cancel(); - } + listenerPicture = false; 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); finish(); break; case R.id.btn_switch: v.setEnabled(false); - handler.sendEmptyMessageDelayed(1, 2000); // 利用handler延迟发送更改状态信息 + handler.sendEmptyMessageDelayed(0x102, 2000); // 利用handler延迟发送更改状态信息 btnSwich(); break; } @@ -488,14 +415,11 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen if (polyline != null) { polyline.remove(); } - if (timerTask != null) { - timerTask.cancel(); - } + listenerPicture = false; for (int i = 0; i < removables.size(); i++) { removables.get(i).remove(); } removables.clear(); - // timer.cancel(); if (EventBus.getDefault().isRegistered(this)) { EventBus.getDefault().unregister(this); } @@ -519,43 +443,29 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen } } - /** - * 记录视频拍摄的时间及经纬度 - */ - 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"); - 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); + public void initMarkerPaper() { + // 记录当前时间、视频时间、以及当前经纬度信息 + StringBuffer sb = new StringBuffer(); + sb.append(formatter.format(new Date())); // 记录当前时 + sb.append(","); + sb.append(videoIndex);//個數 + sb.append(","); + sb.append(Constant.currentLocation.getLatitude()); + sb.append(","); + sb.append(Constant.currentLocation.getLongitude()); + sb.append(","); + if (Constant.currentLocation.getBearing() != 0) { + sb.append(Constant.currentLocation.getBearing()); + } else { + sb.append(Constant.currentLocation.getDirection()); } + 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); } } \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/outdoor/api/Constant.java b/app/src/main/java/com/navinfo/outdoor/api/Constant.java index 0fc8fca..8eaf344 100644 --- a/app/src/main/java/com/navinfo/outdoor/api/Constant.java +++ b/app/src/main/java/com/navinfo/outdoor/api/Constant.java @@ -165,6 +165,7 @@ public class Constant { public static MapView treasureMap; 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_VIDEO_ORATATION = "INTENT_VIDEO_ORATATION"; // 视频拍摄时屏幕方向 0-强制横屏 其他-任意 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 6432cf0..228f35f 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java @@ -29,7 +29,6 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.core.widget.NestedScrollView; import com.bumptech.glide.Glide; -import com.github.lazylibrary.util.FileUtils; import com.github.lazylibrary.util.StringUtils; import com.github.lazylibrary.util.ZipUtil; 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.DialogSettings; import com.kongzue.dialog.v3.MessageDialog; -import com.lzy.okgo.OkGo; import com.lzy.okgo.model.HttpParams; -import com.lzy.okgo.model.Response; import com.navinfo.outdoor.R; import com.navinfo.outdoor.activity.FragmentManagement; import com.navinfo.outdoor.activity.PictureActivity; import com.navinfo.outdoor.activity.PicturesActivity; import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.base.BaseDrawerFragment; -import com.navinfo.outdoor.bean.Info; import com.navinfo.outdoor.bean.OtherUploadPicBean; -import com.navinfo.outdoor.bean.PoiSaveBean; import com.navinfo.outdoor.bean.PoiVideoBean; -import com.navinfo.outdoor.bean.RoadExtend; import com.navinfo.outdoor.bean.UnPolygonTaskBean; import com.navinfo.outdoor.http.Callback; -import com.navinfo.outdoor.http.DialogCallback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; 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.Marker; import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; - import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; - import java.io.File; -import java.io.Serializable; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; -import java.util.Date; import java.util.List; /** @@ -92,12 +81,10 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick private TextView tvPictures; private EditText etRoadName; private ImageView ivPoiVideoPicture; - private RadioButton rbCar; - private RadioButton rbBicycle; - private RadioButton rbWalking; + private RadioGroup rgType; + private RadioButton rbCar, rbBicycle, rbWalking, rbManual; private EditText etDesc; private Button btnRoadSave; - private RadioGroup rgType; private PoiDatabase poiDatabase; private PoiDao poiDao; private Button btnPoiVideoUpload; @@ -107,7 +94,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick private LatLng latLng; private Marker markerPoiVideo; private TextView tvPicture; - private int isRequest; + private int isRequest; public static PoiVideoFragment newInstance(Bundle bundle) { 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); 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); fmPoiVideoPic = findViewById(R.id.fm_poi_video_picture); 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.setOnClickListener(this::onClick); 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 - public void onClick(View v) { - if (v.getTag() == null || ((List) v.getTag()).size() == 0) { - Toast.makeText(getActivity(), "还没有拍摄视频!", Toast.LENGTH_SHORT).show(); - return; - } + public void onCheckedChanged(RadioGroup group, int checkedId) { - File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath()); - Intent intent = new Intent(getContext(), PictureActivity.class); - // intent.putExtra("uuId", showPoiEntity.getId()); - intent.putExtra("poiEntity", showPoiEntity); - intent.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath()); - startActivityForResult(intent, 0x101); + switch (checkedId) { + case R.id.rb_car: + case R.id.rb_bicycle: + case R.id.rb_walking: + tvPicture.setVisibility(View.VISIBLE); + break; + case R.id.rb_manual: + tvPicture.setVisibility(View.GONE); + break; + } } - });*/ + }); fmPoiVideoPic.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { @@ -247,6 +236,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick } int work_type = showPoiEntity.getWork_type(); showPictureType(work_type); + if (work_type==3){ + tvPicture.setVisibility(View.GONE); + } String describe = showPoiEntity.getMemo();//任务描述 if (describe != null && !describe.equals("")) { etDesc.setText(describe + ""); @@ -266,8 +258,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick isImageLoad = true; } - } - fmPoiVideoPic.setTag(videoFileListByUUID); + } + fmPoiVideoPic.setTag(videoFileListByUUID); } } } else if (record_way == 2) {//连拍 @@ -276,7 +268,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick boolean isImageLoad = false; List pictureFileListByUUID = AWMp4ParserHelper.getInstance().getJPGFileListByUUID(showPoiEntity.getId()); 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) { // 使用glide加载视频的第一帧 Glide.with(getActivity()).load(pictureFileListByUUID.get(i)).into(ivPoiVideoPicture); @@ -325,18 +317,15 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick initPoiSaveLocal(false); break; case R.id.tv_pictures://拍照 - tvPicture.setEnabled(false); Intent intents = new Intent(getContext(), PicturesActivity.class); 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); startActivityForResult(intents, 0x102); break; 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); File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).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) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 0x101 && resultCode == 0x101) { + tvPictures.setEnabled(false); isRequest = 0x101; if (data != null && data.hasExtra(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) { - isRequest =0x102; + tvPicture.setEnabled(false); + isRequest = 0x102; if (data != null && data.hasExtra(Constant.INTENT_PICTURES_PATH)) { - ArrayList serializableExtra = (ArrayList) data.getSerializableExtra(Constant.INTENT_PICTURES_PATH); - if (serializableExtra != null) { - Glide.with(getActivity()).load(serializableExtra.get(0)).into(ivPoiVideoPicture); + String videoPath = data.getStringExtra(Constant.INTENT_PICTURES_PATH); + File pictureFile = new File(videoPath); + if (pictureFile.exists()) { + AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(pictureFile).toString(), ivPoiVideoPicture, 500); List pictureFileListByUUID = AWMp4ParserHelper.getInstance().getJPGFileListByUUID(showPoiEntity.getId()); fmPoiVideoPic.setTag(pictureFileListByUUID); } @@ -611,6 +603,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick return 1; } else if (rbWalking != null && rbWalking.isChecked()) { return 2; + } else if (rbManual !=null &&rbManual.isChecked()){ + return 3; } return -1; } @@ -626,6 +620,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick case 2: rbWalking.setChecked(true); break; + case 3: + rbManual.setChecked(true); + break; } } @@ -748,7 +745,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick poiEntity.setCreateTime(format); poiEntity.setType(3); poiEntity.setTaskStatus(2); - if (isRequest==0x101){ + if (isRequest == 0x101) { if (fmPoiVideoPic.getTag() == null) { List videoFileListByUUID = AWMp4ParserHelper.getInstance().getVideoFileListByUUID(showPoiEntity.getId()); if (videoFileListByUUID != null) { @@ -766,7 +763,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick } poiEntity.setRecord_way(1);//录像 } - }else if (isRequest==0x102){ + } else if (isRequest == 0x102) { if (fmPoiVideoPic.getTag() == null) { List pictureFileListByUUID = AWMp4ParserHelper.getInstance().getJPGFileListByUUID(showPoiEntity.getId()); if (pictureFileListByUUID != null) { diff --git a/app/src/main/res/layout/activity_picture.xml b/app/src/main/res/layout/activity_picture.xml index 0facc2e..59cff2a 100644 --- a/app/src/main/res/layout/activity_picture.xml +++ b/app/src/main/res/layout/activity_picture.xml @@ -11,8 +11,8 @@ android:layout_height="match_parent"> + + android:layout_height="match_parent"> + + + android:layout_height="match_parent"> + + app:layout_constraintTop_toTopOf="parent" /> - - - - - - - + + @@ -160,6 +163,7 @@ android:text="录像" android:textColor="@color/white" android:textSize="15sp" /> +