feat: 增加交通枢纽、区域设施和建筑物内部POI类型

This commit is contained in:
xiaoyan 2022-12-09 15:45:28 +08:00
parent 2f5c8464b6
commit c56322abb9
14 changed files with 3348 additions and 3 deletions

View File

@ -10,7 +10,7 @@ android {
defaultConfig {
applicationId "com.navinfo.outdoor"
minSdkVersion 23
minSdkVersion 24
targetSdkVersion 30
versionCode 36
versionName "8.221207"

View File

@ -111,6 +111,8 @@ public class HomeActivity extends BaseActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
DialogSettings.init();
if (Constant.USHERED != null) {
Constant.initRootFolder(Constant.USHERED);
// 检测用户是否为虚拟定位

View File

@ -138,6 +138,7 @@ public abstract class BaseDrawerFragment extends BaseFragment {
//以键值对的形式添加新值
edit.putString("poiEntity", null);
edit.putString("chargingPileEntity", null);
edit.putInt("roadVideoType", -1);
//提交新值必须执行否则前面的操作都无效
edit.commit();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,940 @@
package com.navinfo.outdoor.fragment;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
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.google.gson.Gson;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
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.kongzue.dialog.v3.WaitDialog;
import com.lzy.okgo.model.HttpParams;
import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.FragmentManagement;
import com.navinfo.outdoor.activity.PicturesActivity;
import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.bean.PoiVideoBean;
import com.navinfo.outdoor.bean.UnPolygonTaskBean;
import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.room.ChargingPileEntity;
import com.navinfo.outdoor.room.InsertAndUpdateUtils;
import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.ui.view.SpinnerUtils;
import com.navinfo.outdoor.util.AWMp4ParserHelper;
import com.navinfo.outdoor.util.DataSaveUtils;
import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.PoiSaveUtils;
import com.navinfo.outdoor.util.PreserveUtils;
import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtils;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
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 org.locationtech.jts.geom.Geometry;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* 寻宝-上报弹窗-建筑物内部
*/
public class BuildingInsideFragment extends BaseDrawerFragment implements View.OnClickListener {
private EditText etDesc;
private Spinner spnRoadName;
private ImageView ivPoiVideoPicture;
private Button btnRoadSave;
private File fileZip, logFile;
private FrameLayout fmPoiVideoPic;
private LatLng latLng;
private Marker markerPoiVideo;
private TextView tvCombo, tvShort;
private StringBuilder poiVideoBuilder;
private LatLng rearLatLng;
private boolean booleanExtra = true;
public static BuildingInsideFragment newInstance(Bundle bundle) {
BuildingInsideFragment fragment = new BuildingInsideFragment();
fragment.setArguments(bundle);
return fragment;
}
@Override
protected int getLayout() {
return R.layout.traffic_hub_fragment;
}
@Override
public void onStart() {
super.onStart();
if (!EventBus.getDefault().isRegistered(this)) {//加上判断
EventBus.getDefault().register(this);
}
}
@Override
public void onResume() {
super.onResume();
View header = mView.findViewById(R.id.traffic_hub_header);
header.findViewById(R.id.iv_final).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
initBack();
}
});
header.findViewById(R.id.tv_explain).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), FragmentManagement.class);
intent.putExtra("tag", 8);
startActivity(intent);
}
});
moveLatlng(latLng, null);
}
@Override
public boolean onBackPressed() {
initBack();
return true;
}
private void initBack() {
if (showPoiEntity != null) {
if (showPoiEntity.getTaskStatus() == 5) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
return false;
}
});
} else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
if (showPoiEntity != null) {
if (showPoiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
File filePath = AWMp4ParserHelper.getInstance().getFilePath(showPoiEntity.getId());
filePath.delete();
}
}
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
Bundle arguments = getArguments();
if (arguments != null) {
isSliding = arguments.getBoolean("isSliding", true);
}
if (isSliding) {
Message obtain1 = Message.obtain();
obtain1.what = Constant.TREASURE_FRAGMENT;
obtain1.obj = isSliding;
EventBus.getDefault().post(obtain1);
}
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
return false;
}
});
} else {
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
Bundle arguments = getArguments();
if (arguments != null) {
isSliding = arguments.getBoolean("isSliding", true);
}
if (isSliding) {
Message obtain1 = Message.obtain();
obtain1.what = Constant.TREASURE_FRAGMENT;
obtain1.obj = isSliding;
EventBus.getDefault().post(obtain1);
}
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
}
}
}
@Override
protected void initView() {
super.initView();
setSlidingUpPanelLayout(Constant.SLIDING_LAYOUT);
NestedScrollView nestedScrollView = findViewById(R.id.nested_scroll_view);
if (slidingPaneLayout != null) {
slidingPaneLayout.setScrollableView(nestedScrollView);
}
spnRoadName = findViewById(R.id.spn_poi_video_name);
ivPoiVideoPicture = findViewById(R.id.iv_poi_video_picture);
etDesc = findViewById(R.id.et_desc);
//点击拍照
tvShort = findViewById(R.id.tv_short);
tvShort.setOnClickListener(this);
//自动连拍
tvCombo = findViewById(R.id.tv_combo);
tvCombo.setOnClickListener(this);
fmPoiVideoPic = findViewById(R.id.fm_poi_video_picture);
fmPoiVideoPic.setOnClickListener(this);
fmPoiVideoPic.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了长按删除图片的 按钮,");
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
ivPoiVideoPicture.setImageDrawable(null);
fmPoiVideoPic.setTag(null);
return false;
}
});
return false;
}
});
btnRoadSave = findViewById(R.id.btn_poi_video_save);
btnRoadSave.setOnClickListener(this);
Button btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
btnPoiVideoUpload.setOnClickListener(this);
//添加数据
initShowPoi();
((TextView)findViewById(R.id.tv1)).setText("建筑物内部");
}
@Override
protected void initData() {
super.initData();
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
@SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String newFormat = formatter.format(new Date(System.currentTimeMillis()));
String pictures_time = sharedPreferences.getString("pictures_time", null);
if (pictures_time == null) {
sharedEdit.putString("pictures_time", newFormat);
sharedEdit.apply();
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
} else {
if (pictures_time.equals(newFormat)) {
logFile = new File(Constant.LOG_FOLDER + "/" + pictures_time + ".txt");
} else {
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
}
}
poiVideoBuilder = new StringBuilder();
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("PoiVideoActivity-onCreate-initData ,");
if (Constant.USHERED != null) {
poiVideoBuilder.append("userId:").append(Constant.USHERED).append(",");
}
}
private void initShowPoi() {
// 添加信息
assert getArguments() != null;
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
if (showPoiEntity != null) {
String name = showPoiEntity.getName();//名称
SpinnerUtils spinnerUtils = new SpinnerUtils();
String[] items = {"园区外围(含门)", "园区引导图", "园区底商"};
if (StringUtils.isEmpty(name)) {// 如果从数据获取的名称为空则设置name显示为默认的第一个选项
name = items[0];
}
spinnerUtils.initSpinner(getActivity(), spnRoadName, new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
spnRoadName.setTag(items[position]);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
}, name, items);
String geoWkt = showPoiEntity.getGeoWkt();
if (geoWkt != null) {
String geo = Geohash.getInstance().decode(geoWkt);
Geometry geometry = GeometryTools.createGeometry(geo);
switch (geometry.getGeometryType()) {
case "Point": //
latLng = GeometryTools.createLatLng(geo);
break;
case "LineString": //线
case "Polygon": //
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
assert latLineString != null;
latLng = latLineString.get(0);//起點
rearLatLng = latLineString.get(latLineString.size() - 1);//終點
break;
}
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
markerPoiVideo.setZIndex(4);
moveLatlng(latLng, null);
} else {
String detail = showPoiEntity.getDetail();
if (detail != null) {
String geo = Geohash.getInstance().decode(detail);
Geometry geometry = GeometryTools.createGeometry(geo);
switch (geometry.getGeometryType()) {
case "Point": //
latLng = GeometryTools.createLatLng(geo);
break;
case "LineString": //线
case "Polygon": //
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
assert latLineString != null;
latLng = latLineString.get(0);
break;
}
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
markerPoiVideo.setZIndex(4);
moveLatlng(latLng, null);
} else {
String x = showPoiEntity.getX();
String y = showPoiEntity.getY();
if (x != null && y != null) {
latLng = new LatLng();
latLng.setLongitude(Double.parseDouble(x));
latLng.setLatitude(Double.parseDouble(y));
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
markerPoiVideo.setZIndex(4);
moveLatlng(latLng, null);
}
}
}
String memo = showPoiEntity.getMemo();//任务描述
if (memo != null && !memo.equals("")) {
etDesc.setText(memo);
}
showPoiEntity.setType(3);
String photoList = showPoiEntity.getPhoto();
if (!StringUtils.isEmpty(photoList)) {
boolean isImageLoad = false;
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
if (fileListByUUID.get(i).getPath().contains(".webp") && !fileListByUUID.get(i).getPath().contains("paper.txt")) {
if (fileListByUUID.get(i).exists() && !isImageLoad) {
// 使用glide加载视频的第一帧
Glide.with(Objects.requireNonNull(getActivity())).load(fileListByUUID.get(i)).into(ivPoiVideoPicture);
isImageLoad = true;
}
}
}
fmPoiVideoPic.setTag(fileListByUUID);
}
if (showPoiEntity.getTaskStatus() == 3) {
disables();//禁用所有可操作的控件
}
// 如果是推送的POI录像不允许修改名称
if (showPoiEntity.getTaskId()>0) {
spnRoadName.setEnabled(false);
}
}
}
private void disables() {
spnRoadName.setEnabled(false);
ivPoiVideoPicture.setEnabled(false);
tvShort.setEnabled(false);
tvCombo.setEnabled(false);
etDesc.setEnabled(false);
btnRoadSave.setEnabled(false);
}
@Subscribe
public void onEvent(Message data) {
if (data.what == Constant.PICTURE_VIDEO_WORD) {
if ((boolean) data.obj) {
initPoiVideoSharePre();
}
} else if (data.what == Constant.PHOTO_FINISH_VIDEO) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID.size() == 1) {
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
ivPoiVideoPicture.setImageDrawable(null);
fmPoiVideoPic.setTag(null);
} else {
boolean isImageLoad = false;
for (int i = 0; i < fileListByUUID.size(); i++) {
File videoFile = fileListByUUID.get(i);
if (videoFile.getPath().contains(".webp") && !videoFile.getPath().contains("paper.txt")) {
if (videoFile.exists() && !isImageLoad) {
// 使用glide加载视频的第一帧
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
isImageLoad = true;
}
}
}
fmPoiVideoPic.setTag(fileListByUUID);
}
initPoiVideoSharePre();
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.fm_poi_video_picture:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了图片查看列表 ,");
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID.size() > 1) {
Intent photoAlbumIntent = new Intent(getActivity(), FragmentManagement.class);
photoAlbumIntent.putExtra("tag", 36);
photoAlbumIntent.putExtra("showPoiEntity", showPoiEntity);
startActivity(photoAlbumIntent);
} else {
ToastUtils.Message(getActivity(), "请拍摄");
}
break;
case R.id.btn_poi_video_save:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了保存本地的按钮 ,");
initPoiSaveLocal(false);
break;
case R.id.tv_short://点击拍摄
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了拍摄的按钮 ,");
double latitude = Constant.currentLocation.getLatitude();
double longitude = Constant.currentLocation.getLongitude();
LatLng startLatLng = new LatLng(latitude, longitude);// 用户当前位置
double geometry = GeometryTools.distanceToDouble(startLatLng, latLng);// 起點 于用戶的距離
double rearGeometry = GeometryTools.distanceToDouble(startLatLng, rearLatLng);// 終點于用戶的距離
if (geometry > rearGeometry) {//用戶在终点开始作业
if (rearGeometry > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
} else {//用户在起点开始作业
if (geometry > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
}
Intent intents = new Intent(getActivity(), PicturesActivity.class);
File filePath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intents.putExtra(Constant.INTENT_JPG_PATH, filePath.getAbsolutePath());
intents.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
intents.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
intents.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
int gpsRssi = Constant.currentLocation.getGPSRssi();
if (gpsRssi == 0) {
intents.putExtra(Constant.INTENT_BOOLEAN, false);
} else {
intents.putExtra(Constant.INTENT_BOOLEAN, true);
}
startActivityForResult(intents, 0x101);
break;
case R.id.tv_combo://自动连拍:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了自动连拍的按钮 ,");
LatLng startLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); //用户当前位置
double geom = GeometryTools.distanceToDouble(startLng, latLng);
double rearGeom = GeometryTools.distanceToDouble(startLng, rearLatLng);
if (geom > rearGeom) {//用戶在终点开始作业
if (rearGeom > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
} else {//用户在起点开始作业
if (geom > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
}
Intent intent = new Intent(getActivity(), PicturesActivity.class);
File fileJpgPath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intent.putExtra(Constant.INTENT_JPG_PATH, fileJpgPath.getAbsolutePath());
intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
int gpsRss = Constant.currentLocation.getGPSRssi();
if (gpsRss == 0) {
intent.putExtra(Constant.INTENT_BOOLEAN, false);
} else {
intent.putExtra(Constant.INTENT_BOOLEAN, true);
}
startActivityForResult(intent, 0x102);
break;
case R.id.btn_poi_video_upload:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了上传的按钮 ,");
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
if (poiEntity.getTaskStatus() == 1 || poiEntity.getTaskStatus() == 2 || poiEntity.getTaskStatus() == 0 || poiEntity.getTaskStatus() == 5) {
initPoiSaveLocal(true);
} else {
poiVideoUpload(poiEntity);
Constant.isPresent = false;
}
break;
}
}
public void initPoiSaveLocal(boolean isLocal) {
if (spnRoadName.getTag() == null) {
com.github.lazylibrary.util.ToastUtils.showToast(getActivity(), "没有POI名称无法保存");
return;
}
XXPermissions.with(getContext())
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
if (all) {
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
if (poiEntity.getPhoto() == null||poiEntity.getPhoto().isEmpty()) {
Toast.makeText(getActivity(), "POI录像任务必须拍照", Toast.LENGTH_LONG).show();
return;
}
PoiCheckResult poiCheckResult = checkPoiEntity(poiEntity);
if (poiCheckResult.getCode() == 1) {
ToastUtils.Message(getActivity(), poiCheckResult.getMsg());
return;
}
poiEntity.setTaskStatus(2);
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (isLocal) {
poiVideoSave(poiEntity);
} else {
poiVideoSaveNet(poiEntity);
}
}
});
}
}
}).start();
} else {
ToastUtils.Message(getActivity(), "没有申请权限,请手动申请");
}
}
@Override
public void onDenied(List<String> permissions, boolean never) {
if (never) {
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
// 如果是被永久拒绝就跳转到应用权限系统设置页面
XXPermissions.startPermissionActivity(Objects.requireNonNull(getActivity()), permissions);
}
}
});
}
private void poiVideoSaveNet(PoiEntity poiEntity) {
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", 1);
httpParams.put("memo", poiEntity.getMemo());
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30)
.Builder(getActivity())
.url(HttpInterface.INSIDE_API_LIST)
.cls(PoiVideoBean.class)
.params(httpParams)
.token(Constant.ACCESS_TOKEN);
if (getActivity() != null) {
okGoBuilder.getRequest(PreserveUtils.getInstance().getPoiVideoPreserveCallback(getActivity(), poiEntity));
getActivity().getSupportFragmentManager().popBackStack();//回退
WaitDialog.show((AppCompatActivity) getActivity(), "任务已保存本地,请稍后");
WaitDialog.dismiss(1000);
}
}
private void poiVideoUpload(PoiEntity poiEntity) {
if (poiEntity.getBodyId() == 0) {
ToastUtils.Message(getActivity(), "请先保存本地在上传");
return;
}
if (Constant.isPresent) {
if (fmPoiVideoPic.getTag() != null) {
List<File> videoFileList = (List<File>) fmPoiVideoPic.getTag();
boolean existsPic = PoiSaveUtils.getInstance(getActivity()).checkPicExists(videoFileList);
if (!existsPic) {
ToastUtils.Message(getActivity(), "本地不存在照片文件,无法上传数据,请确认!");
return;
}
DataSaveUtils.getInstance().uploadFiles(getActivity(), showPoiEntity, videoFileList, new DataSaveUtils.UploadCallback() {
@Override
public void onStart() {
dismissLoadingDialog();
Constant.isPresent = false;
getActivity().getSupportFragmentManager().popBackStack();//回退
WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候...");
WaitDialog.dismiss(3000);
}
@Override
public void onFinish() {
Constant.isPresent = true;
}
@Override
public void onError() {
}
});
} else {
dismissLoadingDialog();
ToastUtils.Message(getActivity(), "请录像拍照");
return;
}
} else {
ToastUtils.Message(getActivity(), "该任务正在提交中");
}
}
private void poiVideoSave(PoiEntity poiEntity) {
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", 1);
httpParams.put("memo", poiEntity.getMemo());
showLoadingDialog();
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30)
.Builder(getActivity())
.url(HttpInterface.INSIDE_API_LIST)
.cls(PoiVideoBean.class)
.params(httpParams)
.token(Constant.ACCESS_TOKEN);
okGoBuilder.getRequest(new Callback<PoiVideoBean>() {
@Override
public void onSuccess(PoiVideoBean poiVideoBean, int id) {
dismissLoadingDialog();
if (poiVideoBean.getCode() == 200) {
Integer poiVideoBody = poiVideoBean.getBody();
if (poiVideoBody != null && poiVideoBody != 0) {
poiEntity.setBodyId(poiVideoBody);
poiEntity.setTaskStatus(3);
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
poiVideoUpload(poiEntity);
Constant.isPresent = false;
}
});
}
}
}).start();
} else {
ToastUtils.Message(getActivity(), poiVideoBean.getMessage());
}
} else if (poiVideoBean.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity());
} else {
ToastUtils.Message(getActivity(), poiVideoBean.getMessage());
}
}
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
String message = e.getMessage();
assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(), "请求超时");
} else {
ToastUtils.Message(getActivity(), message);
}
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0x101 && resultCode == 0x111) {
if (data != null && data.hasExtra(Constant.INTENT_PICTURES_PATH)) {
String videoPath = data.getStringExtra(Constant.INTENT_PICTURES_PATH);
booleanExtra = data.getBooleanExtra(Constant.INTENT_BOOLEAN, true);
assert videoPath != null;
File videoFile = new File(videoPath);
if (videoFile.exists()) {
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
fmPoiVideoPic.setTag(fileListByUUID);
}
}
}
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
initPoiVideoSharePre();
}
/* 防止程序崩溃后数据丢失*/
public void initPoiVideoSharePre() {
//获取SharedPreferences对象方法中两个参数的意思为第一个name
//表示文件名系统将会在/dada/dada/包名/shared_prefs目录下生成
//一个以该参数命名的.xml文件第二个mode表示创建的模式通过查看
//方法注释得知建议以0或者MODE_PRIVATE为默认值
SharedPreferences poi = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0);
//获取Editor对象
SharedPreferences.Editor edit = poi.edit();
//根据要保存的数据的类型调用对应的put方法,
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
String newPoiEntity = new Gson().toJson(poiEntity);
//以键值对的形式添加新值
edit.putString("poiEntity", newPoiEntity);
edit.putInt("roadVideoType", 3);
//提交新值必须执行否则前面的操作都无效
edit.apply();
Log.d("TAG", "initRoadSharePre: " + newPoiEntity);
}
@Override
public void onPause() {
super.onPause();
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onPause ,");
}
@Override
public void onStop() {
super.onStop();
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onStop ,");
}
@Override
public void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断
EventBus.getDefault().unregister(this);
super.onDestroy();
if (markerPoiVideo != null) {
markerPoiVideo.remove();
}
if (poiVideoBuilder != null) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onDestroy ");
poiVideoBuilder.append("\r\n");
FileUtils.writeFile(logFile.getAbsolutePath(), poiVideoBuilder.toString(), true);
}
}
private void initEndReceiveTask(String url, PoiEntity poiEntity) {
if (poiEntity == null) {
ToastUtils.Message(getActivity(), "无此任务");
return;
}
if (poiEntity.getTaskId() == 0) {
ToastUtils.Message(getActivity(), "无此任务");
return;
}
HttpParams httpParams = new HttpParams();
httpParams.put("taskIds", poiEntity.getTaskId());
httpParams.put("auditIds", "");
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30)
.Builder(getActivity())
.url(url)
.params(httpParams)
.cls(UnPolygonTaskBean.class)
.token(Constant.ACCESS_TOKEN);
okGoBuilder.getRequest(new Callback<UnPolygonTaskBean>() {
@Override
public void onSuccess(UnPolygonTaskBean response, int id) {
dismissLoadingDialog();
if (response.getCode() == 200) {
new Thread(new Runnable() {
@Override
public void run() {
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntity(poiEntity);
}
}).start();
if (poiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId());
filePath.delete();
}
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
} else if (response.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity());
} else {
ToastUtils.Message(getActivity(), response.getMessage());
}
}
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
String message = e.getMessage();
assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(), "请求超时");
} else {
ToastUtils.Message(getActivity(), message);
}
}
});
}
@Override
protected PoiEntity initPoiEntityByUI(PoiEntity poiEntity) {
String roadName = spnRoadName.getTag().toString();
poiEntity.setName(roadName);
// if (!roadName.equals("")) {
// poiEntity.setName(roadName);
// } else {
// @SuppressLint("SimpleDateFormat")
// DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
// Calendar calendars = Calendar.getInstance();
// calendars.setTimeInMillis(System.currentTimeMillis());
// String formats = formatter.format(calendars.getTime());
// String city = Constant.currentLocation.getCity();//返回当前位置的城市.
// String district = Constant.currentLocation.getDistrict();//返回当前位置的区县.
// StringBuilder sb = new StringBuilder("poi录像上报");
// if (city != null && !"".equals(city)) {
// sb.append("-");
// sb.append(city);
// }
// if (district != null && !"".equals(district)) {
// sb.append(district);
// }
// sb.append("-").append(formats);
// poiEntity.setName(sb.toString());
// Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
// @Override
// public void run() {
// etRoadName.setText(sb);
// }
// });
// }
String desc = etDesc.getText().toString().trim();
if (!desc.equals("")) {
poiEntity.setMemo(desc);
}
@SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
String format = formatter.format(calendar.getTime());
poiEntity.setCreateTime(format);
poiEntity.setChecked(false);
poiEntity.setType(3);
if (showPoiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID != null) {
fmPoiVideoPic.setTag(fileListByUUID);
if (booleanExtra) {
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getLinePhotoByList(fileListByUUID);
if (lineStringByFileList != null) {
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
if (lineString != null) {
poiEntity.setDetail(lineString);
}
}
} else {
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getGpsLineByList(fileListByUUID);
if (lineStringByFileList != null) {
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
if (lineString != null) {
poiEntity.setDetail(lineString);
}
}
}
String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr(fileListByUUID);
poiEntity.setPhoto(photoStr);
}
}
return poiEntity;
}
@Override
protected PoiCheckResult checkPoiEntity(PoiEntity entity) {
PoiCheckResult poiCheckResult = new PoiCheckResult();
if (entity.getPhoto() == null) {
poiCheckResult.setCode(1);
poiCheckResult.setMsg("请拍摄");
return poiCheckResult;
}
return poiCheckResult;
}
@Override
protected ChargingPileEntity initChargingPileEntityByUI(ChargingPileEntity entity) {
return null;
}
@Override
protected PoiCheckResult checkChargingPileEntity(ChargingPileEntity entity) {
return null;
}
}

