修改连拍间隔,修改拍照界面

This commit is contained in:
wangdongsheng 2021-09-09 18:33:23 +08:00
parent 6c39e1f13e
commit 30c374b2d9
13 changed files with 373 additions and 274 deletions

View File

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

View File

@ -47,7 +47,6 @@
android:supportsRtl="true"
android:theme="@style/Theme.WhiteScreen"
tools:targetApi="n">
<activity android:name=".activity.PoiPictureActivity"></activity>
<activity android:name=".activity.LinkActivity" />
<activity android:name=".activity.RegardMapActivity" />
<activity android:name=".activity.StatementActivity" />
@ -59,6 +58,8 @@
android:name=".activity.PictureActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|navigation"
android:launchMode="singleTop" />
<activity android:name=".activity.PhotographActivity"
android:screenOrientation="portrait" />
<meta-data
android:name="TencentMapSDK"

View File

@ -0,0 +1,156 @@
package com.navinfo.outdoor.activity;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Camera;
import android.graphics.Matrix;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
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.ImageView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
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.room.PoiEntity;
import com.navinfo.outdoor.util.AWMp4ParserHelper;
import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.MyTecentLocationSource;
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.controls.Mode;
import com.tencent.map.geolocation.TencentLocation;
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
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.interfaces.Removable;
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.Marker;
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle;
import com.tencent.tencentmap.mapsdk.maps.model.Polyline;
import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions;
import com.vividsolutions.jts.geom.Geometry;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Timer;
import java.util.TimerTask;
import static com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE;
import static com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER;
/**
* 照片对应
*/
public class PhotographActivity extends BaseActivity implements View.OnClickListener {
private CameraView cameraView;
private String photo_path;
@Override
public void onClick(View v) {
if (v.getId() == R.id.capture_picture) {
cameraView.takePicture();
}
}
@Override
protected int getLayout() {
EventBus.getDefault().register(this);
return R.layout.activity_photograph;
}
@Override
protected void initData() {
super.initData();
cameraView.setMode(Mode.PICTURE);
}
@Override
protected void initView() {
super.initView();
if (getIntent()!=null){
photo_path = getIntent().getStringExtra(Constant.INTENT_PHOTO_PATH);
}
cameraView = findViewById(R.id.camera);
cameraView.setOnClickListener(this);
Button btnCapturePicture = findViewById(R.id.capture_picture);
btnCapturePicture.setOnClickListener(this);
cameraView.addCameraListener(new CameraListener() {
@Override
public void onPictureTaken(@NonNull PictureResult result) {
super.onPictureTaken(result);
File file = new File(photo_path);
result.toFile(file, new FileCallback() {
@Override
public void onFileReady(@Nullable File file) {
Intent intent = new Intent();
assert file != null;
intent.putExtra("file",file.getPath());
setResult(0x104,intent);
finish();
}
});
}
});
}
@Subscribe
public void onEvent(Message data) { }
@Override
protected void onResume() {
super.onResume();
cameraView.open();
}
@Override
protected void onPause() {
super.onPause();
cameraView.close();
}
@Override
protected void onDestroy() {
super.onDestroy();
cameraView.destroy();
if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this);
}
}
}

View File

