修改‘poi录像’的保存本地和上传

This commit is contained in:
md
2021-07-12 18:50:53 +08:00
parent c37471f55c
commit 308373e9f4
10 changed files with 306 additions and 76 deletions

View File

@@ -31,6 +31,7 @@ public class Constant {
public static final String BASE_FOLDER = SdkFolderCreate.getSDPath()+"/navinfoOutDoor"; public static final String BASE_FOLDER = SdkFolderCreate.getSDPath()+"/navinfoOutDoor";
// 保存图片的目录 // 保存图片的目录
public static final String PICTURE_FOLDER = BASE_FOLDER+"/picture"; public static final String PICTURE_FOLDER = BASE_FOLDER+"/picture";
public static final String VIDEOS_ = BASE_FOLDER+"/videos";
public static final String POI_DAO = BASE_FOLDER+"/BaseDao/"; public static final String POI_DAO = BASE_FOLDER+"/BaseDao/";
// 申请权限的RequestCode // 申请权限的RequestCode
public static final int PERMISSION_REQUEST_CODE = 0x100; public static final int PERMISSION_REQUEST_CODE = 0x100;

View File

@@ -0,0 +1,32 @@
package com.navinfo.outdoor.bean;
public class PoiVideoBean {
private Integer code;
private String message;
private Integer body;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Integer getBody() {
return body;
}
public void setBody(Integer body) {
this.body = body;
}
}

View File

@@ -399,8 +399,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
PoiEntity poiEntity = poiDao.getPoiEntity(taskId); poiDao.deleteFormTaskID(taskId);
poiDao.deletePoiEntity(poiEntity);
} }
}).start(); }).start();
btnGetTask.setVisibility(View.VISIBLE); btnGetTask.setVisibility(View.VISIBLE);
@@ -473,8 +472,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
PoiEntity poiEntity = poiDao.getPoiEntity(taskId); poiDao.deleteFormTaskID(taskId);
poiDao.deletePoiEntity(poiEntity);
} }
}).start(); }).start();
btnGather.setVisibility(View.VISIBLE); btnGather.setVisibility(View.VISIBLE);

View File

@@ -364,11 +364,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (poiEntity.getTaskId() == 0) { poiDao.insertPoiEntity(poiEntity);
poiDao.insertPoiEntity(poiEntity);
} else {
poiDao.updatePoiEntity(poiEntity);
}
getActivity().runOnUiThread(new Runnable() { getActivity().runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -405,21 +401,26 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
if (tagPictures != null) { if (tagPictures != null) {
otherUploadList.add(new File(tagPictures)); otherUploadList.add(new File(tagPictures));
} }
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
PoiEntity poiEntity = poiDao.getPoiEntity(showPoiEntity.getTaskId()); if (showPoiEntity.getId()!=0){
int taskStatus = poiEntity.getTaskStatus(); PoiEntity poiEntity = poiDao.getPoiEntity(showPoiEntity.getId());
getActivity().runOnUiThread(new Runnable() { int taskStatus = poiEntity.getTaskStatus();
@Override getActivity().runOnUiThread(new Runnable() {
public void run() { @Override
if (taskStatus == 2) {//保存本地未提交 public void run() {
Toast.makeText(getActivity(), "请保存本地", Toast.LENGTH_SHORT).show(); if (taskStatus == 2) {//保存本地未提交
} else if (taskStatus == 3) {//保存本地已提交 Toast.makeText(getActivity(), "请保存本地", Toast.LENGTH_SHORT).show();
otherUploadByNet(body, otherUploadList); } else if (taskStatus == 3) {//保存本地已提交
otherUploadByNet(body, otherUploadList);
}
} }
} });
}); }else {
Toast.makeText(getActivity(), "请保存本地", Toast.LENGTH_SHORT).show();
}
} }
}).start(); }).start();
break; break;
@@ -445,6 +446,13 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
dismissLoadingDialog(); dismissLoadingDialog();
Toast.makeText(getActivity(), "上传成功", Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), "上传成功", Toast.LENGTH_SHORT).show();
Log.d("TAG", "onSuccess: " + response.toString() + "sssssssssssss"); Log.d("TAG", "onSuccess: " + response.toString() + "sssssssssssss");
// new Thread(new Runnable() {
// @Override
// public void run() {
// PoiEntity poiEntity = poiDao.getPoiEntity(showPoiEntity.getId());
// poiDao.deletePoiEntity(poiEntity);
// }
// }).start();
} }
@Override @Override
@@ -485,10 +493,10 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
poiDao.updatePoiEntity(poiEntity); poiDao.insertPoiEntity(poiEntity);
} }
}).start(); }).start();
// Log.d("TAG", " 其他其他其他其他" + poiSaveBean.getBody()); // Log.d("TAG", " 其他其他其他其他" + poiSaveBean.getBody());
} }
@Override @Override