View File

@ -0,0 +1,940 @@
package com.navinfo.outdoor.fragment;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
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.google.gson.Gson;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
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.kongzue.dialog.v3.WaitDialog;
import com.lzy.okgo.model.HttpParams;
import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.FragmentManagement;
import com.navinfo.outdoor.activity.PicturesActivity;
import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.bean.PoiVideoBean;
import com.navinfo.outdoor.bean.UnPolygonTaskBean;
import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.room.ChargingPileEntity;
import com.navinfo.outdoor.room.InsertAndUpdateUtils;
import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.ui.view.SpinnerUtils;
import com.navinfo.outdoor.util.AWMp4ParserHelper;
import com.navinfo.outdoor.util.DataSaveUtils;
import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.PoiSaveUtils;
import com.navinfo.outdoor.util.PreserveUtils;
import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtils;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
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 org.locationtech.jts.geom.Geometry;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* 寻宝-上报弹窗-交通枢纽
*/
public class TrafficHubFragment extends BaseDrawerFragment implements View.OnClickListener {
private EditText etDesc;
private Spinner spnRoadName;
private ImageView ivPoiVideoPicture;
private Button btnRoadSave;
private File fileZip, logFile;
private FrameLayout fmPoiVideoPic;
private LatLng latLng;
private Marker markerPoiVideo;
private TextView tvCombo, tvShort;
private StringBuilder poiVideoBuilder;
private LatLng rearLatLng;
private boolean booleanExtra = true;
public static TrafficHubFragment newInstance(Bundle bundle) {
TrafficHubFragment fragment = new TrafficHubFragment();
fragment.setArguments(bundle);
return fragment;
}
@Override
protected int getLayout() {
return R.layout.traffic_hub_fragment;
}
@Override
public void onStart() {
super.onStart();
if (!EventBus.getDefault().isRegistered(this)) {//加上判断
EventBus.getDefault().register(this);
}
}
@Override
public void onResume() {
super.onResume();
View header = mView.findViewById(R.id.traffic_hub_header);
header.findViewById(R.id.iv_final).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
initBack();
}
});
header.findViewById(R.id.tv_explain).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), FragmentManagement.class);
intent.putExtra("tag", 8);
startActivity(intent);
}
});
moveLatlng(latLng, null);
}
@Override
public boolean onBackPressed() {
initBack();
return true;
}
private void initBack() {
if (showPoiEntity != null) {
if (showPoiEntity.getTaskStatus() == 5) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
return false;
}
});
} else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
if (showPoiEntity != null) {
if (showPoiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
File filePath = AWMp4ParserHelper.getInstance().getFilePath(showPoiEntity.getId());
filePath.delete();
}
}
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
Bundle arguments = getArguments();
if (arguments != null) {
isSliding = arguments.getBoolean("isSliding", true);
}
if (isSliding) {
Message obtain1 = Message.obtain();
obtain1.what = Constant.TREASURE_FRAGMENT;
obtain1.obj = isSliding;
EventBus.getDefault().post(obtain1);
}
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
return false;
}
});
} else {
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
Bundle arguments = getArguments();
if (arguments != null) {
isSliding = arguments.getBoolean("isSliding", true);
}
if (isSliding) {
Message obtain1 = Message.obtain();
obtain1.what = Constant.TREASURE_FRAGMENT;
obtain1.obj = isSliding;
EventBus.getDefault().post(obtain1);
}
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
}
}
}
@Override
protected void initView() {
super.initView();
setSlidingUpPanelLayout(Constant.SLIDING_LAYOUT);
NestedScrollView nestedScrollView = findViewById(R.id.nested_scroll_view);
if (slidingPaneLayout != null) {
slidingPaneLayout.setScrollableView(nestedScrollView);
}
spnRoadName = findViewById(R.id.spn_poi_video_name);
ivPoiVideoPicture = findViewById(R.id.iv_poi_video_picture);
etDesc = findViewById(R.id.et_desc);
//点击拍照
tvShort = findViewById(R.id.tv_short);
tvShort.setOnClickListener(this);
//自动连拍
tvCombo = findViewById(R.id.tv_combo);
tvCombo.setOnClickListener(this);
fmPoiVideoPic = findViewById(R.id.fm_poi_video_picture);
fmPoiVideoPic.setOnClickListener(this);
fmPoiVideoPic.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了长按删除图片的 按钮,");
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
ivPoiVideoPicture.setImageDrawable(null);
fmPoiVideoPic.setTag(null);
return false;
}
});
return false;
}
});
btnRoadSave = findViewById(R.id.btn_poi_video_save);
btnRoadSave.setOnClickListener(this);
Button btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
btnPoiVideoUpload.setOnClickListener(this);
//添加数据
initShowPoi();
((TextView)findViewById(R.id.tv1)).setText("交通枢纽");
}
@Override
protected void initData() {
super.initData();
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
@SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String newFormat = formatter.format(new Date(System.currentTimeMillis()));
String pictures_time = sharedPreferences.getString("pictures_time", null);
if (pictures_time == null) {
sharedEdit.putString("pictures_time", newFormat);
sharedEdit.apply();
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
} else {
if (pictures_time.equals(newFormat)) {
logFile = new File(Constant.LOG_FOLDER + "/" + pictures_time + ".txt");
} else {
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
}
}
poiVideoBuilder = new StringBuilder();
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("PoiVideoActivity-onCreate-initData ,");
if (Constant.USHERED != null) {
poiVideoBuilder.append("userId:").append(Constant.USHERED).append(",");
}
}
private void initShowPoi() {
// 添加信息
assert getArguments() != null;
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
if (showPoiEntity != null) {
String name = showPoiEntity.getName();//名称
SpinnerUtils spinnerUtils = new SpinnerUtils();
String[] items = {"交通枢纽全景", "引导图", "出发、到达层", "停车场", "其他"};
if (StringUtils.isEmpty(name)) { // 如果从数据获取的名称为空则设置name显示为默认的第一个选项
name = items[0];
}
spinnerUtils.initSpinner(getActivity(), spnRoadName, new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
spnRoadName.setTag(items[position]);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
}, name, items);
String geoWkt = showPoiEntity.getGeoWkt();
if (geoWkt != null) {
String geo = Geohash.getInstance().decode(geoWkt);
Geometry geometry = GeometryTools.createGeometry(geo);
switch (geometry.getGeometryType()) {
case "Point": //
latLng = GeometryTools.createLatLng(geo);
break;
case "LineString": //线
case "Polygon": //
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
assert latLineString != null;
latLng = latLineString.get(0);//起點
rearLatLng = latLineString.get(latLineString.size() - 1);//終點
break;
}
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
markerPoiVideo.setZIndex(4);
moveLatlng(latLng, null);
} else {
String detail = showPoiEntity.getDetail();
if (detail != null) {
String geo = Geohash.getInstance().decode(detail);
Geometry geometry = GeometryTools.createGeometry(geo);
switch (geometry.getGeometryType()) {
case "Point": //
latLng = GeometryTools.createLatLng(geo);
break;
case "LineString": //线
case "Polygon": //
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
assert latLineString != null;
latLng = latLineString.get(0);
break;
}
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
markerPoiVideo.setZIndex(4);
moveLatlng(latLng, null);
} else {
String x = showPoiEntity.getX();
String y = showPoiEntity.getY();
if (x != null && y != null) {
latLng = new LatLng();
latLng.setLongitude(Double.parseDouble(x));
latLng.setLatitude(Double.parseDouble(y));
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
markerPoiVideo.setZIndex(4);
moveLatlng(latLng, null);
}
}
}
String memo = showPoiEntity.getMemo();//任务描述
if (memo != null && !memo.equals("")) {
etDesc.setText(memo);
}
showPoiEntity.setType(3);
String photoList = showPoiEntity.getPhoto();
if (!StringUtils.isEmpty(photoList)) {
boolean isImageLoad = false;
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
if (fileListByUUID.get(i).getPath().contains(".webp") && !fileListByUUID.get(i).getPath().contains("paper.txt")) {
if (fileListByUUID.get(i).exists() && !isImageLoad) {
// 使用glide加载视频的第一帧
Glide.with(Objects.requireNonNull(getActivity())).load(fileListByUUID.get(i)).into(ivPoiVideoPicture);
isImageLoad = true;
}
}
}
fmPoiVideoPic.setTag(fileListByUUID);
}
if (showPoiEntity.getTaskStatus() == 3) {
disables();//禁用所有可操作的控件
}
// 如果是推送的POI录像不允许修改名称
if (showPoiEntity.getTaskId()>0) {
spnRoadName.setEnabled(false);
}
}
}
private void disables() {
spnRoadName.setEnabled(false);
ivPoiVideoPicture.setEnabled(false);
tvShort.setEnabled(false);
tvCombo.setEnabled(false);
etDesc.setEnabled(false);
btnRoadSave.setEnabled(false);
}
@Subscribe
public void onEvent(Message data) {
if (data.what == Constant.PICTURE_VIDEO_WORD) {
if ((boolean) data.obj) {
initPoiVideoSharePre();
}
} else if (data.what == Constant.PHOTO_FINISH_VIDEO) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID.size() == 1) {
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
ivPoiVideoPicture.setImageDrawable(null);
fmPoiVideoPic.setTag(null);
} else {
boolean isImageLoad = false;
for (int i = 0; i < fileListByUUID.size(); i++) {
File videoFile = fileListByUUID.get(i);
if (videoFile.getPath().contains(".webp") && !videoFile.getPath().contains("paper.txt")) {
if (videoFile.exists() && !isImageLoad) {
// 使用glide加载视频的第一帧
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
isImageLoad = true;
}
}
}
fmPoiVideoPic.setTag(fileListByUUID);
}
initPoiVideoSharePre();
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.fm_poi_video_picture:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了图片查看列表 ,");
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID.size() > 1) {
Intent photoAlbumIntent = new Intent(getActivity(), FragmentManagement.class);
photoAlbumIntent.putExtra("tag", 36);
photoAlbumIntent.putExtra("showPoiEntity", showPoiEntity);
startActivity(photoAlbumIntent);
} else {
ToastUtils.Message(getActivity(), "请拍摄");
}
break;
case R.id.btn_poi_video_save:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了保存本地的按钮 ,");
initPoiSaveLocal(false);
break;
case R.id.tv_short://点击拍摄
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了拍摄的按钮 ,");
double latitude = Constant.currentLocation.getLatitude();
double longitude = Constant.currentLocation.getLongitude();
LatLng startLatLng = new LatLng(latitude, longitude);// 用户当前位置
double geometry = GeometryTools.distanceToDouble(startLatLng, latLng);// 起點 于用戶的距離
double rearGeometry = GeometryTools.distanceToDouble(startLatLng, rearLatLng);// 終點于用戶的距離
if (geometry > rearGeometry) {//用戶在终点开始作业
if (rearGeometry > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
} else {//用户在起点开始作业
if (geometry > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
}
Intent intents = new Intent(getActivity(), PicturesActivity.class);
File filePath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intents.putExtra(Constant.INTENT_JPG_PATH, filePath.getAbsolutePath());
intents.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
intents.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
intents.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
int gpsRssi = Constant.currentLocation.getGPSRssi();
if (gpsRssi == 0) {
intents.putExtra(Constant.INTENT_BOOLEAN, false);
} else {
intents.putExtra(Constant.INTENT_BOOLEAN, true);
}
startActivityForResult(intents, 0x101);
break;
case R.id.tv_combo://自动连拍:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了自动连拍的按钮 ,");
LatLng startLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); //用户当前位置
double geom = GeometryTools.distanceToDouble(startLng, latLng);
double rearGeom = GeometryTools.distanceToDouble(startLng, rearLatLng);
if (geom > rearGeom) {//用戶在终点开始作业
if (rearGeom > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
} else {//用户在起点开始作业
if (geom > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
}
Intent intent = new Intent(getActivity(), PicturesActivity.class);
File fileJpgPath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intent.putExtra(Constant.INTENT_JPG_PATH, fileJpgPath.getAbsolutePath());
intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
int gpsRss = Constant.currentLocation.getGPSRssi();
if (gpsRss == 0) {
intent.putExtra(Constant.INTENT_BOOLEAN, false);
} else {
intent.putExtra(Constant.INTENT_BOOLEAN, true);
}
startActivityForResult(intent, 0x102);
break;
case R.id.btn_poi_video_upload:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了上传的按钮 ,");
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
if (poiEntity.getTaskStatus() == 1 || poiEntity.getTaskStatus() == 2 || poiEntity.getTaskStatus() == 0 || poiEntity.getTaskStatus() == 5) {
initPoiSaveLocal(true);
} else {
poiVideoUpload(poiEntity);
Constant.isPresent = false;
}
break;
}
}
public void initPoiSaveLocal(boolean isLocal) {
if (spnRoadName.getTag() == null) {
com.github.lazylibrary.util.ToastUtils.showToast(getActivity(), "没有POI名称无法保存");
return;
}
XXPermissions.with(getContext())
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
if (all) {
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
if (poiEntity.getPhoto() == null||poiEntity.getPhoto().isEmpty()) {
Toast.makeText(getActivity(), "POI录像任务必须拍照", Toast.LENGTH_LONG).show();
return;
}
PoiCheckResult poiCheckResult = checkPoiEntity(poiEntity);
if (poiCheckResult.getCode() == 1) {
ToastUtils.Message(getActivity(), poiCheckResult.getMsg());
return;
}
poiEntity.setTaskStatus(2);
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (isLocal) {
poiVideoSave(poiEntity);
} else {
poiVideoSaveNet(poiEntity);
}
}
});
}
}
}).start();
} else {
ToastUtils.Message(getActivity(), "没有申请权限,请手动申请");
}
}
@Override
public void onDenied(List<String> permissions, boolean never) {
if (never) {
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
// 如果是被永久拒绝就跳转到应用权限系统设置页面
XXPermissions.startPermissionActivity(Objects.requireNonNull(getActivity()), permissions);
}
}
});
}
private void poiVideoSaveNet(PoiEntity poiEntity) {
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", 1);
httpParams.put("memo", poiEntity.getMemo());
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30)
.Builder(getActivity())
.url(HttpInterface.INSIDE_API_LIST)
.cls(PoiVideoBean.class)
.params(httpParams)
.token(Constant.ACCESS_TOKEN);
if (getActivity() != null) {
okGoBuilder.getRequest(PreserveUtils.getInstance().getPoiVideoPreserveCallback(getActivity(), poiEntity));
getActivity().getSupportFragmentManager().popBackStack();//回退
WaitDialog.show((AppCompatActivity) getActivity(), "任务已保存本地,请稍后");
WaitDialog.dismiss(1000);
}
}
private void poiVideoUpload(PoiEntity poiEntity) {
if (poiEntity.getBodyId() == 0) {
ToastUtils.Message(getActivity(), "请先保存本地在上传");
return;
}
if (Constant.isPresent) {
if (fmPoiVideoPic.getTag() != null) {
List<File> videoFileList = (List<File>) fmPoiVideoPic.getTag();
boolean existsPic = PoiSaveUtils.getInstance(getActivity()).checkPicExists(videoFileList);
if (!existsPic) {
ToastUtils.Message(getActivity(), "本地不存在照片文件,无法上传数据,请确认!");
return;
}
DataSaveUtils.getInstance().uploadFiles(getActivity(), showPoiEntity, videoFileList, new DataSaveUtils.UploadCallback() {
@Override
public void onStart() {
dismissLoadingDialog();
Constant.isPresent = false;
getActivity().getSupportFragmentManager().popBackStack();//回退
WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候...");
WaitDialog.dismiss(3000);
}
@Override
public void onFinish() {
Constant.isPresent = true;
}
@Override
public void onError() {
}
});
} else {
dismissLoadingDialog();
ToastUtils.Message(getActivity(), "请录像拍照");
return;
}
} else {
ToastUtils.Message(getActivity(), "该任务正在提交中");
}
}
private void poiVideoSave(PoiEntity poiEntity) {
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", 1);
httpParams.put("memo", poiEntity.getMemo());
showLoadingDialog();
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30)
.Builder(getActivity())
.url(HttpInterface.INSIDE_API_LIST)
.cls(PoiVideoBean.class)
.params(httpParams)
.token(Constant.ACCESS_TOKEN);
okGoBuilder.getRequest(new Callback<PoiVideoBean>() {
@Override
public void onSuccess(PoiVideoBean poiVideoBean, int id) {
dismissLoadingDialog();
if (poiVideoBean.getCode() == 200) {
Integer poiVideoBody = poiVideoBean.getBody();
if (poiVideoBody != null && poiVideoBody != 0) {
poiEntity.setBodyId(poiVideoBody);
poiEntity.setTaskStatus(3);
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
poiVideoUpload(poiEntity);
Constant.isPresent = false;
}
});
}
}
}).start();
} else {
ToastUtils.Message(getActivity(), poiVideoBean.getMessage());
}
} else if (poiVideoBean.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity());
} else {
ToastUtils.Message(getActivity(), poiVideoBean.getMessage());
}
}
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
String message = e.getMessage();
assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(), "请求超时");
} else {
ToastUtils.Message(getActivity(), message);
}
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0x101 && resultCode == 0x111) {
if (data != null && data.hasExtra(Constant.INTENT_PICTURES_PATH)) {
String videoPath = data.getStringExtra(Constant.INTENT_PICTURES_PATH);
booleanExtra = data.getBooleanExtra(Constant.INTENT_BOOLEAN, true);
assert videoPath != null;
File videoFile = new File(videoPath);
if (videoFile.exists()) {
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
fmPoiVideoPic.setTag(fileListByUUID);
}
}
}
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
initPoiVideoSharePre();
}
/* 防止程序崩溃后数据丢失*/
public void initPoiVideoSharePre() {
//获取SharedPreferences对象方法中两个参数的意思为第一个name
//表示文件名系统将会在/dada/dada/包名/shared_prefs目录下生成
//一个以该参数命名的.xml文件第二个mode表示创建的模式通过查看
//方法注释得知建议以0或者MODE_PRIVATE为默认值
SharedPreferences poi = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0);
//获取Editor对象
SharedPreferences.Editor edit = poi.edit();
//根据要保存的数据的类型调用对应的put方法,
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
String newPoiEntity = new Gson().toJson(poiEntity);
//以键值对的形式添加新值
edit.putString("poiEntity", newPoiEntity);
edit.putInt("roadVideoType", 1);
//提交新值必须执行否则前面的操作都无效
edit.apply();
Log.d("TAG", "initRoadSharePre: " + newPoiEntity);
}
@Override
public void onPause() {
super.onPause();
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onPause ,");
}
@Override
public void onStop() {
super.onStop();
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onStop ,");
}
@Override
public void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断
EventBus.getDefault().unregister(this);
super.onDestroy();
if (markerPoiVideo != null) {
markerPoiVideo.remove();
}
if (poiVideoBuilder != null) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onDestroy ");
poiVideoBuilder.append("\r\n");
FileUtils.writeFile(logFile.getAbsolutePath(), poiVideoBuilder.toString(), true);
}
}
private void initEndReceiveTask(String url, PoiEntity poiEntity) {
if (poiEntity == null) {
ToastUtils.Message(getActivity(), "无此任务");
return;
}
if (poiEntity.getTaskId() == 0) {
ToastUtils.Message(getActivity(), "无此任务");
return;
}
HttpParams httpParams = new HttpParams();
httpParams.put("taskIds", poiEntity.getTaskId());
httpParams.put("auditIds", "");
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30)
.Builder(getActivity())
.url(url)
.params(httpParams)
.cls(UnPolygonTaskBean.class)
.token(Constant.ACCESS_TOKEN);
okGoBuilder.getRequest(new Callback<UnPolygonTaskBean>() {
@Override
public void onSuccess(UnPolygonTaskBean response, int id) {
dismissLoadingDialog();
if (response.getCode() == 200) {
new Thread(new Runnable() {
@Override
public void run() {
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntity(poiEntity);
}
}).start();
if (poiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId());
filePath.delete();
}
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
} else if (response.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity());
} else {
ToastUtils.Message(getActivity(), response.getMessage());
}
}
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
String message = e.getMessage();
assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(), "请求超时");
} else {
ToastUtils.Message(getActivity(), message);
}
}
});
}
@Override
protected PoiEntity initPoiEntityByUI(PoiEntity poiEntity) {
String roadName = spnRoadName.getTag().toString();
poiEntity.setName(roadName);
// if (!roadName.equals("")) {
// poiEntity.setName(roadName);
// } else {
// @SuppressLint("SimpleDateFormat")
// DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
// Calendar calendars = Calendar.getInstance();
// calendars.setTimeInMillis(System.currentTimeMillis());
// String formats = formatter.format(calendars.getTime());
// String city = Constant.currentLocation.getCity();//返回当前位置的城市.
// String district = Constant.currentLocation.getDistrict();//返回当前位置的区县.
// StringBuilder sb = new StringBuilder("poi录像上报");
// if (city != null && !"".equals(city)) {
// sb.append("-");
// sb.append(city);
// }
// if (district != null && !"".equals(district)) {
// sb.append(district);
// }
// sb.append("-").append(formats);
// poiEntity.setName(sb.toString());
// Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
// @Override
// public void run() {
// etRoadName.setText(sb);
// }
// });
// }
String desc = etDesc.getText().toString().trim();
if (!desc.equals("")) {
poiEntity.setMemo(desc);
}
@SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
String format = formatter.format(calendar.getTime());
poiEntity.setCreateTime(format);
poiEntity.setChecked(false);
poiEntity.setType(3);
if (showPoiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID != null) {
fmPoiVideoPic.setTag(fileListByUUID);
if (booleanExtra) {
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getLinePhotoByList(fileListByUUID);
if (lineStringByFileList != null) {
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
if (lineString != null) {
poiEntity.setDetail(lineString);
}
}
} else {
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getGpsLineByList(fileListByUUID);
if (lineStringByFileList != null) {
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
if (lineString != null) {
poiEntity.setDetail(lineString);
}
}
}
String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr(fileListByUUID);
poiEntity.setPhoto(photoStr);
}
}
return poiEntity;
}
@Override
protected PoiCheckResult checkPoiEntity(PoiEntity entity) {
PoiCheckResult poiCheckResult = new PoiCheckResult();
if (entity.getPhoto() == null) {
poiCheckResult.setCode(1);
poiCheckResult.setMsg("请拍摄");
return poiCheckResult;
}
return poiCheckResult;
}
@Override
protected ChargingPileEntity initChargingPileEntityByUI(ChargingPileEntity entity) {
return null;
}
@Override
protected PoiCheckResult checkChargingPileEntity(ChargingPileEntity entity) {
return null;
}
}

