parent
f291762ab3
commit
5d0e055511
16 changed files with 978 additions and 98 deletions
@ -0,0 +1,185 @@ |
|||||||
|
package com.bingce.controlnetwork.fragment; |
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.graphics.drawable.ColorDrawable; |
||||||
|
import android.os.Bundle; |
||||||
|
import android.os.Parcelable; |
||||||
|
import android.view.LayoutInflater; |
||||||
|
import android.view.View; |
||||||
|
import android.view.ViewGroup; |
||||||
|
import android.view.Window; |
||||||
|
import android.view.WindowManager; |
||||||
|
import android.widget.TextView; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
import androidx.annotation.Nullable; |
||||||
|
import androidx.fragment.app.DialogFragment; |
||||||
|
import androidx.fragment.app.FragmentManager; |
||||||
|
import androidx.recyclerview.widget.RecyclerView; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.model.ViewItemType; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.RadianMethod; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.SurveyorAdjustMethod; |
||||||
|
import com.bingce.controlapphelper.util.SettingValueUtil; |
||||||
|
import com.bingce.controlnetwork.R; |
||||||
|
import com.bingce.controlnetwork.adapter.BaseAdapter; |
||||||
|
import com.bingce.controlnetwork.surveyor.method.SurveyorAdjustMethodTj; |
||||||
|
import com.bingce.controlnetwork.surveyor.state.StateConstantsTj; |
||||||
|
import com.bingce.controlnetwork.ui.vh.StationAdjustItemViewHolder; |
||||||
|
import com.bingce.controlnetwork.ui.widget.ViewFactory; |
||||||
|
import com.bingce.utils.Util; |
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public class StationDataAdjustDialogFragmentTj extends DialogFragment { |
||||||
|
public static final String KEY_MEASURE_WHAT = "__key_measure_what"; |
||||||
|
|
||||||
|
private static final String KEY_LIST = "__key_list"; |
||||||
|
private static final String KEY_IS_SHOW_SLOP_DISTANCE = "__key_show_slop"; |
||||||
|
|
||||||
|
|
||||||
|
private int measureWhat; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onAttach(@NonNull Context context) { |
||||||
|
super.onAttach(context); |
||||||
|
Bundle arguments = getArguments(); |
||||||
|
if (arguments != null) { |
||||||
|
measureWhat = arguments.getInt(KEY_MEASURE_WHAT, StateConstantsTj.VALUE_MEASURE_WHAT_DEFAULT); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||||
|
super.onViewCreated(view, savedInstanceState); |
||||||
|
if (getDialog() == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
Window window = getDialog().getWindow(); |
||||||
|
window.setBackgroundDrawable(new ColorDrawable(0x00000000)); |
||||||
|
window.setLayout( |
||||||
|
WindowManager.LayoutParams.MATCH_PARENT, |
||||||
|
WindowManager.LayoutParams.WRAP_CONTENT); |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@org.jetbrains.annotations.Nullable |
||||||
|
@Override |
||||||
|
public View onCreateView(@NonNull @NotNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) { |
||||||
|
View rootView = inflater.inflate(R.layout.fragment_station_data_adjust_dialog_layout, container, false); |
||||||
|
if (getArguments() != null) { |
||||||
|
ArrayList<SurveyorAdjustMethodTj.Item> items = getArguments().getParcelableArrayList(KEY_LIST); |
||||||
|
|
||||||
|
boolean isShowSlop = getArguments().getBoolean(KEY_IS_SHOW_SLOP_DISTANCE, true); |
||||||
|
RecyclerView recyclerView = rootView.findViewById(R.id.list); |
||||||
|
TextView distanceTitle = rootView.findViewById(R.id.distance_angle_title); |
||||||
|
if (recyclerView != null) { |
||||||
|
_Adapter adapter = new _Adapter(items); |
||||||
|
recyclerView.setAdapter(adapter); |
||||||
|
if (distanceTitle != null) { |
||||||
|
distanceTitle.setText(isShowSlop ? R.string.distance_slope : R.string.distance_horizontal); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
initShowView(rootView.findViewById(R.id.hor_angle_title), |
||||||
|
rootView.findViewById(R.id.ver_angle_title), |
||||||
|
rootView.findViewById(R.id.distance_angle_title)); |
||||||
|
|
||||||
|
} |
||||||
|
return rootView; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void initShowView(View horView, View verView, View disView) { |
||||||
|
switch (measureWhat) { |
||||||
|
case StateConstantsTj.VALUE_MEASURE_WHAT_DISTANCE: |
||||||
|
horView.setVisibility(View.GONE); |
||||||
|
verView.setVisibility(View.GONE); |
||||||
|
disView.setVisibility(View.VISIBLE); |
||||||
|
break; |
||||||
|
case StateConstantsTj.VALUE_MEASURE_WHAT_ANGLE_HOR: |
||||||
|
horView.setVisibility(View.VISIBLE); |
||||||
|
verView.setVisibility(View.GONE); |
||||||
|
disView.setVisibility(View.GONE); |
||||||
|
break; |
||||||
|
case StateConstantsTj.VALUE_MEASURE_WHAT_ANGLE_VER: |
||||||
|
horView.setVisibility(View.GONE); |
||||||
|
verView.setVisibility(View.VISIBLE); |
||||||
|
disView.setVisibility(View.GONE); |
||||||
|
break; |
||||||
|
// case StateConstants.VALUE_MEASURE_WHAT_ANGLE:
|
||||||
|
case StateConstantsTj.VALUE_MEASURE_WHAT_DEFAULT: |
||||||
|
default: |
||||||
|
horView.setVisibility(View.VISIBLE); |
||||||
|
verView.setVisibility(View.VISIBLE); |
||||||
|
disView.setVisibility(View.VISIBLE); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private class _Adapter extends BaseAdapter<SurveyorAdjustMethodTj.Item, StationAdjustItemViewHolder> { |
||||||
|
|
||||||
|
public _Adapter(List<SurveyorAdjustMethodTj.Item> items) { |
||||||
|
super(items); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected StationAdjustItemViewHolder createVH(@NotNull ViewGroup parent, int viewType) { |
||||||
|
RecyclerView.ViewHolder viewHolder = ViewFactory.generatorViewHolder(parent.getContext(), parent, ViewItemType.stationAdjust); |
||||||
|
if (viewHolder instanceof StationAdjustItemViewHolder) { |
||||||
|
return (StationAdjustItemViewHolder) viewHolder; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onBindViewHolder(@NonNull @NotNull StationAdjustItemViewHolder holder, int position) { |
||||||
|
SurveyorAdjustMethodTj.Item item = getItem(position); |
||||||
|
|
||||||
|
initShowView(holder.horAngle, holder.verAngle, holder.distance); |
||||||
|
|
||||||
|
setText(holder.pointName, item.getPointName()); |
||||||
|
setText(holder.horAngle, formatAngle(item.getHorAngle())); |
||||||
|
setText(holder.verAngle, formatAngle(item.getVerAngle())); |
||||||
|
setText(holder.distance, formatDistance(item.getDistance())); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void setText(TextView textView, String string) { |
||||||
|
if (textView != null) { |
||||||
|
textView.setText(string); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private String formatAngle(double angle) { |
||||||
|
// if (angle < 0) {
|
||||||
|
// return "";
|
||||||
|
// }
|
||||||
|
return RadianMethod.dmsStringOf(angle); |
||||||
|
} |
||||||
|
|
||||||
|
private String formatDistance(double distance) { |
||||||
|
if (distance < 0) { |
||||||
|
return ""; |
||||||
|
} |
||||||
|
return Util.formatDouble2String(distance, SettingValueUtil.getLengthDecimalPoint()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static void showDialog(int measureWhat, ArrayList<SurveyorAdjustMethodTj.Item> finalItemList, |
||||||
|
Boolean isShowSlopDistance, |
||||||
|
FragmentManager fragmentManager) { |
||||||
|
StationDataAdjustDialogFragmentTj dialogFragment = new StationDataAdjustDialogFragmentTj(); |
||||||
|
Bundle args = new Bundle(); |
||||||
|
args.putInt(KEY_MEASURE_WHAT, measureWhat); |
||||||
|
args.putParcelableArrayList(KEY_LIST, finalItemList); |
||||||
|
args.putBoolean(KEY_IS_SHOW_SLOP_DISTANCE, isShowSlopDistance); |
||||||
|
dialogFragment.setArguments(args); |
||||||
|
dialogFragment.show(fragmentManager, StationDataAdjustDialogFragmentTj.class.getName()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,305 @@ |
|||||||
|
package com.bingce.controlnetwork.ui.vh; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.view.View; |
||||||
|
import android.widget.TextView; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.model.DataCategory; |
||||||
|
import com.bingce.controlapphelper.model.LeftOrRight; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.RadianMethod; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.model.SdAngleValueType; |
||||||
|
import com.bingce.controlapphelper.util.Tools; |
||||||
|
import com.bingce.controlnetwork.App; |
||||||
|
import com.bingce.controlnetwork.R; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICycleRecorder; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ISurveyorData; |
||||||
|
import com.bingce.controlnetwork.surveyor.method.AverageValueMethod; |
||||||
|
import com.bingce.controlnetwork.surveyor.method.ValueOf2cMethod; |
||||||
|
import com.bingce.controlnetwork.surveyor.method.model.CacheResult; |
||||||
|
import com.bingce.controlnetwork.util.IdUtil; |
||||||
|
import com.bingce.utils.Util; |
||||||
|
|
||||||
|
import blankj.utilcode.util.Utils; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 水平角 |
||||||
|
*/ |
||||||
|
public class SurveyorDataViewHolderHor extends AbstractSurveyorDataViewHolder { |
||||||
|
|
||||||
|
public SurveyorDataViewHolderHor(Context context, @NonNull View itemView) { |
||||||
|
super(context, itemView); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setup(int itemIndex, |
||||||
|
String stationId, |
||||||
|
boolean showSlopDistance, |
||||||
|
ICachedData cachedData, |
||||||
|
ICycleRecorder cycleRecorder, |
||||||
|
ISurveyorData surveyorData) { |
||||||
|
if (showSlopDistance) { |
||||||
|
distanceTitle.setText(R.string.distance_slope); |
||||||
|
} else { |
||||||
|
distanceTitle.setText(R.string.distance_horizontal); |
||||||
|
} |
||||||
|
int currentCycleIndex = cycleRecorder.currentCycleIndex(); |
||||||
|
int currentSurveyorIndex = surveyorData.currentIndex(); |
||||||
|
//设置当前测量状态标识
|
||||||
|
if (currentSurveyorIndex == itemIndex) { |
||||||
|
//当前非跳过点背景黄边白色
|
||||||
|
selectMask.setBackground(Tools.getDrawable(R.drawable.select_mask)); |
||||||
|
} else { |
||||||
|
// if (cachedData.isAbandonPoint(currentCycleIndex, itemIndex)) {
|
||||||
|
// selectMask.setBackground(ToolsTj.getDrawable(R.drawable.bg_skip));
|
||||||
|
// } else {
|
||||||
|
// selectMask.setBackgroundColor(ToolsTj.getColor(R.color.white));
|
||||||
|
// }
|
||||||
|
selectMask.setBackgroundColor(Tools.getColor(R.color.white)); |
||||||
|
} |
||||||
|
|
||||||
|
//初始化
|
||||||
|
setValue(TYPE_LEFT1, ORIGINAL_VALUE, ORIGINAL_VALUE, ORIGINAL_VALUE); |
||||||
|
setValue(TYPE_LEFT2, ORIGINAL_VALUE, ORIGINAL_VALUE, ORIGINAL_VALUE); |
||||||
|
setValue(TYPE_RIGHT1, ORIGINAL_VALUE, ORIGINAL_VALUE, ORIGINAL_VALUE); |
||||||
|
setValue(TYPE_RIGHT2, ORIGINAL_VALUE, ORIGINAL_VALUE, ORIGINAL_VALUE); |
||||||
|
leftLabel.setTextColor(context.getResources().getColor(R.color.value_1_normal)); |
||||||
|
setTextColor(TYPE_LEFT1, R.color.value_1_normal); |
||||||
|
setTextColor(TYPE_LEFT2, R.color.value_2_normal); |
||||||
|
rightLabel.setTextColor(context.getResources().getColor(R.color.value_1_normal)); |
||||||
|
setTextColor(TYPE_RIGHT1, R.color.value_1_normal); |
||||||
|
setTextColor(TYPE_RIGHT2, R.color.value_2_normal); |
||||||
|
|
||||||
|
averageHorAngle.setText(ORIGINAL_VALUE); |
||||||
|
averageVerAngle.setText(ORIGINAL_VALUE); |
||||||
|
averageDistance.setText(ORIGINAL_VALUE); |
||||||
|
|
||||||
|
_2c.setText(ORIGINAL_VALUE); |
||||||
|
_i.setText(ORIGINAL_VALUE); |
||||||
|
_2d.setText(ORIGINAL_VALUE); |
||||||
|
|
||||||
|
boolean excludeDistance = cachedData.isWellSteelPoint(currentCycleIndex, itemIndex) || cachedData.isAloneMeasureDistancePoint(currentCycleIndex, itemIndex); |
||||||
|
|
||||||
|
//如果当前正在测量,使用缓存数据设置相应信息
|
||||||
|
LeftOrRight surveyorState = surveyorData.leftOrRight(); |
||||||
|
if (currentSurveyorIndex == itemIndex) { |
||||||
|
if (surveyorState == LeftOrRight.left) { |
||||||
|
if (surveyorData.hasSurveyor1()) { |
||||||
|
setValue(excludeDistance, TYPE_LEFT1, surveyorData.getAngleHor1(), surveyorData.getAngleVer1(), surveyorData.getDistance1()); |
||||||
|
} |
||||||
|
if (surveyorData.hasSurveyor2()) { |
||||||
|
setValue(excludeDistance, TYPE_LEFT2, surveyorData.getAngleHor2(), surveyorData.getAngleVer2(), surveyorData.getDistance2()); |
||||||
|
} |
||||||
|
//设置颜色
|
||||||
|
setTextColor(TYPE_LEFT1, R.color.value_1_selected); |
||||||
|
setTextColor(TYPE_LEFT2, R.color.value_2_selected); |
||||||
|
leftLabel.setTextColor(context.getResources().getColor(R.color.value_1_selected)); |
||||||
|
} else if (surveyorState == LeftOrRight.right) { |
||||||
|
if (surveyorData.hasSurveyor1()) { |
||||||
|
setValue(excludeDistance, TYPE_RIGHT1, surveyorData.getAngleHor1(), surveyorData.getAngleVer1(), surveyorData.getDistance1()); |
||||||
|
} |
||||||
|
if (surveyorData.hasSurveyor2()) { |
||||||
|
setValue(excludeDistance, TYPE_RIGHT2, surveyorData.getAngleHor2(), surveyorData.getAngleVer2(), surveyorData.getDistance2()); |
||||||
|
} |
||||||
|
//设置颜色
|
||||||
|
setTextColor(TYPE_RIGHT1, R.color.value_1_selected); |
||||||
|
setTextColor(TYPE_RIGHT2, R.color.value_2_selected); |
||||||
|
rightLabel.setTextColor(context.getResources().getColor(R.color.value_1_selected)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//根据测量次数,控制数据显示
|
||||||
|
setValue2Visibility(surveyorData.surveyorCount() > 1); |
||||||
|
|
||||||
|
pointName.setText(cachedData.pointName(currentCycleIndex, itemIndex)); |
||||||
|
heightValue.setText(cachedData.getPrismHeight(currentCycleIndex, itemIndex)); |
||||||
|
prismValue.setText(cachedData.getPrismTypeName(currentCycleIndex, itemIndex)); |
||||||
|
|
||||||
|
//重新监听observe---但是根据当前测量状态,需要排除一些数据监听
|
||||||
|
boolean skipLeft1 = false, skipLeft2 = false, skipRight1 = false, skipRight2 = false; |
||||||
|
//根据内存缓存排除
|
||||||
|
if (currentSurveyorIndex == itemIndex) { |
||||||
|
if (surveyorState == LeftOrRight.left) { |
||||||
|
if (surveyorData.hasSurveyor1()) { |
||||||
|
skipLeft1 = true; |
||||||
|
} |
||||||
|
if (surveyorData.hasSurveyor2() || surveyorData.surveyorCount() == 1) { |
||||||
|
skipLeft2 = true; |
||||||
|
} |
||||||
|
} else if (surveyorState == LeftOrRight.right) { |
||||||
|
if (surveyorData.hasSurveyor1()) { |
||||||
|
skipRight1 = true; |
||||||
|
} |
||||||
|
if (surveyorData.hasSurveyor2() || surveyorData.surveyorCount() == 1) { |
||||||
|
skipRight2 = true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
String pointId = cachedData.pointId(currentCycleIndex, itemIndex); |
||||||
|
String leftRecordId = IdUtil.surveyorRecordKey(stationId, currentCycleIndex, pointId, LeftOrRight.left); |
||||||
|
if (!skipLeft1) { |
||||||
|
DataCategory dataCategory = cachedData.valueState(leftRecordId, 0); |
||||||
|
if (!dataCategory.isEmptyData()) { |
||||||
|
setValue(excludeDistance, TYPE_LEFT1, |
||||||
|
cachedData.angleHor1(leftRecordId), |
||||||
|
cachedData.angleVer1(leftRecordId), |
||||||
|
cachedData.distance1(leftRecordId)); |
||||||
|
} |
||||||
|
if (dataCategory.isNeedResurvey()) { |
||||||
|
setTextColor(TYPE_LEFT1, R.color.value_dirty); |
||||||
|
} else if (dataCategory == DataCategory.dirtyAndSurveyed) { |
||||||
|
setTextColor(TYPE_LEFT1, R.color.value_resurveyed); |
||||||
|
} |
||||||
|
} |
||||||
|
if (!skipLeft2) { |
||||||
|
DataCategory dataCategory = cachedData.valueState(leftRecordId, 1); |
||||||
|
if (!dataCategory.isEmptyData()) { |
||||||
|
setValue(excludeDistance, TYPE_LEFT2, |
||||||
|
cachedData.angleHor2(leftRecordId), |
||||||
|
cachedData.angleVer2(leftRecordId), |
||||||
|
cachedData.distance2(leftRecordId)); |
||||||
|
} |
||||||
|
if (dataCategory.isNeedResurvey()) { |
||||||
|
setTextColor(TYPE_LEFT2, R.color.value_dirty); |
||||||
|
} else if (dataCategory == DataCategory.dirtyAndSurveyed) { |
||||||
|
setTextColor(TYPE_LEFT2, R.color.value_resurveyed); |
||||||
|
} |
||||||
|
} |
||||||
|
String rightRecordId = IdUtil.surveyorRecordKey(stationId, currentCycleIndex, pointId, LeftOrRight.right); |
||||||
|
if (!skipRight1) { |
||||||
|
DataCategory dataCategory = cachedData.valueState(rightRecordId, 0); |
||||||
|
if (!dataCategory.isEmptyData()) { |
||||||
|
setValue(excludeDistance, TYPE_RIGHT1, |
||||||
|
cachedData.angleHor1(rightRecordId), |
||||||
|
cachedData.angleVer1(rightRecordId), |
||||||
|
cachedData.distance1(rightRecordId)); |
||||||
|
} |
||||||
|
if (dataCategory.isNeedResurvey()) { |
||||||
|
setTextColor(TYPE_RIGHT1, R.color.value_dirty); |
||||||
|
} else if (dataCategory == DataCategory.dirtyAndSurveyed) { |
||||||
|
setTextColor(TYPE_RIGHT1, R.color.value_resurveyed); |
||||||
|
} |
||||||
|
} |
||||||
|
if (!skipRight2) { |
||||||
|
DataCategory dataCategory = cachedData.valueState(rightRecordId, 1); |
||||||
|
if (!dataCategory.isEmptyData()) { |
||||||
|
setValue(excludeDistance, TYPE_RIGHT2, |
||||||
|
cachedData.angleHor2(rightRecordId), |
||||||
|
cachedData.angleVer2(rightRecordId), |
||||||
|
cachedData.distance2(rightRecordId)); |
||||||
|
} |
||||||
|
if (dataCategory.isNeedResurvey()) { |
||||||
|
setTextColor(TYPE_RIGHT2, R.color.value_dirty); |
||||||
|
} else if (dataCategory == DataCategory.dirtyAndSurveyed) { |
||||||
|
setTextColor(TYPE_RIGHT2, R.color.value_resurveyed); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//均值(中值)
|
||||||
|
int surveyorCount = surveyorData.surveyorCount(); |
||||||
|
CacheResult horAngleLeftAndRightAverageValue = AverageValueMethod.leftAndRightValue(SdAngleValueType.horAngle, |
||||||
|
leftRecordId, |
||||||
|
rightRecordId, surveyorCount, cachedData); |
||||||
|
//水平角中值
|
||||||
|
if (horAngleLeftAndRightAverageValue.validate) { |
||||||
|
double radian = RadianMethod.formatRadian(horAngleLeftAndRightAverageValue.value); |
||||||
|
averageHorAngle.setText(RadianMethod.dmsStringOf(radian)); |
||||||
|
} else { |
||||||
|
averageHorAngle.setText(ORIGINAL_VALUE); |
||||||
|
} |
||||||
|
|
||||||
|
//垂直角中值
|
||||||
|
averageVerAngle.setText(ORIGINAL_VALUE); |
||||||
|
|
||||||
|
//距离中值
|
||||||
|
averageDistance.setText(ORIGINAL_VALUE); |
||||||
|
|
||||||
|
//设置2c、i、2d
|
||||||
|
CacheResult value2C = ValueOf2cMethod.valueOf2C(SdAngleValueType.horAngle, |
||||||
|
stationId, currentCycleIndex, itemIndex, surveyorData, cycleRecorder.currentCycleIndex(), cachedData); |
||||||
|
if (value2C.validate && horAngleLeftAndRightAverageValue.validate) { |
||||||
|
_2c.setText(String.format("%s″", Util.formatDouble2String(value2C.value, 1))); |
||||||
|
} else { |
||||||
|
_2c.setText(ORIGINAL_VALUE); |
||||||
|
} |
||||||
|
|
||||||
|
_i.setText(ORIGINAL_VALUE); |
||||||
|
|
||||||
|
_2d.setText(ORIGINAL_VALUE); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void setTextColor(int type, int value) { |
||||||
|
angleHor(type).setTextColor(context.getResources().getColor(value)); |
||||||
|
angleVer(type).setTextColor(context.getResources().getColor(value)); |
||||||
|
distance(type).setTextColor(context.getResources().getColor(value)); |
||||||
|
} |
||||||
|
|
||||||
|
private void setValue(boolean excludeDistance, int type, double angleHor, double angleVer, double distance) { |
||||||
|
//判断是否测水平角
|
||||||
|
String distanceString; |
||||||
|
if (excludeDistance) { |
||||||
|
distanceString = ORIGINAL_VALUE; |
||||||
|
} else { |
||||||
|
distanceString = Util.formatDouble2String(distance, ((App) Utils.getApp()).notNumber); |
||||||
|
} |
||||||
|
setValue(type, |
||||||
|
RadianMethod.dmsStringOf(angleHor), |
||||||
|
RadianMethod.dmsStringOf(angleVer), |
||||||
|
distanceString); |
||||||
|
} |
||||||
|
|
||||||
|
private void setValue(int type, String angleHor, String angleVer, String distance) { |
||||||
|
angleHor(type).setText(angleHor); |
||||||
|
angleVer(type).setText(ORIGINAL_VALUE); |
||||||
|
distance(type).setText(ORIGINAL_VALUE); |
||||||
|
} |
||||||
|
|
||||||
|
private void setValue2Visibility(boolean visibility) { |
||||||
|
leftAngleHor2.setVisibility(visibility ? View.VISIBLE : View.GONE); |
||||||
|
leftAngleVer2.setVisibility(visibility ? View.VISIBLE : View.GONE); |
||||||
|
leftDistance2.setVisibility(visibility ? View.VISIBLE : View.GONE); |
||||||
|
rightAngleHor2.setVisibility(visibility ? View.VISIBLE : View.GONE); |
||||||
|
rightAngleVer2.setVisibility(visibility ? View.VISIBLE : View.GONE); |
||||||
|
rightDistance2.setVisibility(visibility ? View.VISIBLE : View.GONE); |
||||||
|
} |
||||||
|
|
||||||
|
private TextView angleHor(int type) { |
||||||
|
if (TYPE_LEFT1 == type) { |
||||||
|
return leftAngleHor1; |
||||||
|
} else if (TYPE_LEFT2 == type) { |
||||||
|
return leftAngleHor2; |
||||||
|
} else if (TYPE_RIGHT1 == type) { |
||||||
|
return rightAngleHor1; |
||||||
|
} |
||||||
|
return rightAngleHor2; |
||||||
|
} |
||||||
|
|
||||||
|
private TextView angleVer(int type) { |
||||||
|
if (TYPE_LEFT1 == type) { |
||||||
|
return leftAngleVer1; |
||||||
|
} else if (TYPE_LEFT2 == type) { |
||||||
|
return leftAngleVer2; |
||||||
|
} else if (TYPE_RIGHT1 == type) { |
||||||
|
return rightAngleVer1; |
||||||
|
} |
||||||
|
return rightAngleVer2; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private TextView distance(int type) { |
||||||
|
if (TYPE_LEFT1 == type) { |
||||||
|
return leftDistance1; |
||||||
|
} else if (TYPE_LEFT2 == type) { |
||||||
|
return leftDistance2; |
||||||
|
} else if (TYPE_RIGHT1 == type) { |
||||||
|
return rightDistance1; |
||||||
|
} |
||||||
|
return rightDistance2; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,302 @@ |
|||||||
|
package com.bingce.controlnetwork.ui.vh; |
||||||
|
|
||||||
|
import android.content.Context; |
||||||
|
import android.view.View; |
||||||
|
import android.widget.TextView; |
||||||
|
|
||||||
|
import androidx.annotation.NonNull; |
||||||
|
|
||||||
|
import com.bingce.controlapphelper.model.DataCategory; |
||||||
|
import com.bingce.controlapphelper.model.LeftOrRight; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.RadianMethod; |
||||||
|
import com.bingce.controlapphelper.surveyor.method.model.SdAngleValueType; |
||||||
|
import com.bingce.controlapphelper.util.Tools; |
||||||
|
import com.bingce.controlnetwork.App; |
||||||
|
import com.bingce.controlnetwork.R; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICachedData; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ICycleRecorder; |
||||||
|
import com.bingce.controlnetwork.surveyor.data.ISurveyorData; |
||||||
|
import com.bingce.controlnetwork.surveyor.method.AverageValueMethod; |
||||||
|
import com.bingce.controlnetwork.surveyor.method.ValueOf2cMethod; |
||||||
|
import com.bingce.controlnetwork.surveyor.method.model.CacheResult; |
||||||
|
import com.bingce.controlnetwork.util.IdUtil; |
||||||
|
import com.bingce.utils.Util; |
||||||
|
|
||||||
|
import blankj.utilcode.util.Utils; |
||||||
|
|
||||||
|
/** |
||||||
|
* 分开观测的垂直角holder |
||||||
|
*/ |
||||||
|
public class SurveyorDataViewHolderVer extends AbstractSurveyorDataViewHolder { |
||||||
|
|
||||||
|
public SurveyorDataViewHolderVer(Context context, @NonNull View itemView) { |
||||||
|
super(context, itemView); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setup(int itemIndexCycle, |
||||||
|
String stationId, |
||||||
|
boolean showSlopDistance, |
||||||
|
ICachedData cachedData, |
||||||
|
ICycleRecorder cycleRecorder, |
||||||
|
ISurveyorData surveyorData) { |
||||||
|
if (showSlopDistance) { |
||||||
|
distanceTitle.setText(R.string.distance_slope); |
||||||
|
} else { |
||||||
|
distanceTitle.setText(R.string.distance_horizontal); |
||||||
|
} |
||||||
|
int currentCycleIndex = cycleRecorder.currentCycleIndex(); |
||||||
|
int currentSurveyorIndex = surveyorData.currentIndex(); |
||||||
|
//设置当前测量状态标识
|
||||||
|
if (currentCycleIndex == itemIndexCycle) { |
||||||
|
//当前非跳过点背景黄边白色
|
||||||
|
selectMask.setBackground(Tools.getDrawable(R.drawable.select_mask)); |
||||||
|
} else { |
||||||
|
// if (cachedData.isAbandonPoint(currentCycleIndex, itemIndexCycle)) {
|
||||||
|
// selectMask.setBackground(ToolsTj.getDrawable(R.drawable.bg_skip));
|
||||||
|
// } else {
|
||||||
|
// selectMask.setBackgroundColor(ToolsTj.getColor(R.color.white));
|
||||||
|
// }
|
||||||
|
selectMask.setBackgroundColor(Tools.getColor(R.color.white)); |
||||||
|
} |
||||||
|
|
||||||
|
//初始化
|
||||||
|
setValue(TYPE_LEFT1, ORIGINAL_VALUE, ORIGINAL_VALUE, ORIGINAL_VALUE); |
||||||
|
setValue(TYPE_LEFT2, ORIGINAL_VALUE, ORIGINAL_VALUE, ORIGINAL_VALUE); |
||||||
|
setValue(TYPE_RIGHT1, ORIGINAL_VALUE, ORIGINAL_VALUE, ORIGINAL_VALUE); |
||||||
|
setValue(TYPE_RIGHT2, ORIGINAL_VALUE, ORIGINAL_VALUE, ORIGINAL_VALUE); |
||||||
|
leftLabel.setTextColor(context.getResources().getColor(R.color.value_1_normal)); |
||||||
|
setTextColor(TYPE_LEFT1, R.color.value_1_normal); |
||||||
|
setTextColor(TYPE_LEFT2, R.color.value_2_normal); |
||||||
|
rightLabel.setTextColor(context.getResources().getColor(R.color.value_1_normal)); |
||||||
|
setTextColor(TYPE_RIGHT1, R.color.value_1_normal); |
||||||
|
setTextColor(TYPE_RIGHT2, R.color.value_2_normal); |
||||||
|
|
||||||
|
averageHorAngle.setText(ORIGINAL_VALUE); |
||||||
|
averageVerAngle.setText(ORIGINAL_VALUE); |
||||||
|
averageDistance.setText(ORIGINAL_VALUE); |
||||||
|
|
||||||
|
_2c.setText(ORIGINAL_VALUE); |
||||||
|
_i.setText(ORIGINAL_VALUE); |
||||||
|
_2d.setText(ORIGINAL_VALUE); |
||||||
|
|
||||||
|
boolean excludeDistance = cachedData.isWellSteelPoint(currentCycleIndex, itemIndexCycle) || cachedData.isAloneMeasureDistancePoint(currentCycleIndex, itemIndexCycle); |
||||||
|
|
||||||
|
//如果当前正在测量,使用缓存数据设置相应信息
|
||||||
|
LeftOrRight surveyorState = surveyorData.leftOrRight(); |
||||||
|
|
||||||
|
if (isCurrentItem(itemIndexCycle, currentCycleIndex)) { |
||||||
|
if (surveyorState == LeftOrRight.left) { |
||||||
|
if (surveyorData.hasSurveyor1()) { |
||||||
|
setValue(excludeDistance, TYPE_LEFT1, surveyorData.getAngleHor1(), surveyorData.getAngleVer1(), surveyorData.getDistance1()); |
||||||
|
} |
||||||
|
if (surveyorData.hasSurveyor2()) { |
||||||
|
setValue(excludeDistance, TYPE_LEFT2, surveyorData.getAngleHor2(), surveyorData.getAngleVer2(), surveyorData.getDistance2()); |
||||||
|
} |
||||||
|
//设置颜色
|
||||||
|
setTextColor(TYPE_LEFT1, R.color.value_1_selected); |
||||||
|
setTextColor(TYPE_LEFT2, R.color.value_2_selected); |
||||||
|
leftLabel.setTextColor(context.getResources().getColor(R.color.value_1_selected)); |
||||||
|
} else if (surveyorState == LeftOrRight.right) { |
||||||
|
if (surveyorData.hasSurveyor1()) { |
||||||
|
setValue(excludeDistance, TYPE_RIGHT1, surveyorData.getAngleHor1(), surveyorData.getAngleVer1(), surveyorData.getDistance1()); |
||||||
|
} |
||||||
|
if (surveyorData.hasSurveyor2()) { |
||||||
|
setValue(excludeDistance, TYPE_RIGHT2, surveyorData.getAngleHor2(), surveyorData.getAngleVer2(), surveyorData.getDistance2()); |
||||||
|
} |
||||||
|
//设置颜色
|
||||||
|
setTextColor(TYPE_RIGHT1, R.color.value_1_selected); |
||||||
|
setTextColor(TYPE_RIGHT2, R.color.value_2_selected); |
||||||
|
rightLabel.setTextColor(context.getResources().getColor(R.color.value_1_selected)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//根据测量次数,控制数据显示
|
||||||
|
setValue2Visibility(surveyorData.surveyorCount() > 1); |
||||||
|
|
||||||
|
pointName.setText("第" + (itemIndexCycle + 1) + "测回"); |
||||||
|
heightValue.setText(cachedData.getPrismHeight(0, currentSurveyorIndex)); |
||||||
|
prismValue.setText(cachedData.getPrismTypeName(0, currentSurveyorIndex)); |
||||||
|
|
||||||
|
//重新监听observe---但是根据当前测量状态,需要排除一些数据监听
|
||||||
|
boolean skipLeft1 = false, skipLeft2 = false, skipRight1 = false, skipRight2 = false; |
||||||
|
//根据内存缓存排除
|
||||||
|
if (isCurrentItem(itemIndexCycle, currentCycleIndex)) { |
||||||
|
if (surveyorState == LeftOrRight.left) { |
||||||
|
if (surveyorData.hasSurveyor1()) { |
||||||
|
skipLeft1 = true; |
||||||
|
} |
||||||
|
if (surveyorData.hasSurveyor2() || surveyorData.surveyorCount() == 1) { |
||||||
|
skipLeft2 = true; |
||||||
|
} |
||||||
|
} else if (surveyorState == LeftOrRight.right) { |
||||||
|
if (surveyorData.hasSurveyor1()) { |
||||||
|
skipRight1 = true; |
||||||
|
} |
||||||
|
if (surveyorData.hasSurveyor2() || surveyorData.surveyorCount() == 1) { |
||||||
|
skipRight2 = true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
String pointId = cachedData.pointId(itemIndexCycle, currentSurveyorIndex); |
||||||
|
String leftRecordId = IdUtil.surveyorRecordKey(stationId, itemIndexCycle, pointId, LeftOrRight.left); |
||||||
|
if (!skipLeft1) { |
||||||
|
DataCategory dataCategory = cachedData.valueState(leftRecordId, 0); |
||||||
|
if (!dataCategory.isEmptyData()) { |
||||||
|
setValue(excludeDistance, TYPE_LEFT1, |
||||||
|
cachedData.angleHor1(leftRecordId), |
||||||
|
cachedData.angleVer1(leftRecordId), |
||||||
|
cachedData.distance1(leftRecordId)); |
||||||
|
} |
||||||
|
if (dataCategory.isNeedResurvey()) { |
||||||
|
setTextColor(TYPE_LEFT1, R.color.value_dirty); |
||||||
|
} else if (dataCategory == DataCategory.dirtyAndSurveyed) { |
||||||
|
setTextColor(TYPE_LEFT1, R.color.value_resurveyed); |
||||||
|
} |
||||||
|
} |
||||||
|
if (!skipLeft2) { |
||||||
|
DataCategory dataCategory = cachedData.valueState(leftRecordId, 1); |
||||||
|
if (!dataCategory.isEmptyData()) { |
||||||
|
setValue(excludeDistance, TYPE_LEFT2, |
||||||
|
cachedData.angleHor2(leftRecordId), |
||||||
|
cachedData.angleVer2(leftRecordId), |
||||||
|
cachedData.distance2(leftRecordId)); |
||||||
|
} |
||||||
|
if (dataCategory.isNeedResurvey()) { |
||||||
|
setTextColor(TYPE_LEFT2, R.color.value_dirty); |
||||||
|
} else if (dataCategory == DataCategory.dirtyAndSurveyed) { |
||||||
|
setTextColor(TYPE_LEFT2, R.color.value_resurveyed); |
||||||
|
} |
||||||
|
} |
||||||
|
String rightRecordId = IdUtil.surveyorRecordKey(stationId, itemIndexCycle, pointId, LeftOrRight.right); |
||||||
|
if (!skipRight1) { |
||||||
|
DataCategory dataCategory = cachedData.valueState(rightRecordId, 0); |
||||||
|
if (!dataCategory.isEmptyData()) { |
||||||
|
setValue(excludeDistance, TYPE_RIGHT1, |
||||||
|
cachedData.angleHor1(rightRecordId), |
||||||
|
cachedData.angleVer1(rightRecordId), |
||||||
|
cachedData.distance1(rightRecordId)); |
||||||
|
} |
||||||
|
if (dataCategory.isNeedResurvey()) { |
||||||
|
setTextColor(TYPE_RIGHT1, R.color.value_dirty); |
||||||
|
} else if (dataCategory == DataCategory.dirtyAndSurveyed) { |
||||||
|
setTextColor(TYPE_RIGHT1, R.color.value_resurveyed); |
||||||
|
} |
||||||
|
} |
||||||
|
if (!skipRight2) { |
||||||
|
DataCategory dataCategory = cachedData.valueState(rightRecordId, 1); |
||||||
|
if (!dataCategory.isEmptyData()) { |
||||||
|
setValue(excludeDistance, TYPE_RIGHT2, |
||||||
|
cachedData.angleHor2(rightRecordId), |
||||||
|
cachedData.angleVer2(rightRecordId), |
||||||
|
cachedData.distance2(rightRecordId)); |
||||||
|
} |
||||||
|
if (dataCategory.isNeedResurvey()) { |
||||||
|
setTextColor(TYPE_RIGHT2, R.color.value_dirty); |
||||||
|
} else if (dataCategory == DataCategory.dirtyAndSurveyed) { |
||||||
|
setTextColor(TYPE_RIGHT2, R.color.value_resurveyed); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//均值(中值)
|
||||||
|
int surveyorCount = surveyorData.surveyorCount(); |
||||||
|
//水平角中值
|
||||||
|
averageHorAngle.setText(ORIGINAL_VALUE); |
||||||
|
//垂直角中值
|
||||||
|
CacheResult verAngleLeftAndRightAverageValue = AverageValueMethod.leftAndRightValue(SdAngleValueType.verAngle, |
||||||
|
leftRecordId, |
||||||
|
rightRecordId, surveyorCount, cachedData); |
||||||
|
|
||||||
|
if (verAngleLeftAndRightAverageValue.validate) {//显示天顶距
|
||||||
|
averageVerAngle.setText(RadianMethod.dmsStringOf(Math.PI / 2 - verAngleLeftAndRightAverageValue.value)); |
||||||
|
} else { |
||||||
|
averageVerAngle.setText(ORIGINAL_VALUE); |
||||||
|
} |
||||||
|
//距离中值
|
||||||
|
averageDistance.setText(ORIGINAL_VALUE); |
||||||
|
|
||||||
|
//设置2c、i、2d
|
||||||
|
_2c.setText(ORIGINAL_VALUE); |
||||||
|
|
||||||
|
CacheResult valueI = ValueOf2cMethod.valueOf2C(SdAngleValueType.verAngle, |
||||||
|
stationId, itemIndexCycle, currentSurveyorIndex, surveyorData, cycleRecorder.currentCycleIndex(), cachedData); |
||||||
|
if (valueI.validate && verAngleLeftAndRightAverageValue.validate) { |
||||||
|
_i.setText(String.format("%s″", Util.formatDouble2String(valueI.value, 1))); |
||||||
|
} else { |
||||||
|
_i.setText(ORIGINAL_VALUE); |
||||||
|
} |
||||||
|
|
||||||
|
_2d.setText(ORIGINAL_VALUE); |
||||||
|
} |
||||||
|
|
||||||
|
private void setTextColor(int type, int value) { |
||||||
|
angleHor(type).setTextColor(context.getResources().getColor(value)); |
||||||
|
angleVer(type).setTextColor(context.getResources().getColor(value)); |
||||||
|
distance(type).setTextColor(context.getResources().getColor(value)); |
||||||
|
} |
||||||
|
|
||||||
|
private void setValue(boolean excludeDistance, int type, double angleHor, double angleVer, double distance) { |
||||||
|
//判断是否测水平角
|
||||||
|
String distanceString; |
||||||
|
if (excludeDistance) { |
||||||
|
distanceString = ORIGINAL_VALUE; |
||||||
|
} else { |
||||||
|
distanceString = Util.formatDouble2String(distance, ((App) Utils.getApp()).notNumber); |
||||||
|
} |
||||||
|
setValue(type, |
||||||
|
RadianMethod.dmsStringOf(angleHor), |
||||||
|
RadianMethod.dmsStringOf(angleVer), |
||||||
|
distanceString); |
||||||
|
} |
||||||
|
|
||||||
|
private void setValue(int type, String angleHor, String angleVer, String distance) { |
||||||
|
angleHor(type).setText(ORIGINAL_VALUE); |
||||||
|
angleVer(type).setText(angleVer); |
||||||
|
distance(type).setText(ORIGINAL_VALUE); |
||||||
|
} |
||||||
|
|
||||||
|
private void setValue2Visibility(boolean visibility) { |
||||||
|
leftAngleHor2.setVisibility(visibility ? View.VISIBLE : View.GONE); |
||||||
|
leftAngleVer2.setVisibility(visibility ? View.VISIBLE : View.GONE); |
||||||
|
leftDistance2.setVisibility(visibility ? View.VISIBLE : View.GONE); |
||||||
|
rightAngleHor2.setVisibility(visibility ? View.VISIBLE : View.GONE); |
||||||
|
rightAngleVer2.setVisibility(visibility ? View.VISIBLE : View.GONE); |
||||||
|
rightDistance2.setVisibility(visibility ? View.VISIBLE : View.GONE); |
||||||
|
} |
||||||
|
|
||||||
|
private TextView angleHor(int type) { |
||||||
|
if (TYPE_LEFT1 == type) { |
||||||
|
return leftAngleHor1; |
||||||
|
} else if (TYPE_LEFT2 == type) { |
||||||
|
return leftAngleHor2; |
||||||
|
} else if (TYPE_RIGHT1 == type) { |
||||||
|
return rightAngleHor1; |
||||||
|
} |
||||||
|
return rightAngleHor2; |
||||||
|
} |
||||||
|
|
||||||
|
private TextView angleVer(int type) { |
||||||
|
if (TYPE_LEFT1 == type) { |
||||||
|
return leftAngleVer1; |
||||||
|
} else if (TYPE_LEFT2 == type) { |
||||||
|
return leftAngleVer2; |
||||||
|
} else if (TYPE_RIGHT1 == type) { |
||||||
|
return rightAngleVer1; |
||||||
|
} |
||||||
|
return rightAngleVer2; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private TextView distance(int type) { |
||||||
|
if (TYPE_LEFT1 == type) { |
||||||
|
return leftDistance1; |
||||||
|
} else if (TYPE_LEFT2 == type) { |
||||||
|
return leftDistance2; |
||||||
|
} else if (TYPE_RIGHT1 == type) { |
||||||
|
return rightDistance1; |
||||||
|
} |
||||||
|
return rightDistance2; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1 +1 @@ |
|||||||
Subproject commit 0c4327501a3bc4830c366d2b7f9c947839152a29 |
Subproject commit 686f68e2478454ec4d4903173f6f17d80229137b |
Loading…
Reference in new issue