@ -68,6 +68,8 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Timer;
import java.util.TimerTask;
import static com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE;
import static com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER;
@ -75,8 +77,7 @@ import static com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle.LOCATION_
public class PicturesActivity extends BaseActivity implements View.OnClickListener {
private static final CameraLogger LOG = CameraLogger.create("Picture");
private CameraView camera;
private long captureTime = 0;
private android.widget.Button btnSwitch;
private Button btnSwitch;
private TencentMap tencentMap;
private TextureMapView ivMap;
private List<Removable> removables;
@ -86,32 +87,36 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
private ViewGroup layerChange; // 切换地图和相机的父控件
private CheckBox capturePicture, cbMapType;//拍照
private boolean isMapSlide = false;
private boolean listenerPicture = false;
/*
private boolean listenerPicture = false;
*/
private SimpleDateFormat formatter;
private File paperFile;
private int type, videoIndex;
private int type;
private ImageView ivZoomAdd, ivZoomDel, ivLocation;
private Handler handler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(@NonNull Message msg) {
if (msg.what == 0x101 && listenerPicture) {
if (msg.what == 0x101) {
camera.takePicture();
} else if (msg.what == 0x102) {
if (btnSwitch != null) {
// tencentMap.setBaseMapEnabled(true);
btnSwitch.setEnabled(true);
}
} else if (msg.what == 0x103) {
listenerPicture = false;
if (type != 3) {
capturePicture.setText("开始采集");
}
capturePicture.setChecked(false);
stopTimer();
}
return false;
}
});
private Timer timer;
private TimerTask timerTask;
private int videoIndex = -1;
@Override
protected int getLayout() {
@ -136,7 +141,6 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
formatter = new SimpleDateFormat("yyyyMMdd HHmmss");
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
ivMap = findViewById(R.id.iv_map);
ivMap.setOnClickListener(this::onClick);
btnSwitch = findViewById(R.id.btn_switch);
btnSwitch.setOnClickListener(this);
//相机记录器
@ -145,23 +149,24 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
ivZoomAdd.setOnClickListener(this);
ivZoomDel = findViewById(R.id.iv_zoom_del);
ivZoomDel.setOnClickListener(this);
// cbMapType =findViewById(R.id.cb_map_type);
// cbMapType.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
// @Override
// public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
// }
// });
/* cbMapType =findViewById(R.id.cb_map_type);
cbMapType.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
}
});*/
ivLocation = findViewById(R.id.iv_location);
ivLocation.setOnClickListener(this);
camera = findViewById(R.id.camera);
camera.setOnClickListener(this);
capturePicture = findViewById(R.id.capture_picture);
if (type == 3) {
capturePicture.setText("拍摄");
} else {
capturePicture.setText("开始采集");
}
capturePicture.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
/* capturePicture.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) { // 开始采集设置按钮文字内容为结束采集
@ -177,6 +182,22 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
}
}
}
});*/
capturePicture.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
if (type != 3) {
capturePicture.setText("暂停采集");
}
startTimer();
} else {
if (type != 3) {
capturePicture.setText("开始采集");
}
stopTimer();
}
}
});
Button stopPicture = findViewById(R.id.btn_stop_picture);
stopPicture.setOnClickListener(this);
@ -206,29 +227,32 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
}
}
}
tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() {
camera.addCameraListener(new CameraListener() {
@Override
public void onMapClick(LatLng latLng) {
btnSwitch.setEnabled(false);
handler.sendEmptyMessageDelayed(0x102, 2000);// 利用handler延迟发送更改状态信息
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
System.out.println("width-display :" + dm.widthPixels);
System.out.println("height-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();
if (heightMap<heightCamera){
benSwitch();
}
public void onPictureTaken(@NonNull PictureResult result) {
super.onPictureTaken(result);
File file = new File(finalVideoPath);
initMarkerPaper();
result.toFile(file, new FileCallback() {
@Override
public void onFileReady(@Nullable File file) {
assert file != null;
if (file.exists()) {
initMarker();
videoIndex = Integer.parseInt(file.getName().replace(".jpg", ""));
finalVideoPath = Objects.requireNonNull(file.getParentFile()).getAbsolutePath() + "/" + (videoIndex + 1) + ".jpg";
Toast.makeText(PicturesActivity.this, "保存成功:" + (videoIndex + 1), Toast.LENGTH_SHORT).show();
}
if (type==3){
Message message = new Message();
message.what = 0x103;
handler.sendMessage(message);
}
}
});
}
});
camera.addCameraListener(new CameraListener() {//相机预览监听
/* camera.addCameraListener(new CameraListener() {//相机预览监听
@Override
public void onPictureTaken(@NonNull @NotNull PictureResult result) {
if (listenerPicture) {
@ -249,10 +273,10 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
if (type == 3) {
message.what = 0x103;
handler.sendMessageDelayed(message, 0);
Toast.makeText(PicturesActivity.this, "保存成功:" + (videoIndex + 1), Toast.LENGTH_SHORT).show();
Toast.makeText(PicturesActivity.this, "保存成功:" + (videoIndex+1), Toast.LENGTH_SHORT).show();
} else {
message.what = 0x101;
Toast.makeText(PicturesActivity.this, "保存成功" + (videoIndex + 1), Toast.LENGTH_SHORT).show();
Toast.makeText(PicturesActivity.this, "保存成功" + (videoIndex+1), Toast.LENGTH_SHORT).show();
handler.sendMessageDelayed(message, 1500);
}
}
@ -266,7 +290,6 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
Log.d("captureTime", captureTime + "");
}
}
//录像监听
@Override
public void onVideoTaken(@NonNull @NotNull VideoResult result) {
@ -284,37 +307,13 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
public void onVideoRecordingStart() {
super.onVideoRecordingStart();
}
});
});*/
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);
//相机监听
camera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
benSwitch();
Toast.makeText(PicturesActivity.this, "dianjile1", Toast.LENGTH_SHORT).show();
// btnSwitch.setEnabled(false);
// handler.sendEmptyMessageDelayed(0x102, 2000);// 利用handler延迟发送更改状态信息
// DisplayMetrics dm = new DisplayMetrics();
// getWindowManager().getDefaultDisplay().getMetrics(dm);
// System.out.println("width-display :" + dm.widthPixels);
// System.out.println("height-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();
// if (heightMap>heightCamera){
// benSwitch();
// }
}
});
}
private void message(String content) {
@ -363,7 +362,9 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_stop_picture:
/*
listenerPicture = false;
*/
Intent intent = new Intent();
finalVideoPath = Objects.requireNonNull(paperFile.getParentFile()).getAbsolutePath() + "/" + videoIndex + ".jpg";
intent.putExtra(Constant.INTENT_PICTURES_PATH, finalVideoPath);
@ -372,9 +373,9 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
finish();
break;
case R.id.btn_switch:
// v.setEnabled(false);
// handler.sendEmptyMessageDelayed(0x102, 2000);// 利用handler延迟发送更改状态信息
// benSwitch();
v.setEnabled(false);
handler.sendEmptyMessageDelayed(0x102, 2000);// 利用handler延迟发送更改状态信息
benSwitch();
break;
case R.id.iv_zoom_add://放大
CameraUpdate cameraUpdateIn = CameraUpdateFactory.zoomIn();
@ -395,8 +396,6 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
tencentMap.animateCamera(cameraSigma);
}
break;
}
}
@ -473,7 +472,6 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
isMapSlide = false;
ivZoomAdd.setVisibility(View.GONE);
ivZoomDel.setVisibility(View.GONE);
ivLocation.setVisibility(View.GONE);
setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE);
@ -517,19 +515,20 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
protected void onPause() {
super.onPause();
camera.close();
if (type != 3) {
listenerPicture = false;
}
stopTimer();
}
@Override
protected void onDestroy() {
super.onDestroy();
camera.destroy();
stopTimer();
if (polyline != null) {
polyline.remove();
}
/*
listenerPicture = false;
*/
for (int i = 0; i < removables.size(); i++) {
removables.get(i).remove();
}
@ -559,7 +558,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
StringBuilder sb = new StringBuilder();
sb.append(formatter.format(new Date())); // 记录当前时
sb.append(",");
sb.append(videoIndex);//個數
sb.append(videoIndex == -1 ? 0 : (videoIndex + 1));//個數
sb.append(",");
sb.append(Constant.currentLocation.getLatitude());
sb.append(",");
@ -571,13 +570,51 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
sb.append(Constant.currentLocation.getDirection());
}
sb.append("\r\n");
FileUtils.writeFile(paperFile.getAbsolutePath(), sb.toString(), true);
}
public void initMarker() {
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);
}
private void startTimer() {
if (timer == null) {
timer = new Timer();
}
timerTask = new TimerTask() {
@Override
public void run() {
if (type == 3) {
camera.takePicture();
} else {
Message message = new Message();
message.what = 0x101;
handler.sendMessage(message);
}
}
};
if (type==3){
timer.schedule(timerTask, 0);
}else {
timer.schedule(timerTask, 0, 2000);
}
}
private void stopTimer() {
if (timer != null) {
timer.cancel();
timer = null;
}
if (timerTask != null) {
timerTask.cancel();
timerTask = null;
}
}
}