View File

@ -39,6 +39,7 @@ import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.elvishew.xlog.XLog;
import com.github.lazylibrary.util.DensityUtil;
import com.github.lazylibrary.util.FileUtils;
import com.google.gson.Gson;
@ -1127,13 +1128,26 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
DialogSettings.cancelable = false;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你poi录像页面还有未提交完的数据之前的成果已保存点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() {
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
treasureBuilder.append(TimestampUtil.time()).append(",").append("未提交完的数据-点击了poi录像");
Bundle bundle = new Bundle();
bundle.putSerializable("poiEntity", poiEntity);
PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
showSlidingFragment(poiVideoFragment);
int roadVideoType = dataFile.getInt("roadVideoType", -1);
if (roadVideoType == -1) {
PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
showSlidingFragment(poiVideoFragment);
} else if (roadVideoType == 1) {
TrafficHubFragment trafficHubFragment = TrafficHubFragment.newInstance(bundle);
showSlidingFragment(trafficHubFragment);
} else if (roadVideoType == 2) {
AreaHubFragment areaHubFragment = AreaHubFragment.newInstance(bundle);
showSlidingFragment(areaHubFragment);
} else if (roadVideoType == 3) {
BuildingInsideFragment buildingInsideFragment = BuildingInsideFragment.newInstance(bundle);
showSlidingFragment(buildingInsideFragment);
}
initRemovePoiSharePre();
return false;
}
@ -1187,6 +1201,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
//根据要保存的数据的类型调用对应的put方法,
//以键值对的形式添加新值
edit.putString("poiEntity", null);
edit.putInt("roadVideoType", -1);
//提交新值必须执行否则前面的操作都无效
edit.apply();
}
@ -1335,6 +1350,11 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
if (upload.contains(5)) {
itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_other, "其他"));
}
if (upload.contains(3)) {
itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.icon_traffic_hub, "交通枢纽"));
itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.icon_parking_hub, "区域设施"));
itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.icon_building_inside, "建筑物内部"));
}
Bundle bundle = new Bundle();
PoiEntity poiEntity = new PoiEntity();
// 上报时以当前用户位置为准
@ -1369,6 +1389,18 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
OtherFragment otherFragment = OtherFragment.newInstance(bundle);
showSlidingFragment(otherFragment);
treasureBuilder.append(TimestampUtil.time()).append("点击弹窗上的其他,");
} else if (item.getText().equals("交通枢纽")) {
TrafficHubFragment trafficHubFragment = TrafficHubFragment.newInstance(bundle);
showSlidingFragment(trafficHubFragment);
XLog.d("点击弹窗上的交通枢纽");
} else if (item.getText().equals("区域设施")) {
AreaHubFragment areaHubFragment = AreaHubFragment.newInstance(bundle);
showSlidingFragment(areaHubFragment);
XLog.d("点击弹窗上的区域设施");
} else if (item.getText().equals("建筑物内部")) {
BuildingInsideFragment buildingInsideFragment = BuildingInsideFragment.newInstance(bundle);
showSlidingFragment(buildingInsideFragment);
XLog.d("点击弹窗上的建筑物内部");
}
return false;
}
@ -1413,6 +1445,24 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
fragmentTransaction.hide(poiVideoFragment);
}
}
if (!(fragment instanceof TrafficHubFragment)) {
TrafficHubFragment trafficHubFragment = (TrafficHubFragment) supportFragmentManager.findFragmentByTag(TrafficHubFragment.class.getName());
if (trafficHubFragment != null) {
fragmentTransaction.hide(trafficHubFragment);
}
}
if (!(fragment instanceof AreaHubFragment)) {
AreaHubFragment areaHubFragment = (AreaHubFragment) supportFragmentManager.findFragmentByTag(AreaHubFragment.class.getName());
if (areaHubFragment != null) {
fragmentTransaction.hide(areaHubFragment);
}
}
if (!(fragment instanceof BuildingInsideFragment)) {
BuildingInsideFragment buildingInsideFragment = (BuildingInsideFragment) supportFragmentManager.findFragmentByTag(BuildingInsideFragment.class.getName());
if (buildingInsideFragment != null) {
fragmentTransaction.hide(buildingInsideFragment);
}
}
if (!(fragment instanceof OtherFragment)) {
OtherFragment otherFragment = (OtherFragment) supportFragmentManager.findFragmentByTag(OtherFragment.class.getName());
if (otherFragment != null) {

View File

@ -0,0 +1,36 @@
package com.navinfo.outdoor.ui.view;
import android.content.Context;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class SpinnerUtils {
public void initSpinner(Context mContext, Spinner spinner, AdapterView.OnItemSelectedListener selectedListener, String selectItem, String... items) {
if (spinner == null) {
return;
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_dropdown_item_1line,
android.R.id.text1, items);
spinner.setAdapter(adapter);
for (int i = 0; i < items.length; i++) {
if (items[i]!=null) {
if (items[i].equals(selectItem)) {
spinner.setSelection(i);
spinner.setTag(items[i]);
break;
}
}
if (selectItem!=null) {
// 如果是楼层选项则被选中要素为楼层选择
if (items[i].startsWith("楼层选择")&&selectItem.endsWith("")) {
spinner.setSelection(i);
spinner.setTag(selectItem);
break;
}
}
}
// 增加监听
spinner.setOnItemSelectedListener(selectedListener);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="180dp"
android:layout_height="match_parent"
android:background="@color/colorWhite"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/default_widget_padding"
android:text="选择楼层"
android:gravity="center"
android:textSize="@dimen/pickerview_topbar_title_textsize"></TextView>
<NumberPicker
android:id="@+id/number_picker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
></NumberPicker>
<TextView
android:id="@+id/btn_select_floor_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="确定"
android:background="@drawable/selector_hui_bg"
android:padding="@dimen/default_widget_padding"
android:gravity="center"
android:textSize="@dimen/pickerview_textsize"></TextView>
</LinearLayout>

View File

@ -0,0 +1,235 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical">
<include
android:id="@+id/traffic_hub_header"
layout="@layout/traffic_hub_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</include>
<androidx.core.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:text="01.基本信息"
android:textColor="@color/black"
android:textSize="16sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/ll_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/road_shape"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="@+id/tv_message"
app:layout_constraintTop_toBottomOf="@+id/tv_message">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:text="名称 "
android:textColor="@color/black"
android:textSize="15sp" />
<androidx.appcompat.widget.AppCompatSpinner
android:id="@+id/spn_poi_video_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:inputType="text"
android:maxLines="1"
android:layout_weight="1"
android:textSize="14sp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/btn_select_floor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:padding="@dimen/default_widget_padding"
android:layout_gravity="center"
android:layout_marginRight="@dimen/default_widget_padding"
android:visibility="gone"
android:text="楼层">
</androidx.appcompat.widget.AppCompatTextView>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_pictures"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="@+id/tv_message"
app:layout_constraintTop_toBottomOf="@id/ll_name">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="02.拍摄"
android:textColor="@color/black"
android:textSize="16sp" />
<TextView
android:id="@+id/tv_short"
style="@style/user_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:gravity="center"
android:text="点击拍摄"
android:textColor="@color/white"
android:textSize="15sp" />
<TextView
android:id="@+id/tv_combo"
style="@style/user_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:gravity="center"
android:visibility="gone"
android:text="自动连拍"
android:textColor="@color/white"
android:textSize="15sp" />
</LinearLayout>
<FrameLayout
android:id="@+id/fm_poi_video_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:layout_constraintLeft_toLeftOf="@id/ll_pictures"
app:layout_constraintTop_toBottomOf="@id/ll_pictures">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="点击拍摄成果可查看,长按可删除"
android:textSize="16sp"
/>
<ImageView
android:id="@+id/iv_poi_video_picture"
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_marginTop="25dp"
android:scaleType="fitXY" />
</FrameLayout>
<LinearLayout
android:id="@+id/ll_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintLeft_toLeftOf="@id/fm_poi_video_picture"
app:layout_constraintTop_toBottomOf="@id/fm_poi_video_picture">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="20dp"
android:text="03.描述"
android:textColor="@color/black"
android:textSize="16sp" />
<LinearLayout
android:id="@+id/linear_describe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:background="@drawable/underline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_03">
<EditText
android:id="@+id/et_desc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:background="@color/white"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="top"
android:hint="任务描述"
android:paddingStart="10dp"
android:paddingTop="10dp"
android:paddingBottom="30dp"
android:textColor="@color/test_color_selector"
android:textSize="15sp"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ll_desc">
<Button
android:id="@+id/btn_poi_video_save"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="@drawable/selector_red_radius_bg"
android:text="保存本地"
android:textColor="@color/white" />
<Button
android:id="@+id/btn_poi_video_upload"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="@drawable/shape_transparent_pink_radius_bg"
android:text="上传" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>

View File

@ -0,0 +1,68 @@
<?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="wrap_content">
<ImageView
android:id="@+id/road_bg"
android:layout_width="match_parent"
android:layout_height="110dp"
android:background="@drawable/top_bg"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_final"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:padding="10dp"
android:src="@drawable/icon_arrow"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="交通枢纽"
android:textColor="@color/white"
android:textSize="25sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/road_bg"
app:layout_constraintLeft_toLeftOf="@id/road_bg"
app:layout_constraintRight_toRightOf="@id/road_bg"
app:layout_constraintTop_toTopOf="@id/road_bg" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:background="@drawable/top_bg_line_left"
app:layout_constraintBottom_toBottomOf="@id/tv1"
app:layout_constraintRight_toLeftOf="@id/tv1"
app:layout_constraintTop_toTopOf="@id/tv1" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:background="@drawable/top_bg_line_right"
app:layout_constraintBottom_toBottomOf="@id/tv1"
app:layout_constraintLeft_toRightOf="@id/tv1"
app:layout_constraintTop_toTopOf="@id/tv1" />
<TextView
android:id="@+id/tv_explain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="点击跳至任务说明"
android:padding="5dp"
android:textColor="@color/white"
app:layout_constraintLeft_toLeftOf="@id/tv1"
app:layout_constraintRight_toRightOf="@id/tv1"
app:layout_constraintTop_toBottomOf="@id/tv1" />
</androidx.constraintlayout.widget.ConstraintLayout>