feat: 增加道路和POI录像任务绘制辅助线的功能
This commit is contained in:
parent
baebb9e5cf
commit
c5e4a216bc
@ -150,6 +150,9 @@ public class Constant {
|
|||||||
public static final int CAPACITY_EVALUATION=59;//能力测试的返回
|
public static final int CAPACITY_EVALUATION=59;//能力测试的返回
|
||||||
public static final int CHARGING_STATION_DISABLE=60;//能力测试的返回
|
public static final int CHARGING_STATION_DISABLE=60;//能力测试的返回
|
||||||
public static final int EVENT_WHAT_UPLOAD_PROGRESS=61;// 数据上传的进度progress
|
public static final int EVENT_WHAT_UPLOAD_PROGRESS=61;// 数据上传的进度progress
|
||||||
|
public static final int EVENT_WHAT_CHANGE_SLIDING_STATE=62;// 改变抽屉的状态
|
||||||
|
public static final int EVENT_WHAT_START_DRAW_LINE=63;// 开始绘制参考线
|
||||||
|
public static final int EVENT_WHAT_FINISH_DRAW_LINE=64;// 完成绘制参考线
|
||||||
public static final String INTENT_POI_VIDEO_TYPE = "poi_video_type";
|
public static final String INTENT_POI_VIDEO_TYPE = "poi_video_type";
|
||||||
public static int NUMBER = 200; //任务个数
|
public static int NUMBER = 200; //任务个数
|
||||||
public static int LIMIT_TYPE = -1; //权限类型,普通任务-0,专属任务-1
|
public static int LIMIT_TYPE = -1; //权限类型,普通任务-0,专属任务-1
|
||||||
|
@ -175,4 +175,14 @@ public abstract class BaseDrawerFragment extends BaseFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 隐藏抽屉界面
|
||||||
|
* */
|
||||||
|
public void changeSlidingLayout(int isVisible, SlidingUpPanelLayout.PanelState panelState) {
|
||||||
|
Message msg = Message.obtain();
|
||||||
|
msg.what = Constant.EVENT_WHAT_CHANGE_SLIDING_STATE;
|
||||||
|
msg.arg1 = isVisible;
|
||||||
|
msg.obj = panelState;
|
||||||
|
EventBus.getDefault().post(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ import com.navinfo.outdoor.util.TimestampUtil;
|
|||||||
import com.navinfo.outdoor.util.ToastUtils;
|
import com.navinfo.outdoor.util.ToastUtils;
|
||||||
import com.navinfo.outdoor.util.UploadUtils;
|
import com.navinfo.outdoor.util.UploadUtils;
|
||||||
import com.navinfo.outdoor.util.ZipUtils;
|
import com.navinfo.outdoor.util.ZipUtils;
|
||||||
|
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||||
@ -96,6 +97,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
private StringBuilder poiVideoBuilder;
|
private StringBuilder poiVideoBuilder;
|
||||||
private LatLng rearLatLng;
|
private LatLng rearLatLng;
|
||||||
private boolean booleanExtra = true;
|
private boolean booleanExtra = true;
|
||||||
|
private TextView tvDrawLine; // 绘制辅助线
|
||||||
|
|
||||||
public static PoiVideoFragment newInstance(Bundle bundle) {
|
public static PoiVideoFragment newInstance(Bundle bundle) {
|
||||||
PoiVideoFragment fragment = new PoiVideoFragment();
|
PoiVideoFragment fragment = new PoiVideoFragment();
|
||||||
@ -233,7 +235,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了长按删除图片的 按钮,");
|
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了长按删除图片的 按钮,");
|
||||||
@ -251,6 +253,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
});
|
});
|
||||||
btnRoadSave = findViewById(R.id.btn_poi_video_save);
|
btnRoadSave = findViewById(R.id.btn_poi_video_save);
|
||||||
btnRoadSave.setOnClickListener(this);
|
btnRoadSave.setOnClickListener(this);
|
||||||
|
tvDrawLine = findViewById(R.id.tv_draw_line_poi_video);
|
||||||
|
tvDrawLine.setOnClickListener(this::onClick);
|
||||||
Button btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
|
Button btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
|
||||||
btnPoiVideoUpload.setOnClickListener(this);
|
btnPoiVideoUpload.setOnClickListener(this);
|
||||||
//添加数据
|
//添加数据
|
||||||
@ -400,7 +404,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
}
|
}
|
||||||
ivPoiVideoPicture.setImageDrawable(null);
|
ivPoiVideoPicture.setImageDrawable(null);
|
||||||
fmPoiVideoPic.setTag(null);
|
fmPoiVideoPic.setTag(null);
|
||||||
} else {
|
} else {
|
||||||
boolean isImageLoad = false;
|
boolean isImageLoad = false;
|
||||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||||
File videoFile = fileListByUUID.get(i);
|
File videoFile = fileListByUUID.get(i);
|
||||||
@ -415,6 +419,13 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
fmPoiVideoPic.setTag(fileListByUUID);
|
fmPoiVideoPic.setTag(fileListByUUID);
|
||||||
}
|
}
|
||||||
initPoiVideoSharePre();
|
initPoiVideoSharePre();
|
||||||
|
} else if (data.what == Constant.EVENT_WHAT_FINISH_DRAW_LINE) {
|
||||||
|
// 显示原有抽屉画面
|
||||||
|
changeSlidingLayout(View.VISIBLE, SlidingUpPanelLayout.PanelState.COLLAPSED);
|
||||||
|
if (data.arg1 == 1) {
|
||||||
|
List<LatLng> drawPoints = (List<LatLng>) data.obj;
|
||||||
|
showPoiEntity.setDrawLine(GeometryTools.getLineString(drawPoints));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,9 +520,23 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
Constant.isPresent = false;
|
Constant.isPresent = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case R.id.tv_draw_line_poi_video:
|
||||||
|
// 开始绘制辅助线,隐藏当前界面,展示地图,用户点击绘制线
|
||||||
|
changeSlidingLayout(View.GONE, SlidingUpPanelLayout.PanelState.HIDDEN);
|
||||||
|
startDrawLine();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始绘制参考线
|
||||||
|
* */
|
||||||
|
private void startDrawLine() {
|
||||||
|
Message drawMsg = Message.obtain();
|
||||||
|
drawMsg.what = Constant.EVENT_WHAT_START_DRAW_LINE;
|
||||||
|
EventBus.getDefault().post(drawMsg);
|
||||||
|
}
|
||||||
|
|
||||||
public void initPoiSaveLocal(boolean isLocal) {
|
public void initPoiSaveLocal(boolean isLocal) {
|
||||||
XXPermissions.with(getContext())
|
XXPermissions.with(getContext())
|
||||||
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
|
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
|
||||||
|
@ -67,6 +67,7 @@ import com.navinfo.outdoor.util.AWMp4ParserHelper;
|
|||||||
import com.navinfo.outdoor.util.Geohash;
|
import com.navinfo.outdoor.util.Geohash;
|
||||||
import com.navinfo.outdoor.util.GeometryTools;
|
import com.navinfo.outdoor.util.GeometryTools;
|
||||||
import com.navinfo.outdoor.util.ZipUtils;
|
import com.navinfo.outdoor.util.ZipUtils;
|
||||||
|
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||||
@ -105,6 +106,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
private RadioGroup rgRoadStatus; // 道路状态的radioGroup
|
private RadioGroup rgRoadStatus; // 道路状态的radioGroup
|
||||||
private EditText edtCheckedOther;
|
private EditText edtCheckedOther;
|
||||||
private int existence = 0; // 是否存在
|
private int existence = 0; // 是否存在
|
||||||
|
private TextView tvDrawLine; // 绘制辅助线
|
||||||
|
|
||||||
public static RoadFragment newInstance(Bundle bundle) {
|
public static RoadFragment newInstance(Bundle bundle) {
|
||||||
RoadFragment fragment = new RoadFragment();
|
RoadFragment fragment = new RoadFragment();
|
||||||
@ -150,18 +152,18 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
if (showPoiEntity != null) {
|
if (showPoiEntity != null) {
|
||||||
if (showPoiEntity.getTaskStatus() == 5) {
|
if (showPoiEntity.getTaskStatus() == 5) {
|
||||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||||
roadBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
|
roadBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
|
||||||
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);
|
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);
|
||||||
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
|
requireActivity().getSupportFragmentManager().popBackStack();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) {
|
} else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) {
|
||||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||||
roadBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
|
roadBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
|
||||||
@ -187,7 +189,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
obtain1.obj = isSliding;
|
obtain1.obj = isSliding;
|
||||||
EventBus.getDefault().post(obtain1);
|
EventBus.getDefault().post(obtain1);
|
||||||
}
|
}
|
||||||
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
|
requireActivity().getSupportFragmentManager().popBackStack();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -206,7 +208,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
obtain1.obj = isSliding;
|
obtain1.obj = isSliding;
|
||||||
EventBus.getDefault().post(obtain1);
|
EventBus.getDefault().post(obtain1);
|
||||||
}
|
}
|
||||||
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
|
requireActivity().getSupportFragmentManager().popBackStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,7 +266,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) requireContext(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||||
roadBuilder.append(TimestampUtil.time()).append(",").append("点击长按删除 确定按钮,");
|
roadBuilder.append(TimestampUtil.time()).append(",").append("点击长按删除 确定按钮,");
|
||||||
@ -282,6 +284,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
});
|
});
|
||||||
btnRoadSave = findViewById(R.id.btn_road_save);
|
btnRoadSave = findViewById(R.id.btn_road_save);
|
||||||
btnRoadSave.setOnClickListener(this);
|
btnRoadSave.setOnClickListener(this);
|
||||||
|
tvDrawLine = findViewById(R.id.tv_draw_line_road);
|
||||||
|
tvDrawLine.setOnClickListener(this::onClick);
|
||||||
Button roadUpload = findViewById(R.id.road_upload);
|
Button roadUpload = findViewById(R.id.road_upload);
|
||||||
roadUpload.setOnClickListener(this);
|
roadUpload.setOnClickListener(this);
|
||||||
//数据展示
|
//数据展示
|
||||||
@ -291,7 +295,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
@Override
|
@Override
|
||||||
protected void initData() {
|
protected void initData() {
|
||||||
super.initData();
|
super.initData();
|
||||||
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
|
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
|
||||||
@SuppressLint("SimpleDateFormat")
|
@SuppressLint("SimpleDateFormat")
|
||||||
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
|
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
|
||||||
@ -392,7 +396,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
|| fileListByUUID.get(i).getPath().endsWith(".jpg")|| fileListByUUID.get(i).getPath().endsWith(".jpeg")) {
|
|| fileListByUUID.get(i).getPath().endsWith(".jpg")|| fileListByUUID.get(i).getPath().endsWith(".jpeg")) {
|
||||||
if (fileListByUUID.get(i).exists() && !isImageLoad) {
|
if (fileListByUUID.get(i).exists() && !isImageLoad) {
|
||||||
// 使用glide加载视频的第一帧
|
// 使用glide加载视频的第一帧
|
||||||
Glide.with(Objects.requireNonNull(getActivity())).load(fileListByUUID.get(i)).into(ivRoadPicture);
|
Glide.with(requireActivity()).load(fileListByUUID.get(i)).into(ivRoadPicture);
|
||||||
isImageLoad = true;
|
isImageLoad = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -488,6 +492,13 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
fmRoadPic.setTag(fileListByUUID);
|
fmRoadPic.setTag(fileListByUUID);
|
||||||
}
|
}
|
||||||
initRoadSharePre();
|
initRoadSharePre();
|
||||||
|
} else if (data.what == Constant.EVENT_WHAT_FINISH_DRAW_LINE) {
|
||||||
|
// 显示原有抽屉画面
|
||||||
|
changeSlidingLayout(View.VISIBLE, SlidingUpPanelLayout.PanelState.COLLAPSED);
|
||||||
|
if (data.arg1 == 1) {
|
||||||
|
List<LatLng> drawPoints = (List<LatLng>) data.obj;
|
||||||
|
showPoiEntity.setDrawLine(GeometryTools.getLineString(drawPoints));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,10 +612,24 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
Constant.isPresent = false;
|
Constant.isPresent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case R.id.tv_draw_line_road:
|
||||||
|
// 开始绘制辅助线,隐藏当前界面,展示地图,用户点击绘制线
|
||||||
|
changeSlidingLayout(View.GONE, SlidingUpPanelLayout.PanelState.HIDDEN);
|
||||||
|
startDrawLine();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始绘制参考线
|
||||||
|
* */
|
||||||
|
private void startDrawLine() {
|
||||||
|
Message drawMsg = Message.obtain();
|
||||||
|
drawMsg.what = Constant.EVENT_WHAT_START_DRAW_LINE;
|
||||||
|
EventBus.getDefault().post(drawMsg);
|
||||||
|
}
|
||||||
|
|
||||||
public void initPoiSaveLocal(boolean isLocal) {
|
public void initPoiSaveLocal(boolean isLocal) {
|
||||||
XXPermissions.with(getContext())
|
XXPermissions.with(getContext())
|
||||||
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
|
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
|
||||||
@ -627,7 +652,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
|
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
|
||||||
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
|
requireActivity().runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (isLocal) {
|
if (isLocal) {
|
||||||
@ -649,7 +674,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
if (never) {
|
if (never) {
|
||||||
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
|
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
|
||||||
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
||||||
XXPermissions.startPermissionActivity(Objects.requireNonNull(getActivity()), permissions);
|
XXPermissions.startPermissionActivity(requireActivity(), permissions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -826,7 +851,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||||
SharedPreferences poi = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0);
|
SharedPreferences poi = requireActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||||
//获取Editor对象
|
//获取Editor对象
|
||||||
SharedPreferences.Editor edit = poi.edit();
|
SharedPreferences.Editor edit = poi.edit();
|
||||||
//根据要保存的数据的类型,调用对应的put方法,
|
//根据要保存的数据的类型,调用对应的put方法,
|
||||||
|
@ -111,6 +111,7 @@ import com.tencent.tencentmap.mapsdk.maps.model.Polygon;
|
|||||||
import com.tencent.tencentmap.mapsdk.maps.model.PolygonOptions;
|
import com.tencent.tencentmap.mapsdk.maps.model.PolygonOptions;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.Polyline;
|
import com.tencent.tencentmap.mapsdk.maps.model.Polyline;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions;
|
import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions;
|
||||||
|
import com.tencent.tencentmap.mapsdk.maps.model.TencentMapGestureListener;
|
||||||
|
|
||||||
import org.locationtech.jts.geom.Coordinate;
|
import org.locationtech.jts.geom.Coordinate;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import org.locationtech.jts.geom.Geometry;
|
||||||
@ -130,6 +131,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,6 +185,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
|||||||
private TencentMarkerUtils tencentMarkerUtils;
|
private TencentMarkerUtils tencentMarkerUtils;
|
||||||
private ImageView imgAutoMatchRoad; // 自动匹配道路
|
private ImageView imgAutoMatchRoad; // 自动匹配道路
|
||||||
private ImageView ivNaviDistance; // 按距离自动导航
|
private ImageView ivNaviDistance; // 按距离自动导航
|
||||||
|
private List<Marker> drawLineMarkerList = new ArrayList<>();
|
||||||
|
private Polyline drawLinePolyline;
|
||||||
|
|
||||||
public static TreasureFragment newInstance(Bundle bundle) {
|
public static TreasureFragment newInstance(Bundle bundle) {
|
||||||
TreasureFragment fragment = new TreasureFragment();
|
TreasureFragment fragment = new TreasureFragment();
|
||||||
@ -387,73 +391,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 内部测试功能
|
|
||||||
ImageView imgViewSettingHook = findViewById(R.id.image_view);
|
|
||||||
imgViewSettingHook.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
View layer = findViewById(R.id.layer_visiable_setting);
|
|
||||||
if (layer.isShown()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
settingHookClickCount++;
|
|
||||||
if(lastClickTime > 0){
|
|
||||||
long secondClickTime = System.currentTimeMillis();//距离上次开机时间
|
|
||||||
long dtime = secondClickTime - lastClickTime;
|
|
||||||
if(dtime <800){
|
|
||||||
if (settingHookClickCount>8) {
|
|
||||||
Toast.makeText(getContext(), "打开设置功能", Toast.LENGTH_SHORT).show();
|
|
||||||
layer.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
if (settingHookClickCount>3) {
|
|
||||||
Toast.makeText(getContext(), "再点击"+(9-settingHookClickCount)+"下打开设置功能", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else{
|
|
||||||
lastClickTime = 0;
|
|
||||||
settingHookClickCount = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lastClickTime = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Spinner spnBaseLocation = findViewById(R.id.spn_main_location);
|
|
||||||
// Spinner spnRefrenceLocation = findViewById(R.id.spn_reference_location);
|
|
||||||
// ArrayAdapter arrayAdapter = new ArrayAdapter(getActivity(), android.R.layout.simple_spinner_dropdown_item, android.R.id.text1, new String[]{"腾讯", "GPS"});
|
|
||||||
// spnBaseLocation.setAdapter(arrayAdapter);
|
|
||||||
// spnRefrenceLocation.setAdapter(arrayAdapter);
|
|
||||||
// spnRefrenceLocation.setSelection(1);
|
|
||||||
// spnBaseLocation.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
|
||||||
// if (i == 0) {
|
|
||||||
// LocationLifeCycle.getInstance().setMainLocationFrom(LocationLifeCycle.LOCATION_FROM.TENCENT);
|
|
||||||
// } else if (i==1) {
|
|
||||||
// LocationLifeCycle.getInstance().setMainLocationFrom(LocationLifeCycle.LOCATION_FROM.ORIGIN);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onNothingSelected(AdapterView<?> adapterView) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// spnRefrenceLocation.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
|
||||||
// if (i == 0) {
|
|
||||||
// LocationLifeCycle.getInstance().setReferenceLocationFrom(LocationLifeCycle.LOCATION_FROM.TENCENT);
|
|
||||||
// } else if (i==1) {
|
|
||||||
// LocationLifeCycle.getInstance().setReferenceLocationFrom(LocationLifeCycle.LOCATION_FROM.ORIGIN);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onNothingSelected(AdapterView<?> adapterView) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1132,6 +1069,116 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
|||||||
tvTenantGaps.setText("信号强度:强");
|
tvTenantGaps.setText("信号强度:强");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (data.what == Constant.EVENT_WHAT_CHANGE_SLIDING_STATE) { // 改变滑动窗口的状态
|
||||||
|
if (sliding_layout!=null) {
|
||||||
|
if (data.arg1 == View.GONE || data.arg1 == View.INVISIBLE) {
|
||||||
|
sliding_layout.setPanelHeight(0);
|
||||||
|
} else {
|
||||||
|
int[] deviceInfo = DensityUtil.getDeviceInfo(getActivity());
|
||||||
|
sliding_layout.setPanelHeight(deviceInfo[1] / 2);
|
||||||
|
}
|
||||||
|
sliding_layout.setPanelState((SlidingUpPanelLayout.PanelState) data.obj);
|
||||||
|
}
|
||||||
|
} else if (data.what == Constant.EVENT_WHAT_START_DRAW_LINE) { // 开始绘制参考线
|
||||||
|
// 界面显示绘制结束按钮
|
||||||
|
TextView drawFinish = findViewById(R.id.tv_draw_line_finish);
|
||||||
|
TextView drawCancel = findViewById(R.id.tv_draw_line_cancel);
|
||||||
|
drawFinish.setVisibility(View.VISIBLE);
|
||||||
|
drawCancel.setVisibility(View.VISIBLE);
|
||||||
|
drawFinish.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
// 检查当前线型的点位数据,如果小于2个点,无法完成
|
||||||
|
if (drawLinePolyline.getPoints()==null||drawLinePolyline.getPoints().size()<2) {
|
||||||
|
// 绘制的线不存在
|
||||||
|
ToastUtils.Message(getActivity(), "绘制的线不存在!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Message drawLineFinishMsg = Message.obtain();
|
||||||
|
drawLineFinishMsg.what = Constant.EVENT_WHAT_FINISH_DRAW_LINE;
|
||||||
|
drawLineFinishMsg.obj = drawLinePolyline.getPoints();
|
||||||
|
drawLineFinishMsg.arg1=1; // arg1为1代表存在绘制的辅助线,为0代表用户点击取消,不需要辅助线
|
||||||
|
EventBus.getDefault().post(drawLineFinishMsg);
|
||||||
|
|
||||||
|
drawFinish.setVisibility(View.GONE);
|
||||||
|
drawCancel.setVisibility(View.GONE);
|
||||||
|
tencentMap.setOnMapClickListener(null);
|
||||||
|
if (drawLineMarkerList!=null&&!drawLineMarkerList.isEmpty()) {
|
||||||
|
drawLineMarkerList.stream().forEach(new Consumer<Marker>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Marker marker) {
|
||||||
|
marker.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
drawLineMarkerList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drawLinePolyline!=null) {
|
||||||
|
drawLinePolyline.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
drawCancel.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Message drawLineFinishMsg = Message.obtain();
|
||||||
|
drawLineFinishMsg.what = Constant.EVENT_WHAT_FINISH_DRAW_LINE;
|
||||||
|
drawLineFinishMsg.arg1=0;// arg1为1代表存在绘制的辅助线,为0代表用户点击取消,不需要辅助线
|
||||||
|
EventBus.getDefault().post(drawLineFinishMsg);
|
||||||
|
|
||||||
|
drawFinish.setVisibility(View.GONE);
|
||||||
|
drawCancel.setVisibility(View.GONE);
|
||||||
|
tencentMap.setOnMapClickListener(null);
|
||||||
|
if (drawLineMarkerList!=null&&!drawLineMarkerList.isEmpty()) {
|
||||||
|
drawLineMarkerList.stream().forEach(new Consumer<Marker>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Marker marker) {
|
||||||
|
marker.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
drawLineMarkerList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drawLinePolyline!=null) {
|
||||||
|
drawLinePolyline.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (drawLineMarkerList!=null&&!drawLineMarkerList.isEmpty()) {
|
||||||
|
drawLineMarkerList.stream().forEach(new Consumer<Marker>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Marker marker) {
|
||||||
|
marker.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
drawLineMarkerList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drawLinePolyline!=null) {
|
||||||
|
drawLinePolyline.remove();
|
||||||
|
}
|
||||||
|
PolylineOptions drawLineOptions = new PolylineOptions() // 用户绘制参考线的线数据
|
||||||
|
// 折线设置圆形线头
|
||||||
|
.lineCap(true)
|
||||||
|
// 折线的颜色为绿色
|
||||||
|
.color(0xff00ff00)
|
||||||
|
.borderColor(0xff00ff00)
|
||||||
|
// 折线宽度为25像素
|
||||||
|
.width(12)
|
||||||
|
// 描边颜色的宽度,线宽还是 25 像素,不过填充的部分宽度为 `width` - 2 * `borderWidth`
|
||||||
|
.borderWidth(5);
|
||||||
|
drawLinePolyline = tencentMap.addPolyline(drawLineOptions);
|
||||||
|
if (tencentMap!=null) {
|
||||||
|
tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onMapClick(LatLng latLng) {
|
||||||
|
drawLinePolyline.appendPoint(latLng);
|
||||||
|
drawLineMarkerList.add(tencentMap.addMarker(new MarkerOptions(latLng).icon(
|
||||||
|
BitmapDescriptorFactory.fromResource(R.drawable.green_point)
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
app/src/main/res/drawable-xhdpi/green_point.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/green_point.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -38,6 +38,20 @@
|
|||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_draw_line_road"
|
||||||
|
style="@style/user_style"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:gravity="center"
|
||||||
|
app:layout_constraintLeft_toRightOf="@id/tv_message"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/tv_message"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/tv_message"
|
||||||
|
android:text="绘制辅助线"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/ll_name"
|
android:id="@+id/ll_name"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -43,6 +43,20 @@
|
|||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_draw_line_poi_video"
|
||||||
|
style="@style/user_style"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:gravity="center"
|
||||||
|
app:layout_constraintLeft_toRightOf="@id/tv_message"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/tv_message"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/tv_message"
|
||||||
|
android:text="绘制辅助线"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/ll_name"
|
android:id="@+id/ll_name"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -174,33 +174,36 @@
|
|||||||
app:layout_constraintLeft_toLeftOf="@id/iv_refrish"
|
app:layout_constraintLeft_toLeftOf="@id/iv_refrish"
|
||||||
app:layout_constraintTop_toBottomOf="@id/iv_refrish" />
|
app:layout_constraintTop_toBottomOf="@id/iv_refrish" />
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/image_view"
|
|
||||||
android:layout_width="60dp"
|
|
||||||
android:layout_height="50dp"
|
|
||||||
android:background="@android:color/transparent"
|
|
||||||
app:layout_constraintHeight_default="percent"
|
|
||||||
app:layout_constraintHeight_percent="0.4"
|
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintWidth_default="percent"
|
|
||||||
app:layout_constraintWidth_percent="0.4" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/layer_visiable_setting"
|
android:id="@+id/layer_visiable_setting"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
app:layout_constraintRight_toRightOf="@id/cb_map_type"
|
android:layout_margin="@dimen/default_widget_padding"
|
||||||
app:layout_constraintBottom_toTopOf="@id/cb_map_type">
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
<!-- <Spinner-->
|
app:layout_constraintBottom_toBottomOf="parent">
|
||||||
<!-- android:id="@+id/spn_main_location"-->
|
<TextView
|
||||||
<!-- android:layout_width="wrap_content"-->
|
android:id="@+id/tv_draw_line_finish"
|
||||||
<!-- android:layout_height="wrap_content"></Spinner>-->
|
android:layout_width="wrap_content"
|
||||||
<!-- <Spinner-->
|
android:layout_height="wrap_content"
|
||||||
<!-- android:id="@+id/spn_reference_location"-->
|
android:background="@drawable/selector_default_btn_round_corner_bg"
|
||||||
<!-- android:layout_width="wrap_content"-->
|
android:textColor="@color/selector_default_btn_text_color"
|
||||||
<!-- android:layout_height="wrap_content"></Spinner>-->
|
android:textSize="24sp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:padding="@dimen/default_widget_padding"
|
||||||
|
android:text="完成"></TextView>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_draw_line_cancel"
|
||||||
|
android:layout_marginTop="@dimen/default_widget_padding"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/selector_default_btn_round_corner_bg"
|
||||||
|
android:textColor="@color/selector_default_btn_text_color"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:padding="@dimen/default_widget_padding"
|
||||||
|
android:text="取消"></TextView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user