修改 拍照功能(存在错误)添加‘其他’ 上传接口
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
package com.navinfo.outdoor.activity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseActivity;
|
||||
import com.otaliastudios.cameraview.CameraListener;
|
||||
import com.otaliastudios.cameraview.CameraLogger;
|
||||
import com.otaliastudios.cameraview.CameraView;
|
||||
import com.otaliastudios.cameraview.VideoResult;
|
||||
import com.otaliastudios.cameraview.controls.Engine;
|
||||
import com.otaliastudios.cameraview.controls.Mode;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.UiSettings;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
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() {
|
||||
@Override
|
||||
public void onVideoTaken(@NonNull @NotNull VideoResult result) {
|
||||
super.onVideoTaken(result);
|
||||
Toast.makeText(PicturesActivity.this, "停止摄像", Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
// tencentMap = ivMap.getMap();
|
||||
//获取地图UI 设置对象
|
||||
// UiSettings uiSettings = tencentMap.getUiSettings();
|
||||
// //设置logo的大小
|
||||
// uiSettings.setLogoScale(0.7f);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
super.initData();
|
||||
}
|
||||
|
||||
|
||||
@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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
cameraView.open();
|
||||
// ivMap.onResume();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
cameraView.close();
|
||||
// ivMap.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
cameraView.destroy();
|
||||
// ivMap.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.bean.JobSearchBean;
|
||||
import com.navinfo.outdoor.util.SdkFolderCreate;
|
||||
import com.tencent.map.geolocation.TencentLocation;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
||||
|
||||
@@ -90,6 +91,7 @@ public class Constant {
|
||||
|
||||
|
||||
public static JobSearchBean jobSearchBean;//数据
|
||||
public static MapView treasureMap;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setScreenRoate(true);
|
||||
// setScreenRoate(true);
|
||||
//初始化,默认透明状态栏和黑色导航栏
|
||||
ImmersionBar.with(this).init();
|
||||
Collector.addActivity(this);
|
||||
|
||||
@@ -86,12 +86,12 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
private PoiDao poiDao;
|
||||
private PoiEntity showPoiEntity;
|
||||
private LatLng latLng;
|
||||
private int station_type=0;
|
||||
String[] spinner = new String[]{"存在","不存在","无法验证"};
|
||||
private int station_type = 0;
|
||||
String[] spinner = new String[]{"存在", "不存在", "无法验证"};
|
||||
private RelativeLayout linearExist;
|
||||
private Spinner spinnerExist;
|
||||
|
||||
private ArrayList<Object> otheruploadList;
|
||||
private ArrayList<File> otheruploadList;
|
||||
private String takePhotoPath;
|
||||
private String takePhotoPath2;
|
||||
|
||||
@@ -162,13 +162,13 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
station_type=6;
|
||||
station_type = 6;
|
||||
break;
|
||||
case 1:
|
||||
station_type=7;
|
||||
station_type = 7;
|
||||
break;
|
||||
case 2:
|
||||
station_type=8;
|
||||
station_type = 8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -244,7 +244,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
|
||||
if (showPoiEntity != null) {
|
||||
String name = showPoiEntity.getName();//名称
|
||||
if (name != null&&!name.equals("")) {
|
||||
if (name != null && !name.equals("")) {
|
||||
editTaskName.setText(name + "");
|
||||
}
|
||||
String x = showPoiEntity.getX();
|
||||
@@ -255,12 +255,12 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
latLng.setLatitude(Double.parseDouble(y));
|
||||
}
|
||||
String describe = showPoiEntity.getDescribe();//任务描述
|
||||
if (describe != null &&!describe.equals("")) {
|
||||
if (describe != null && !describe.equals("")) {
|
||||
editOtherDescribe.setText(describe);
|
||||
}
|
||||
linearExist.setVisibility(View.VISIBLE);
|
||||
int station_type = showPoiEntity.getStation_type();
|
||||
spinnerOther.setSelection(station_type,true);
|
||||
spinnerOther.setSelection(station_type, true);
|
||||
if (showPoiEntity.getPhotoInfo() != null) {
|
||||
for (int i = 0; i < showPoiEntity.getPhotoInfo().size(); i++) {
|
||||
String photo = showPoiEntity.getPhotoInfo().get(i).getPhoto();
|
||||
@@ -338,8 +338,8 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
} else {
|
||||
infoList.add(new Info(tagPictures));
|
||||
}
|
||||
if (showPoiEntity!=null){
|
||||
if (showPoiEntity.getTaskId()!=0){
|
||||
if (showPoiEntity != null) {
|
||||
if (showPoiEntity.getTaskId() != 0) {
|
||||
poiEntity.setTaskId(showPoiEntity.getTaskId());
|
||||
}
|
||||
}
|
||||
@@ -388,20 +388,42 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
otheruploadList = new ArrayList<>();
|
||||
File otherUploadFile = new File(takePhotoPath);
|
||||
File otherUploadFile2 = new File(takePhotoPath2);
|
||||
if (!otherUploadFile.exists() || !otherUploadFile2.exists()){
|
||||
if (!otherUploadFile.exists() || !otherUploadFile2.exists()) {
|
||||
Toast.makeText(getContext(), "照片不能为空", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
otheruploadList.add(otherUploadFile);
|
||||
otheruploadList.add(otherUploadFile2);
|
||||
OkGo
|
||||
// 请求方式和请求url
|
||||
.<NameAuthenticationBean>post(HttpInterface.USER_AUTH_ADD)
|
||||
// 请求的 tag, 主要用于取消对应的请求
|
||||
.params("userid", "1")
|
||||
.addFileParams("file", otheruploadList)
|
||||
.tag(this)
|
||||
.execute(new DialogCallback<NameAuthenticationBean>(NameAuthenticationBean.class) {
|
||||
@Override
|
||||
public void onSuccess(Response<NameAuthenticationBean> response) {
|
||||
dismissLoadingDialog();
|
||||
Log.d("TAG", "onSuccess: " + response.toString() + "sssssssssssss");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<NameAuthenticationBean> response) {
|
||||
super.onError(response);
|
||||
dismissLoadingDialog();
|
||||
Toast.makeText(getActivity(), response.message(), Toast.LENGTH_SHORT).show();
|
||||
Log.d("TAG", "onError: " + response.message());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void otherSaveByNetWork(PoiEntity poiEntity) {
|
||||
showLoadingDialog();
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("type",poiEntity.getStation_type());
|
||||
httpParams.put("type", poiEntity.getStation_type());
|
||||
httpParams.put("taskId", poiEntity.getTaskId());
|
||||
httpParams.put("name", poiEntity.getName());
|
||||
httpParams.put("existence", "1");
|
||||
@@ -459,15 +481,15 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
poiEntity.setDescribe(describe);
|
||||
}
|
||||
String tagPicture = (String) ivPicture.getTag();
|
||||
if (tagPicture != null &&!tagPicture.equals("")) {
|
||||
if (tagPicture != null && !tagPicture.equals("")) {
|
||||
arrayList.add(new Info(tagPicture));
|
||||
}
|
||||
String tagPictures = (String) ivPictures.getTag();
|
||||
if (tagPictures != null&&!tagPictures.equals("")) {
|
||||
if (tagPictures != null && !tagPictures.equals("")) {
|
||||
arrayList.add(new Info(tagPictures));
|
||||
}
|
||||
if (showPoiEntity!=null){
|
||||
if (showPoiEntity.getTaskId()!=0){
|
||||
if (showPoiEntity != null) {
|
||||
if (showPoiEntity.getTaskId() != 0) {
|
||||
poiEntity.setTaskId(showPoiEntity.getTaskId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,15 +40,19 @@ import com.kongzue.dialog.util.BaseDialog;
|
||||
import com.kongzue.dialog.util.DialogSettings;
|
||||
import com.kongzue.dialog.v3.MessageDialog;
|
||||
import com.kongzue.dialog.v3.ShareDialog;
|
||||
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.adapter.PoiRecycleAdapter;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseDrawerFragment;
|
||||
import com.navinfo.outdoor.bean.Info;
|
||||
import com.navinfo.outdoor.bean.NameAuthenticationBean;
|
||||
import com.navinfo.outdoor.bean.PoiBean;
|
||||
import com.navinfo.outdoor.bean.PoiSaveBean;
|
||||
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;
|
||||
@@ -62,6 +66,7 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -96,6 +101,13 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
String[] spinner = new String[]{"存在","不存在","无法验证"};
|
||||
private RelativeLayout linearExist;
|
||||
private Spinner spinnerExist;
|
||||
private ArrayList<File> poiUploadList;
|
||||
//获取的拍照图片
|
||||
private String takePhotoPath2;
|
||||
private String takePhotoPath5;
|
||||
private String takePhotoPath4;
|
||||
private String takePhotoPath3;
|
||||
private String takePhotoPath1;
|
||||
|
||||
public static PoiFragment newInstance(Bundle bundle) {
|
||||
PoiFragment fragment = new PoiFragment();
|
||||
@@ -464,6 +476,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
obtain.what = Constant.TREASURE_FRAGMENT;
|
||||
obtain.obj = false;
|
||||
EventBus.getDefault().post(obtain);
|
||||
poiUploadByNetWork();
|
||||
break;
|
||||
case R.id.tv_examine:
|
||||
Toast.makeText(getContext(), editNameContent.getText().toString(), Toast.LENGTH_SHORT).show();
|
||||
@@ -492,6 +505,47 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
}
|
||||
}
|
||||
|
||||
private void poiUploadByNetWork() {
|
||||
poiUploadList = new ArrayList<>();
|
||||
File poiUploadFile1 = new File(takePhotoPath1);
|
||||
File poiUploadFile2 = new File(takePhotoPath2);
|
||||
File poiUploadFile3 = new File(takePhotoPath3);
|
||||
File poiUploadFile4 = new File(takePhotoPath4);
|
||||
File poiUploadFile5 = new File(takePhotoPath5);
|
||||
if (!poiUploadFile1.exists()||!poiUploadFile2.exists()||!poiUploadFile3.exists()||!poiUploadFile4.exists()||!poiUploadFile5.exists()){
|
||||
Toast.makeText(getActivity(), "照片不能为空", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
poiUploadList.add(poiUploadFile1);
|
||||
poiUploadList.add(poiUploadFile2);
|
||||
poiUploadList.add(poiUploadFile3);
|
||||
poiUploadList.add(poiUploadFile4);
|
||||
poiUploadList.add(poiUploadFile5);
|
||||
OkGo
|
||||
// 请求方式和请求url
|
||||
.<NameAuthenticationBean>post(HttpInterface.USER_AUTH_ADD)
|
||||
// 请求的 tag, 主要用于取消对应的请求
|
||||
.params("auditId", "1")
|
||||
.addFileParams("file",poiUploadList)
|
||||
.tag(this)
|
||||
.execute(new DialogCallback<NameAuthenticationBean>(NameAuthenticationBean.class) {
|
||||
@Override
|
||||
public void onSuccess(Response<NameAuthenticationBean> response) {
|
||||
dismissLoadingDialog();
|
||||
Log.d("TAG", "onSuccess: " + response.toString() + "sssssssssssss");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<NameAuthenticationBean> response) {
|
||||
super.onError(response);
|
||||
dismissLoadingDialog();
|
||||
Toast.makeText(getActivity(), response.message(), Toast.LENGTH_SHORT).show();
|
||||
Log.d("TAG", "onError: " + response.message());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void poiSaveByNet(PoiEntity poiEntity) {
|
||||
showLoadingDialog();
|
||||
HttpParams httpParams = new HttpParams();
|
||||
@@ -631,8 +685,8 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
}
|
||||
});
|
||||
} else {
|
||||
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "a");
|
||||
ivPanorama.setTag(takePhotoPath);
|
||||
takePhotoPath1 = PhotoPathUtil.getTakePhotoPath(data, "a");
|
||||
ivPanorama.setTag(takePhotoPath1);
|
||||
ivPanorama.setImageBitmap(bitmap);//显示图像
|
||||
}
|
||||
|
||||
@@ -652,8 +706,8 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
}
|
||||
});
|
||||
} else {
|
||||
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "b");
|
||||
ivName.setTag(takePhotoPath);
|
||||
takePhotoPath2 = PhotoPathUtil.getTakePhotoPath(data, "b");
|
||||
ivName.setTag(takePhotoPath2);
|
||||
ivName.setImageBitmap(bitmap);//显示图像
|
||||
|
||||
}
|
||||
@@ -674,8 +728,8 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
}
|
||||
});
|
||||
} else {
|
||||
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "c");
|
||||
ivInternal.setTag(takePhotoPath);
|
||||
takePhotoPath3 = PhotoPathUtil.getTakePhotoPath(data, "c");
|
||||
ivInternal.setTag(takePhotoPath3);
|
||||
ivInternal.setImageBitmap(bitmap);//显示图像
|
||||
}
|
||||
} else if (requestCode == 104 && resultCode == RESULT_OK) {
|
||||
@@ -694,8 +748,8 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
}
|
||||
});
|
||||
} else {
|
||||
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "d");
|
||||
ivCard.setTag(takePhotoPath);
|
||||
takePhotoPath4 = PhotoPathUtil.getTakePhotoPath(data, "d");
|
||||
ivCard.setTag(takePhotoPath4);
|
||||
ivCard.setImageBitmap(bitmap);//显示图像
|
||||
}
|
||||
} else if (requestCode == 105 && resultCode == RESULT_OK) {
|
||||
@@ -714,8 +768,8 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
}
|
||||
});
|
||||
} else {
|
||||
String takePhotoPath = PhotoPathUtil.getTakePhotoPath(data, "e");
|
||||
ivElse.setTag(takePhotoPath);
|
||||
takePhotoPath5 = PhotoPathUtil.getTakePhotoPath(data, "e");
|
||||
ivElse.setTag(takePhotoPath5);
|
||||
ivElse.setImageBitmap(bitmap);//显示图像
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.hjq.permissions.Permission;
|
||||
import com.hjq.permissions.XXPermissions;
|
||||
import com.navinfo.outdoor.R;
|
||||
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.RoadExtend;
|
||||
@@ -286,7 +287,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
break;
|
||||
|
||||
case R.id.tv_pictures:
|
||||
Intent intent = new Intent(getContext(), PictureActivity.class);
|
||||
Intent intent = new Intent(getContext(), PicturesActivity.class);
|
||||
startActivity(intent);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.hjq.permissions.Permission;
|
||||
import com.hjq.permissions.XXPermissions;
|
||||
import com.navinfo.outdoor.R;
|
||||
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.PoiBean;
|
||||
@@ -293,7 +294,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
break;
|
||||
|
||||
case R.id.tv_pictures:
|
||||
Intent intent = new Intent(getContext(), PictureActivity.class);
|
||||
Intent intent = new Intent(getContext(), PicturesActivity.class);
|
||||
startActivity(intent);
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user