View File

@ -1,103 +0,0 @@
package com.navinfo.outdoor.activity;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Toast;
import com.navinfo.outdoor.R;
import com.navinfo.outdoor.base.BaseActivity;
import com.otaliastudios.cameraview.CameraException;
import com.otaliastudios.cameraview.CameraListener;
import com.otaliastudios.cameraview.CameraView;
import com.otaliastudios.cameraview.FileCallback;
import com.otaliastudios.cameraview.PictureResult;
import com.otaliastudios.cameraview.VideoResult;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.Objects;
public class PoiPictureActivity extends BaseActivity implements View.OnClickListener {
private CameraView poiPictureCamera;
private android.widget.CheckBox capturePoiPicture;
private android.widget.Button btnStopPoiPicture;
@Override
protected int getLayout() {
return R.layout.activity_poi_picture;
}
@Override
protected void initView() {
super.initView();
poiPictureCamera = (CameraView) findViewById(R.id.poi_picture_camera);
capturePoiPicture = (CheckBox) findViewById(R.id.capture_poi_picture);
capturePoiPicture.setOnClickListener(this::onClick);
btnStopPoiPicture = (Button) findViewById(R.id.btn_stop_poi_picture);
btnStopPoiPicture.setOnClickListener(this::onClick);
poiPictureCamera.setLifecycleOwner(this);
poiPictureCamera.addCameraListener(new CameraListener() {//相机预览监听
@Override
public void onPictureTaken(@NonNull @NotNull PictureResult result) {
}
@Override
public void onCameraError(@NonNull @NotNull CameraException exception) {
super.onCameraError(exception);
Toast.makeText(PoiPictureActivity.this, exception.toString(), Toast.LENGTH_SHORT).show();
}
});
}
@Override
protected void initData() {
super.initData();
poiPictureCamera.takePicture();
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.capture_poi_picture:
break;
case R.id.btn_stop_poi_picture:
break;
}
}
@Override
protected void onResume() {
super.onResume();
poiPictureCamera.open();
}
@Override
protected void onPause() {
super.onPause();
poiPictureCamera.close();
}
@Override
protected void onDestroy() {
super.onDestroy();
poiPictureCamera.destroy();
}
}