View File

@@ -587,7 +587,6 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
@Override @Override
public void onSuccess(PoiSaveBean poiSaveBean, int id) { public void onSuccess(PoiSaveBean poiSaveBean, int id) {
dismissLoadingDialog(); dismissLoadingDialog();
body = poiSaveBean.getBody(); body = poiSaveBean.getBody();
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
Log.d("TAG", "onSuccess: "+poiSaveBean.getBody()); Log.d("TAG", "onSuccess: "+poiSaveBean.getBody());

View File

@@ -24,17 +24,33 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.github.lazylibrary.util.ZipUtil;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.hjq.permissions.OnPermissionCallback; import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission; import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions; import com.hjq.permissions.XXPermissions;
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.R;
import com.navinfo.outdoor.activity.PictureActivity; import com.navinfo.outdoor.activity.PictureActivity;
import com.navinfo.outdoor.activity.PicturesActivity; import com.navinfo.outdoor.activity.PicturesActivity;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseDrawerFragment; import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.bean.OtherUploadPicBean;
import com.navinfo.outdoor.bean.PoiSaveBean;
import com.navinfo.outdoor.bean.PoiVideoBean;
import com.navinfo.outdoor.bean.RoadExtend; import com.navinfo.outdoor.bean.RoadExtend;
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.PoiDao; import com.navinfo.outdoor.room.PoiDao;
import com.navinfo.outdoor.room.PoiDatabase; import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity; import com.navinfo.outdoor.room.PoiEntity;
@@ -45,6 +61,7 @@ import org.greenrobot.eventbus.EventBus;
import java.io.File; import java.io.File;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -56,7 +73,7 @@ import java.util.List;
public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClickListener { public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClickListener {
private TextView tvPictures; private TextView tvPictures;
private EditText etRoadName; private EditText etRoadName;
private ImageView ivRoadPicture; private ImageView ivPoiVideoPicture;
private RadioButton rbCar; private RadioButton rbCar;
private RadioButton rbBicycle; private RadioButton rbBicycle;
private RadioButton rbWalking; private RadioButton rbWalking;
@@ -69,7 +86,11 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
private PoiEntity showPoiEntity; private PoiEntity showPoiEntity;
private RelativeLayout linearExist; private RelativeLayout linearExist;
private Spinner spinnerExist; private Spinner spinnerExist;
String[] spinner = new String[]{"存在","不存在","无法验证"}; String[] spinner = new String[]{"存在", "不存在", "无法验证"};
private Integer poiVideoBody;
private File videoFile;
private Button roadUpload;
private String videoPath;
public static PoiVideoFragment newInstance(Bundle bundle) { public static PoiVideoFragment newInstance(Bundle bundle) {
PoiVideoFragment fragment = new PoiVideoFragment(); PoiVideoFragment fragment = new PoiVideoFragment();
@@ -94,20 +115,20 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Bundle arguments = getArguments(); Bundle arguments = getArguments();
if (arguments!=null) { if (arguments != null) {
isSliding= arguments.getBoolean("isSliding",true); isSliding = arguments.getBoolean("isSliding", true);
Log.d("TAG", "onCreatessss: "+isSliding); Log.d("TAG", "onCreatessss: " + isSliding);
} }
if (isSliding) { if (isSliding) {
// 监听到返回按钮点击事件 // 监听到返回按钮点击事件
Message obtain = Message.obtain(); Message obtain = Message.obtain();
obtain.what= Constant.TREASURE_FRAGMENT; obtain.what = Constant.TREASURE_FRAGMENT;
obtain.obj=isSliding; obtain.obj = isSliding;
EventBus.getDefault().post(obtain); EventBus.getDefault().post(obtain);
Message mainButtonVisiableMsg = Message.obtain(); Message mainButtonVisiableMsg = Message.obtain();
mainButtonVisiableMsg.what= Constant.MAIN_BUTTON_VISIABLE; mainButtonVisiableMsg.what = Constant.MAIN_BUTTON_VISIABLE;
mainButtonVisiableMsg.obj= View.VISIBLE; mainButtonVisiableMsg.obj = View.VISIBLE;
EventBus.getDefault().post(mainButtonVisiableMsg); EventBus.getDefault().post(mainButtonVisiableMsg);
} }
onBackPressed(); onBackPressed();
@@ -116,8 +137,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} }
@Override @Override
protected void initView() { protected void initView() {
super.initView(); super.initView();
@@ -126,7 +145,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
tvPictures = (TextView) findViewById(R.id.tv_pictures); tvPictures = (TextView) findViewById(R.id.tv_pictures);
tvPictures.setOnClickListener(this::onClick); tvPictures.setOnClickListener(this::onClick);
etRoadName = (EditText) findViewById(R.id.et_road_name); etRoadName = (EditText) findViewById(R.id.et_road_name);
ivRoadPicture = (ImageView) findViewById(R.id.iv_road_picture); ivPoiVideoPicture = (ImageView) findViewById(R.id.iv_road_picture);
rbCar = (RadioButton) findViewById(R.id.rb_car); rbCar = (RadioButton) findViewById(R.id.rb_car);
rbBicycle = (RadioButton) findViewById(R.id.rb_bicycle); rbBicycle = (RadioButton) findViewById(R.id.rb_bicycle);
rbWalking = (RadioButton) findViewById(R.id.rb_walking); rbWalking = (RadioButton) findViewById(R.id.rb_walking);
@@ -134,6 +153,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
etDesc = (EditText) findViewById(R.id.et_desc); etDesc = (EditText) findViewById(R.id.et_desc);
btnRoadSave = (Button) findViewById(R.id.btn_road_save); btnRoadSave = (Button) findViewById(R.id.btn_road_save);
btnRoadSave.setOnClickListener(this::onClick); btnRoadSave.setOnClickListener(this::onClick);
roadUpload = findViewById(R.id.road_upload);
roadUpload.setOnClickListener(this::onClick);
rgType = (RadioGroup) findViewById(R.id.rg_type); rgType = (RadioGroup) findViewById(R.id.rg_type);
linearExist = findViewById(R.id.linear_exist); linearExist = findViewById(R.id.linear_exist);
spinnerExist = findViewById(R.id.spinner_exist); spinnerExist = findViewById(R.id.spinner_exist);
@@ -158,7 +179,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} }
}); });
ivRoadPicture.setOnClickListener(new View.OnClickListener() { ivPoiVideoPicture.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (v.getTag() == null) { if (v.getTag() == null) {
@@ -171,12 +192,33 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
startActivityForResult(intent, 0x101); startActivityForResult(intent, 0x101);
} }
}); });
ivPoiVideoPicture.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
MessageDialog.show((AppCompatActivity) getContext(), "提示", "对否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
if (videoFile != null) {
videoFile.delete();
//获取文件名
String csvFileName = videoFile.getName() + ".txt";
File cavFile = new File(videoFile.getParent(), csvFileName);
cavFile.delete();
ivPoiVideoPicture.setImageDrawable(null);
}
return false;
}
});
return false;
}
});
//添加数据 //添加数据
initShowPoi(); initShowPoi();
//禁用可操作性控件 //禁用可操作性控件
// disables(); // disables();
} }
private void initShowPoi() { private void initShowPoi() {
// 添加信息: // 添加信息:
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity"); showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
@@ -186,9 +228,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
etRoadName.setText(name + ""); etRoadName.setText(name + "");
} }
String extend = showPoiEntity.getExtend(); String extend = showPoiEntity.getExtend();
if (extend!=null&&!extend.equals("")){ if (extend != null && !extend.equals("")) {
RoadExtend roadExtend = new Gson().fromJson(extend, RoadExtend.class); RoadExtend roadExtend = new Gson().fromJson(extend, RoadExtend.class);
int type= roadExtend.getType(); int type = roadExtend.getType();
showPictureType(type); showPictureType(type);
} }
linearExist.setVisibility(View.VISIBLE); linearExist.setVisibility(View.VISIBLE);
@@ -197,20 +239,21 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
etDesc.setText(describe); etDesc.setText(describe);
} }
String photo = showPoiEntity.getPhoto(); String photo = showPoiEntity.getPhoto();
if (photo!=null) { if (photo != null) {
File videoFile = new File(photo); File videoFile = new File(photo);
if (videoFile.exists()) { if (videoFile.exists()) {
// 使用glide加载视频的第一帧 // 使用glide加载视频的第一帧
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500); AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
ivRoadPicture.setTag(videoFile); ivPoiVideoPicture.setTag(videoFile);
} }
} }
} }
} }
private void disables() { private void disables() {
etRoadName.setEnabled(false); etRoadName.setEnabled(false);
rgType.setEnabled(false); rgType.setEnabled(false);
ivRoadPicture.setEnabled(false); ivPoiVideoPicture.setEnabled(false);
tvPictures.setEnabled(false); tvPictures.setEnabled(false);
etDesc.setEnabled(false); etDesc.setEnabled(false);
btnRoadSave.setEnabled(false); btnRoadSave.setEnabled(false);
@@ -219,7 +262,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
@Override @Override
protected void initData() { protected void initData() {
super.initData(); super.initData();
// infos = new ArrayList<>(); // infos = new ArrayList<>();
} }
/** /**
@@ -264,9 +307,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} }
RoadExtend roadExtend = new RoadExtend(); RoadExtend roadExtend = new RoadExtend();
int type = getPictureType(); int type = getPictureType();
if (type== -1){ if (type == -1) {
Toast.makeText(getContext(), "请选择拍照方式", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "请选择拍照方式", Toast.LENGTH_SHORT).show();
return; return;
} }
roadExtend.setType(type); roadExtend.setType(type);
Gson gson = new Gson(); Gson gson = new Gson();
@@ -278,13 +321,13 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} else { } else {
poiEntity.setDescribe(desc); poiEntity.setDescribe(desc);
} }
if (showPoiEntity!=null){ if (showPoiEntity != null) {
if (showPoiEntity.getTaskId()!=0){ if (showPoiEntity.getTaskId() != 0) {
poiEntity.setTaskId(showPoiEntity.getTaskId()); poiEntity.setTaskId(showPoiEntity.getTaskId());
} }
} }
if (ivRoadPicture.getTag()!=null) { if (ivPoiVideoPicture.getTag() != null) {
File videoFile = (File) ivRoadPicture.getTag(); File videoFile = (File) ivPoiVideoPicture.getTag();
poiEntity.setPhoto(videoFile.getAbsolutePath()); poiEntity.setPhoto(videoFile.getAbsolutePath());
} }
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -298,13 +341,16 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (showPoiEntity != null) {
poiDao.updatePoiEntity(poiEntity);
}
poiDao.insertPoiEntity(poiEntity); poiDao.insertPoiEntity(poiEntity);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
poiVideoSave(poiEntity);
}
});
} }
}).start(); }).start();
onBackPressed(); //onBackPressed();
} }
} }
@@ -316,7 +362,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
XXPermissions.startPermissionActivity(getActivity(), permissions); XXPermissions.startPermissionActivity(getActivity(), permissions);
} }
} }
}); });
break; break;
@@ -325,22 +370,98 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String videoFormatName = formatter.format(new Date()); String videoFormatName = formatter.format(new Date());
Intent intent = new Intent(getContext(), PictureActivity.class); Intent intent = new Intent(getContext(), PictureActivity.class);
intent.putExtra(Constant.INTENT_VIDEO_PATH, Constant.PICTURE_FOLDER+"/"+videoFormatName+".mp4"); intent.putExtra(Constant.INTENT_VIDEO_PATH, Constant.PICTURE_FOLDER + "/" + videoFormatName + ".mp4");
startActivityForResult(intent, 0x101); startActivityForResult(intent, 0x101);
break; break;
case R.id.road_upload:
ArrayList<File> files = new ArrayList<>();
if (videoFile != null) {
files.add(videoFile);
}
File file = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
ZipUtil.zipFiles(files, file, new ZipUtil.ZipListener() {
@Override
public void zipProgress(int zipProgress) {
if (zipProgress == 100) {
}
}
});
poiVideoUpload();
break;
} }
} }
private void poiVideoUpload() {
// OkGo
// // 请求方式和请求url
// .<OtherUploadPicBean>post(HttpInterface.POI_VIDEO_UPLOAD_PIC)
// // 请求的 tag, 主要用于取消对应的请求
// .params("auditId", )
// .addFileParams("file",)
// .tag(this)
// .execute(new DialogCallback<OtherUploadPicBean>(OtherUploadPicBean.class) {
// @Override
// public void onSuccess(Response<OtherUploadPicBean> otherUploadPicBeanResponse) {
// dismissLoadingDialog();
// Toast.makeText(getActivity(), "上传成功", Toast.LENGTH_SHORT).show();
// Log.d("TAG", "onSuccess: " + otherUploadPicBeanResponse.toString() + "sssssssssssss");
//
// }
//
// @Override
// public void onError(Response<OtherUploadPicBean> response) {
// super.onError(response);
// dismissLoadingDialog();
// Toast.makeText(getActivity(), response.code()+"", Toast.LENGTH_SHORT).show();
// Log.d("TAG", "onError: " + response.code()+"");
// }
// });
}
private void poiVideoSave(PoiEntity poiEntity) {
showLoadingDialog();
OkGoBuilder.getInstance()
.Builder(getActivity())
.url(HttpInterface.INSIDE_API_LIST)
.method(OkGoBuilder.GET)
.cls(PoiVideoBean.class)
.callback(new Callback<PoiVideoBean>() {
@Override
public void onSuccess(PoiVideoBean poiVideoBean, int id) {
dismissLoadingDialog();
poiVideoBody = poiVideoBean.getBody();
poiEntity.setTaskStatus(3);
poiEntity.setBodyId(poiVideoBody);
new Thread(new Runnable() {
@Override
public void run() {
poiDao.insertPoiEntity(poiEntity);
}
}).start();
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
Log.d("TAG", "onError: " + e.getMessage());
}
}).build();
}
@Override @Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0x101&&resultCode == 0x101) { if (requestCode == 0x101 && resultCode == 0x101) {
if (data!=null&&data.hasExtra(Constant.INTENT_VIDEO_PATH)) { if (data != null && data.hasExtra(Constant.INTENT_VIDEO_PATH)) {
String videoPath = data.getStringExtra(Constant.INTENT_VIDEO_PATH); videoPath = data.getStringExtra(Constant.INTENT_VIDEO_PATH);
File videoFile = new File(videoPath); videoFile = new File(videoPath);
if (videoFile.exists()) { if (videoFile.exists()) {
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500); AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
ivRoadPicture.setTag(videoFile); ivPoiVideoPicture.setTag(videoFile);
} }
} }
} }
@@ -353,9 +474,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} }
/** /**
*防止程序崩溃后数据丢失 * 防止程序崩溃后数据丢失
*/ */
public void initPoiVideoSharePre(){ public void initPoiVideoSharePre() {
//获取SharedPreferences对象方法中两个参数的意思为第一个name //获取SharedPreferences对象方法中两个参数的意思为第一个name
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成 //表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
//一个以该参数命名的.xml文件。第二个mode表示创建的模式通过查看 //一个以该参数命名的.xml文件。第二个mode表示创建的模式通过查看
@@ -382,8 +503,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
if (desc != null && !desc.equals("")) { if (desc != null && !desc.equals("")) {
poiEntity.setDescribe(desc); poiEntity.setDescribe(desc);
} }
if (showPoiEntity!=null){ if (showPoiEntity != null) {
if (showPoiEntity.getTaskId()!=0){ if (showPoiEntity.getTaskId() != 0) {
poiEntity.setTaskId(showPoiEntity.getTaskId()); poiEntity.setTaskId(showPoiEntity.getTaskId());
} }
} }
@@ -400,7 +521,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
edit.putString("poiEntity", newPoiEntity); edit.putString("poiEntity", newPoiEntity);
//提交新值。必须执行,否则前面的操作都无效。 //提交新值。必须执行,否则前面的操作都无效。
edit.commit(); edit.commit();
Log.d("TAG", "initRoadSharePre: "+newPoiEntity); Log.d("TAG", "initRoadSharePre: " + newPoiEntity);
} }
@@ -412,13 +533,14 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
return 1; return 1;
} else if (rbWalking != null && rbWalking.isChecked()) { } else if (rbWalking != null && rbWalking.isChecked()) {
return 2; return 2;
}else if (rbManual != null && rbManual.isChecked()) { } else if (rbManual != null && rbManual.isChecked()) {
return 3; return 3;
} }
return -1; return -1;
} }
private void showPictureType(int type){
switch (type){ private void showPictureType(int type) {
switch (type) {
case 0: case 0:
rbCar.setChecked(true); rbCar.setChecked(true);
break; break;

View File

@@ -4,6 +4,7 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever; import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Message; import android.os.Message;
import android.util.Log; import android.util.Log;
@@ -22,6 +23,7 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.google.gson.Gson; import com.google.gson.Gson;
@@ -38,15 +40,18 @@ import com.navinfo.outdoor.bean.RoadExtend;
import com.navinfo.outdoor.room.PoiDao; import com.navinfo.outdoor.room.PoiDao;
import com.navinfo.outdoor.room.PoiDatabase; import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity; import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.AWMp4ParserHelper;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.File;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@@ -157,6 +162,19 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
public void onNothingSelected(AdapterView<?> parent) { public void onNothingSelected(AdapterView<?> parent) {
} }
}); });
ivRoadPicture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (v.getTag() == null) {
Toast.makeText(getActivity(), "还没有拍摄视频!", Toast.LENGTH_SHORT).show();
return;
}
File videoFile = (File) v.getTag();
Intent intent = new Intent(getContext(), PictureActivity.class);
intent.putExtra(Constant.INTENT_VIDEO_PATH, videoFile.getAbsolutePath());
startActivityForResult(intent, 0x101);
}
});
//数据展示 //数据展示
initShowPoi(); initShowPoi();
//禁用可操作性控件 //禁用可操作性控件
@@ -182,7 +200,17 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
if (describe != null && !describe.equals("")) { if (describe != null && !describe.equals("")) {
etDesc.setText(describe); etDesc.setText(describe);
} }
String photo = showPoiEntity.getPhoto();
if (photo!=null) {
File videoFile = new File(photo);
if (videoFile.exists()) {
// 使用glide加载视频的第一帧
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500);
ivRoadPicture.setTag(videoFile);
}
}
} }
} }
//禁用控件 //禁用控件
private void disables() throws JSONException { private void disables() throws JSONException {
@@ -261,6 +289,10 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
poiEntity.setTaskId(showPoiEntity.getTaskId()); poiEntity.setTaskId(showPoiEntity.getTaskId());
} }
} }
if (ivRoadPicture.getTag()!=null) {
File videoFile = (File) ivRoadPicture.getTag();
poiEntity.setPhoto(videoFile.getAbsolutePath());
}
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis()); calendar.setTimeInMillis(System.currentTimeMillis());
@@ -295,13 +327,30 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
break; break;
case R.id.tv_pictures: case R.id.tv_pictures:
// 根据用户点击的时间为视频名称赋值
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String videoFormatName = formatter.format(new Date());
Intent intent = new Intent(getContext(), PictureActivity.class); Intent intent = new Intent(getContext(), PictureActivity.class);
startActivity(intent); intent.putExtra(Constant.INTENT_VIDEO_PATH, Constant.PICTURE_FOLDER+"/"+videoFormatName+".mp4");
startActivityForResult(intent, 0x101);
break; break;
} }
} }
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0x101&&resultCode == 0x101) {
if (data!=null&&data.hasExtra(Constant.INTENT_VIDEO_PATH)) {
String videoPath = data.getStringExtra(Constant.INTENT_VIDEO_PATH);
File videoFile = new File(videoPath);
if (videoFile.exists()) {
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500);
ivRoadPicture.setTag(videoFile);
}
}
}
}
@Override @Override
public void onSaveInstanceState(@NonNull Bundle outState) { public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);

