diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2326241..d606447 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -274,6 +274,186 @@ android:label="@string/connect_rtk" android:launchMode="singleTask" android:windowSoftInputMode="adjustUnspecified|stateHidden" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/PointStakingActivity.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/PointStakingActivity.java index ebf1f5a..9ad25d0 100644 --- a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/PointStakingActivity.java +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/PointStakingActivity.java @@ -57,6 +57,7 @@ import com.bingce.totalstation.TsConfig; import com.bingce.utils.IntentUtil; import com.bingce.utils.PointUtils; import com.bingce.utils.SoundPoolUtil; +import com.bingce.utils.StringUtil; import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.Util; import com.project.survey.App; @@ -85,6 +86,8 @@ import blankj.utilcode.util.ToastUtils; import blankj.utilcode.util.Utils; import cn.liuyanbing.surveyor.model.base.BasePoint; import cn.liuyanbing.surveyor.model.util.CUtil; +import google.gson.Gson; +import google.gson.reflect.TypeToken; import lecho.hellocharts.listener.LineChartOnValueSelectListener; import lecho.hellocharts.model.Line; import lecho.hellocharts.model.LineChartData; @@ -125,6 +128,7 @@ public class PointStakingActivity extends BaseSurveyNewActivity { private final List methodList = new ArrayList<>(); private SharedPreferences preferences; private boolean isFirstUpdateChartView; + private boolean mStakingPointIsInMemory = false; @Override public View getContentView() { @@ -220,29 +224,32 @@ public class PointStakingActivity extends BaseSurveyNewActivity { } }); //点库选点 - binding.pointLibrary.setOnClickListener(v -> - CustomRecycleDialog.showDialog(PointStakingActivity.this, R.string.data_source, stringListLibraty, 0, false, (index, itemString) -> { - stopSoundPool(); - switch (index) { - case 0: - //放样点库 - StakingNewJobActivity.pickPoint(PointStakingActivity.this, (pointId, pointsListIndex, name, x, y, z) -> - onPickedPoint(true, pointId, name, x, y, z)); - break; - case 1: - //工程全局控制点 - ControlPointsNewActivity.pickPoint(PointStakingActivity.this, true, (pointId, name, code, x, y, z, remarks) -> { - onPickedPoint(false, pointId, name, x, y, z); - }); - break; - case 2: - //测量点库 - CoordinatePointsLibraryActivity.pickPoint(PointStakingActivity.this, (pointId, name, code, x, y, z, b, l, h) -> { - onPickedPoint(false, pointId, name, x, y, z); - }); - break; - } - })); + binding.pointLibrary.setOnClickListener(v -> { + if (mStakingPointIsInMemory) return; + CustomRecycleDialog.showDialog(PointStakingActivity.this, R.string.data_source, stringListLibraty, 0, false, (index, itemString) -> { + stopSoundPool(); + switch (index) { + case 0: + //放样点库 + StakingNewJobActivity.pickPoint(PointStakingActivity.this, (pointId, pointsListIndex, name, x, y, z) -> + onPickedPoint(true, pointId, name, x, y, z)); + break; + case 1: + //工程全局控制点 + ControlPointsNewActivity.pickPoint(PointStakingActivity.this, true, (pointId, name, code, x, y, z, remarks) -> { + onPickedPoint(false, pointId, name, x, y, z); + }); + break; + case 2: + //测量点库 + CoordinatePointsLibraryActivity.pickPoint(PointStakingActivity.this, (pointId, name, code, x, y, z, b, l, h) -> { + onPickedPoint(false, pointId, name, x, y, z); + }); + break; + } + }); + }); + //移动方法 showTopMoveMethod(); binding.tvMoveMethod.setOnClickListener(v -> { @@ -408,42 +415,103 @@ public class PointStakingActivity extends BaseSurveyNewActivity { stringListLibraty.add(getString(R.string.global_control_point)); stringListLibraty.add(getString(R.string.point_survey_point_library)); - PointDb.getInstance().rawQueryListLiveData(PointConstants.findKnownPointByJob(jobId())).observe(this, pointRecords -> { - surveyBasePointLine.getValues().clear(); - stakingPointLine.getValues().clear(); - recordPointLine.getValues().clear(); - effectGuideLine.getValues().clear(); - stakingLibraryPointList.clear(); - stakingLibraryPointList.addAll(pointRecords); - for (int i = 0; i < stakingLibraryPointList.size(); i++) { - PointRecord pointRecord = stakingLibraryPointList.get(i); - surveyBasePointLine.getValues().add(new PointValue(pointRecord.y, pointRecord.x).setLabel(pointRecord.name)); +// PointDb.getInstance().rawQueryListLiveData(PointConstants.findKnownPointByJob(jobId())).observe(this, pointRecords -> { +// surveyBasePointLine.getValues().clear(); +// stakingPointLine.getValues().clear(); +// recordPointLine.getValues().clear(); +// effectGuideLine.getValues().clear(); +// stakingLibraryPointList.clear(); +// stakingLibraryPointList.addAll(pointRecords); +// for (int i = 0; i < stakingLibraryPointList.size(); i++) { +// PointRecord pointRecord = stakingLibraryPointList.get(i); +// surveyBasePointLine.getValues().add(new PointValue(pointRecord.y, pointRecord.x).setLabel(pointRecord.name)); +// } +// if (stakingLibraryPointList.size() > 0) { +// targetStakePointRecord = stakingLibraryPointList.get(0); +// stakingPointLine.getValues().add(new PointValue(targetStakePointRecord.y, targetStakePointRecord.x).setLabel(targetStakePointRecord.name)); +// updateBottomInfo(targetStakePointRecord.name, targetStakePointRecord.x, targetStakePointRecord.y, targetStakePointRecord.h); +// drawRecordPointLine(); +// if (currentCoordinate != null) { +// drawCurrentPointLine(currentCoordinate.getX(), currentCoordinate.getY(), currentCoordinate.getZ()); +// updateTopInfo(currentCoordinate); +// } else { +// showTopMoveMethod(); +// } +// isTirpsAddSP = false; +// } else { +// targetStakePointRecord = null; +// binding.tvStakingPointName.setText(getString(R.string.staking_point_name)); +// binding.tvTargetX.setText(TextFactory.fixedString("X")); +// binding.tvTargetY.setText(TextFactory.fixedString("Y")); +// binding.tvTargetZ.setText(TextFactory.fixedString("Z")); +// showTopMoveMethod(); +// isTirpsAddSP = true; +// } +// ((LineChartRenderer) binding.lineChartView.getChartRenderer()).calculateMaxViewport(1.5f); +// binding.lineChartView.onChartDataChange(); +// binding.lineChartView.setCurrentViewport(binding.lineChartView.getMaximumViewport()); +// }); + + String targetPointList = IntentUtil.stringExtra(this, KEY_POINT_LIST); + if (StringUtil.isEmpty(targetPointList)) { + PointDb.getInstance().rawQueryListLiveData(PointConstants.findKnownPointByJob(jobId())).observe(this, pointRecords -> { + onPointRecordsUpdate(pointRecords); + }); + } else { + mStakingPointIsInMemory = true; + Gson gson = new Gson(); + List points = gson.fromJson(targetPointList, new TypeToken>() { + }.getType()); + List pointRecords = new ArrayList<>(); + for (StakingPoint point : points) { + pointRecords.add(new PointRecord( + "", "", "", + point.getCategory(), + point.getName(), + "", + "", + point.getX(), point.getY(), point.getZ(), + 0, 0, 0, PointConstants.POINT_FORMAT_XYZ, new DeviceInfoData())); } - if (stakingLibraryPointList.size() > 0) { - targetStakePointRecord = stakingLibraryPointList.get(0); - stakingPointLine.getValues().add(new PointValue(targetStakePointRecord.y, targetStakePointRecord.x).setLabel(targetStakePointRecord.name)); - updateBottomInfo(targetStakePointRecord.name, targetStakePointRecord.x, targetStakePointRecord.y, targetStakePointRecord.h); - drawRecordPointLine(); - if (currentCoordinate != null) { - drawCurrentPointLine(currentCoordinate.getX(), currentCoordinate.getY(), currentCoordinate.getZ()); - updateTopInfo(currentCoordinate); - } else { - showTopMoveMethod(); - } - isTirpsAddSP = false; + onPointRecordsUpdate(pointRecords); + } + } + + private void onPointRecordsUpdate(List pointRecords) { + surveyBasePointLine.getValues().clear(); + stakingPointLine.getValues().clear(); + recordPointLine.getValues().clear(); + effectGuideLine.getValues().clear(); + stakingLibraryPointList.clear(); + stakingLibraryPointList.addAll(pointRecords); + for (int i = 0; i < stakingLibraryPointList.size(); i++) { + PointRecord pointRecord = stakingLibraryPointList.get(i); + surveyBasePointLine.getValues().add(new PointValue(pointRecord.y, pointRecord.x).setLabel(pointRecord.name)); + } + if (stakingLibraryPointList.size() > 0) { + targetStakePointRecord = stakingLibraryPointList.get(0); + stakingPointLine.getValues().add(new PointValue(targetStakePointRecord.y, targetStakePointRecord.x).setLabel(targetStakePointRecord.name)); + updateBottomInfo(targetStakePointRecord.name, targetStakePointRecord.x, targetStakePointRecord.y, targetStakePointRecord.h); + drawRecordPointLine(); + if (currentCoordinate != null) { + drawCurrentPointLine(currentCoordinate.getX(), currentCoordinate.getY(), currentCoordinate.getZ()); + updateTopInfo(currentCoordinate); } else { - targetStakePointRecord = null; - binding.tvStakingPointName.setText(getString(R.string.staking_point_name)); - binding.tvTargetX.setText(TextFactory.fixedString("X")); - binding.tvTargetY.setText(TextFactory.fixedString("Y")); - binding.tvTargetZ.setText(TextFactory.fixedString("Z")); showTopMoveMethod(); - isTirpsAddSP = true; } - ((LineChartRenderer) binding.lineChartView.getChartRenderer()).calculateMaxViewport(1.5f); - binding.lineChartView.onChartDataChange(); - binding.lineChartView.setCurrentViewport(binding.lineChartView.getMaximumViewport()); - }); + isTirpsAddSP = false; + } else { + targetStakePointRecord = null; + binding.tvStakingPointName.setText(getString(R.string.staking_point_name)); + binding.tvTargetX.setText(TextFactory.fixedString("X")); + binding.tvTargetY.setText(TextFactory.fixedString("Y")); + binding.tvTargetZ.setText(TextFactory.fixedString("Z")); + showTopMoveMethod(); + isTirpsAddSP = true; + } + ((LineChartRenderer) binding.lineChartView.getChartRenderer()).calculateMaxViewport(1.5f); + binding.lineChartView.onChartDataChange(); + binding.lineChartView.setCurrentViewport(binding.lineChartView.getMaximumViewport()); } private void watchSurvey() { @@ -553,6 +621,23 @@ public class PointStakingActivity extends BaseSurveyNewActivity { ToastUtils.showShort(getString(R.string.add_points_staking_point_first)); return; } + if (mStakingPointIsInMemory) { + int currentIndex = -1; + for (int i = 0; i < stakingLibraryPointList.size(); i++) { + if (stakingLibraryPointList.get(i) == targetStakePointRecord) { + currentIndex = i; + break; + } + } + if (currentIndex == -1) { + return; + } + currentIndex += stakingLibraryPointList.size(); + int targetIndex = (nextOrLast ? currentIndex + 1 : currentIndex - 1) % stakingLibraryPointList.size(); + targetStakePointRecord = stakingLibraryPointList.get(targetIndex); + updateUI(); + return; + } ThreadPoolUtil.execute(() -> { String projectId = CachedProject.currentProjectId(); String jobId = CachedCurrentJob.currentJobId(projectId); @@ -1132,6 +1217,16 @@ public class PointStakingActivity extends BaseSurveyNewActivity { return IntentUtil.stringExtra(getIntent(), KEY_JOB_ID); } + private static final String KEY_POINT_LIST = "key_point_list"; + + + public static void start(Context context, List stakingPointList) { + Gson gson = new Gson(); + Intent intent = new Intent(context, PointStakingActivity.class); + intent.putExtra(KEY_POINT_LIST, gson.toJson(stakingPointList)); + context.startActivity(intent); + } + public static void start(Context context) { ThreadPoolUtil.execute(() -> { String projectId = CachedProject.currentProjectId(); diff --git a/app/src/main/res/layout/sh_toolbar.xml b/app/src/main/res/layout/sh_toolbar.xml index aa0c31d..eb11825 100644 --- a/app/src/main/res/layout/sh_toolbar.xml +++ b/app/src/main/res/layout/sh_toolbar.xml @@ -4,10 +4,7 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?actionBarSize" - android:background="@color/transparent" + android:background="?attr/colorPrimary" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" - app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" - app:titleTextAppearance="@style/ToolbarTextAppearance" - app:navigationIcon="@drawable/icon_toolbar_back" - app:titleCentered="true" /> + app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 3fcdd50..2e40eb5 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -121,7 +121,7 @@