View File

@ -176,7 +176,8 @@ 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_JPG_PATH = "INTENT_JPG_PATH"; // 拍照界面指定的图片保存位置
public static final String INTENT_PHOTO_PATH = "INTENT_PHOTO_PATH"; // 拍照界面指定的图片保存位置
public static final String INTENT_PICTURES_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置
public static final String INTENT_VIDEO_OBLATION = "INTENT_VIDEO_OBLATION"; // 视频拍摄时屏幕方向 0-强制横屏 其他-任意

View File

@ -43,6 +43,7 @@ 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.PhotographActivity;
import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.bean.Info;
@ -59,6 +60,7 @@ import com.navinfo.outdoor.room.InsertAndUpdateUtils;
import com.navinfo.outdoor.room.PoiDao;
import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.AWMp4ParserHelper;
import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.PhotoUtils;
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
@ -102,7 +104,6 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
private int station_type = 5;
private ArrayList<File> otherUploadList;
private CheckBox checkPot;
private File file;
private Marker markerOther;
private Point screenOtherPositions;
@ -192,7 +193,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
checkPot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(checkPot.isChecked()){
if (checkPot.isChecked()) {
moveLatlng(latLng, new TencentMap.CancelableCallback() {
@Override
public void onFinish() {
@ -217,7 +218,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
checkPot.setChecked(false);
}
});
}else {
} else {
BitmapDescriptor otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_bag);
markerOther.setIcon(otherDescriptor);
checkPot.setText("编辑");
@ -326,7 +327,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
latLng.setLongitude(Double.parseDouble(x));
latLng.setLatitude(Double.parseDouble(y));
BitmapDescriptor otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_bag);
markerOther = tencentMap.addMarker(new MarkerOptions(latLng).icon(otherDescriptor) .anchor(0.5f,1.0f));
markerOther = tencentMap.addMarker(new MarkerOptions(latLng).icon(otherDescriptor).anchor(0.5f, 1.0f));
markerOther.setZIndex(4);
moveLatlng(latLng, null);
}
@ -367,15 +368,15 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
public void onClick(View v) {
switch (v.getId()) {
case R.id.rl_picture:
Intent intentPicture = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("a", latLng);
intentPicture.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
Intent intentPicture = new Intent(getActivity(), PhotographActivity.class);
File file = PhotoUtils.showPhotoFile("a", latLng);
intentPicture.putExtra(Constant.INTENT_PHOTO_PATH, file.getPath());
startActivityForResult(intentPicture, 101);
break;
case R.id.rl_pictures:
Intent intentPictures = new Intent("android.media.action.IMAGE_CAPTURE");
file = PhotoUtils.showPhotoFile("b", latLng);
intentPictures.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
Intent intentPictures = new Intent(getActivity(), PhotographActivity.class);
File files = PhotoUtils.showPhotoFile("b", latLng);
intentPictures.putExtra(Constant.INTENT_PHOTO_PATH, files.getPath());
startActivityForResult(intentPictures, 102);
break;
case R.id.btn_other_local:
@ -467,7 +468,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
}
}
@Override
@Override
public void onDenied(List<String> permissions, boolean never) {
if (never) {
Toast.makeText(getActivity(), "被永久拒绝授权,请手动授予权限", Toast.LENGTH_SHORT).show();
@ -587,8 +588,6 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
} else {
Toast.makeText(getActivity(), "" + poiSaveBean.getMessage(), Toast.LENGTH_SHORT).show();
}
}
@Override
@ -614,7 +613,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
//表示文件名系统将会在/dada/dada/包名/shared_prefs目录下生成
//一个以该参数命名的.xml文件第二个mode表示创建的模式通过查看
//方法注释得知建议以0或者MODE_PRIVATE为默认值
SharedPreferences poi = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
SharedPreferences poi = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0);
//获取Editor对象
SharedPreferences.Editor edit = poi.edit();
//根据要保存的数据的类型调用对应的put方法,
@ -623,14 +622,37 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
//以键值对的形式添加新值
edit.putString("poiEntity", newPoiEntity);
//提交新值必须执行否则前面的操作都无效
edit.commit();
edit.apply();
Log.d("TAG", "initPoiSharePre: " + newPoiEntity);
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 101 && resultCode == RESULT_OK) {
if (resultCode == 0x104) {
if (requestCode == 101) {
assert data != null;
String file = data.getStringExtra("file");
assert file != null;
File videoFile = new File(file);
if (videoFile.exists()) {
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPicture, 500);
String andGetPath = PhotoUtils.showPhotoAndGetPath(videoFile, ivPicture);
tvPicture.setTag(andGetPath);
}
} else if (requestCode == 102) {
assert data != null;
String file = data.getStringExtra("file");
assert file != null;
File videoFile = new File(file);
if (videoFile.exists()) {
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPictures, 500);
String andGetPath = PhotoUtils.showPhotoAndGetPath(videoFile, ivPictures);
tvPictures.setTag(andGetPath);
}
}
}
/* if (requestCode == 101 && resultCode == RESULT_OK) {
if (file == null || !file.exists()) {
Toast.makeText(getActivity(), "没有拍摄照片", Toast.LENGTH_SHORT).show();
return;
@ -650,23 +672,24 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
tvPictures.setTag(s);
}
file = null;
}
}*/
}
@Override
public void onDestroyView() {
super.onDestroyView();
if (showPoiEntity != null) {
if (showPoiEntity.getTaskStatus() == 5) {
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);
}else {
} else {
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
}
}
}
@Override
public void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断
@ -676,7 +699,8 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
markerOther.remove();
}
}
private void initEndReceiveTask(String url,PoiEntity poiEntity) {
private void initEndReceiveTask(String url, PoiEntity poiEntity) {
if (poiEntity.getTaskId() == 0) {
Toast.makeText(getActivity(), "无此任务", Toast.LENGTH_SHORT).show();
return;

View File

@ -73,6 +73,7 @@ import java.util.Objects;
*/
public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClickListener {
private TextView tvPictures;
private EditText etRoadName;
private ImageView ivPoiVideoPicture;
@ -147,39 +148,37 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
super.initView();
PoiDatabase poiDatabase = PoiDatabase.getInstance(getContext());
poiDao = poiDatabase.getPoiDao();
tvPictures = (TextView) findViewById(R.id.tv_pictures);//拍照
tvPictures = findViewById(R.id.tv_pictures);//拍照
tvPictures.setOnClickListener(this);
tvPicture = (TextView) findViewById(R.id.tv_picture);//录像
tvPicture = findViewById(R.id.tv_picture);//录像
tvPicture.setOnClickListener(this);
setSlidingUpPanelLayout(Constant.SLIDING_LAYOUT);
NestedScrollView nestedScrollView = findViewById(R.id.nested_scroll_view);
if (slidingPaneLayout != null) {
slidingPaneLayout.setScrollableView(nestedScrollView);
}
etRoadName = (EditText) findViewById(R.id.et_poi_video_name);
ivPoiVideoPicture = (ImageView) findViewById(R.id.iv_poi_video_picture);
etDesc = (EditText) findViewById(R.id.et_desc);
etRoadName = findViewById(R.id.et_poi_video_name);
ivPoiVideoPicture = findViewById(R.id.iv_poi_video_picture);
etDesc = findViewById(R.id.et_desc);
fmPoiVideoPic = findViewById(R.id.fm_poi_video_picture);
btnRoadSave = (Button) findViewById(R.id.btn_poi_video_save);
btnRoadSave = findViewById(R.id.btn_poi_video_save);
btnRoadSave.setOnClickListener(this);
Button btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
btnPoiVideoUpload.setOnClickListener(this);
rgType = (RadioGroup) findViewById(R.id.rg_type);
rgType = findViewById(R.id.rg_type);
rbCar = findViewById(R.id.rb_car);
rbBicycle = findViewById(R.id.rb_bicycle);
rbWalking = findViewById(R.id.rb_walking);
rbManual = findViewById(R.id.rb_manual);
tvPhotoAlbum = findViewById(R.id.tv_photo_album);
tvPhotoAlbum.setOnClickListener(this);
/*fmRoadPic.setOnClickListener(new View.OnClickListener() {
/*fmRoadPic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (v.getTag() == null || ((List<File>) v.getTag()).size() == 0) {
Toast.makeText(getActivity(), "还没有拍摄视频!", Toast.LENGTH_SHORT).show();
return;
}
File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
Intent intent = new Intent(getContext(), PictureActivity.class);
intent.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath());
@ -188,11 +187,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
startActivityForResult(intent, 0x101);
}
});*/
rgType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.rb_car:
case R.id.rb_bicycle:
@ -515,7 +512,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
Toast.makeText(getActivity(), "没有申请权限,请手动申请", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onDenied(List<String> permissions, boolean never) {
if (never) {
@ -668,13 +664,11 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} else if (requestCode == 0x102 && resultCode == 0x102) {
tvPicture.setEnabled(false);
isRequest = 0x102;
if (data != null && data.hasExtra(Constant.INTENT_PICTURES_PATH)) {
int type = data.getIntExtra("type", 0);
if (type == 3) {
showWorkType(type);
}
String videoPath = data.getStringExtra(Constant.INTENT_PICTURES_PATH);
assert videoPath != null;
File pictureFile = new File(videoPath);
@ -692,7 +686,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
super.onSaveInstanceState(outState);
initPoiVideoSharePre();
}
/**
* 防止程序崩溃后数据丢失
*/
@ -714,7 +707,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
Log.d("TAG", "initRoadSharePre: " + newPoiEntity);
}
//获取拍照类型
private int getPictureType() {
if (rbCar != null && rbCar.isChecked()) {
@ -743,7 +735,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
case 3:
rbManual.setChecked(true);
break;
}
}

View File

@ -3,9 +3,9 @@ package com.navinfo.outdoor.http;
import com.navinfo.outdoor.api.Constant;
public class HttpInterface {
public static final String IP_TEST = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
public static final String DATA_IP = "http://172.23.139.4:9999/m4";//接口
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb_test/m4";//测试接口
public static final String IP_TASK = "http://dtxbmaps.navinfo.com/dtxb_test/m4";//测试接口
public static final String TEST_GUIDANCE_IP = "http://172.21.98.90:9999/m4";//引导页完成接口
public static final String APKIP = "http://172.23.139.4:8001/";

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF444444">
<com.otaliastudios.cameraview.CameraView
android:id="@+id/camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
app:cameraPictureSizeAspectRatio="1920:1080"
app:cameraVideoSizeMaxArea="3686400"
app:cameraVideoSizeMaxHeight="1920"
app:cameraVideoSizeMaxWidth="1920"
app:cameraVideoSizeMinArea="1166400"
app:cameraVideoSizeMinHeight="1080"
app:cameraVideoSizeMinWidth="1080"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/capture_picture"
style="@style/user_data_style"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/user_style"
android:gravity="center"
android:padding="@dimen/fab_margin"
android:text="拍照"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -16,11 +16,12 @@
android:id="@+id/camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cameraPictureSizeMaxArea="3200000"
app:cameraPictureSizeMaxHeight="2000"
app:cameraPictureSizeMinHeight="1000"
app:cameraPictureSizeMaxWidth="2000"
app:cameraPictureSizeMinWidth="1000"
app:cameraVideoSizeMaxArea="3686400"
app:cameraVideoSizeMinArea="1166400"
app:cameraVideoSizeMaxHeight="1920"
app:cameraVideoSizeMinHeight="1080"
app:cameraVideoSizeMaxWidth="1920"
app:cameraVideoSizeMinWidth="1080"
app:cameraPictureSizeAspectRatio="1920:1080"
android:keepScreenOn="true"
app:layout_constraintBottom_toBottomOf="parent"
@ -90,7 +91,6 @@
android:layout_marginTop="20dp"
android:layout_marginEnd="25dp"
android:text="切换"
android:visibility="gone"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

View File

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.PoiPictureActivity">
<com.otaliastudios.cameraview.CameraView
android:id="@+id/poi_picture_camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cameraPictureSizeMaxArea="3200000"
app:cameraPictureSizeMaxHeight="2000"
app:cameraPictureSizeMinHeight="1000"
app:cameraPictureSizeMaxWidth="2000"
app:cameraPictureSizeMinWidth="1000"
app:cameraPictureSizeAspectRatio="1920:1080"
android:keepScreenOn="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
android:id="@+id/capture_poi_picture"
style="@style/user_data_style"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/user_style"
android:button="@null"
android:gravity="center"
android:padding="@dimen/fab_margin"
android:text="开始采集"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/btn_stop_poi_picture" />
<Button
android:id="@+id/btn_stop_poi_picture"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:background="@drawable/uploding_shape"
android:text="结束采集"
android:textColor="@color/colorBlue"
app:layout_constraintBottom_toBottomOf="@id/capture_poi_picture"
app:layout_constraintLeft_toRightOf="@id/capture_poi_picture"
app:layout_constraintRight_toRightOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -29,8 +29,8 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
google()
mavenCentral()
maven { url 'https://jitpack.io' }
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}