View File

@@ -103,4 +103,18 @@ public class HttpInterface {
//172.23.139.4:8003/poitask/1/uploadpic //172.23.139.4:8003/poitask/1/uploadpic
public static final String POI_TASK_UPLOAD_PIC=IPm13+"uploadpic";//poi-上传 public static final String POI_TASK_UPLOAD_PIC=IPm13+"uploadpic";//poi-上传
public static final String IPm14 = "http://172.23.139.4:8003/poivideotask/1/";
// 172.23.139.4:8003/poivideotask/1/submitPoivideotask
public static final String INSIDE_API_LIST = IPm14+"submitPoivideotask";//poi录像 保存
//172.23.139.4:8003/poivideotask/1/uploadpic
public static final String POI_VIDEO_UPLOAD_PIC = IPm14+"uploadpic";//poi录像-上传
} }

View File

@@ -31,8 +31,8 @@ public interface PoiDao {
List<PoiEntity> getAllTaskStatus(int taskStatus, int taskStatus1, int type, int type1, int isExclusive, int isExclusive1); List<PoiEntity> getAllTaskStatus(int taskStatus, int taskStatus1, int type, int type1, int isExclusive, int isExclusive1);
@Query("SELECT * FROM poi where taskId=:taskId") @Query("SELECT * FROM poi where id=:id")
PoiEntity getPoiEntity(int taskId); PoiEntity getPoiEntity(int id);
/** /**
* 添加 * 添加
* *
@@ -82,6 +82,9 @@ public interface PoiDao {
@Query("DELETE FROM poi where taskId=:taskId") @Query("DELETE FROM poi where taskId=:taskId")
void deleteFormTaskID(int taskId); void deleteFormTaskID(int taskId);
@Query("DELETE FROM poi where id =:id")
void deleteFormID(int id);
/** /**
* 全部删除 * 全部删除
*/ */

View File

@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -263,4 +267,4 @@
android:text="上传" /> android:text="上传" />
</LinearLayout> </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </ScrollView>