You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
199 lines
12 KiB
199 lines
12 KiB
package com.project.survey.util;
|
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
import com.bingce.autounit.TextFactory;
|
|
import com.bingce.device.Device;
|
|
import com.bingce.device.enums.DeviceTypeEnum;
|
|
import com.bingce.rtk.enums.WorkModeEnum;
|
|
import com.bingce.rtk.gnss.Gnss;
|
|
import com.bingce.rtk.model.GnssPosition;
|
|
import com.bingce.totalstation.TotalStation;
|
|
import com.bingce.totalstation.TsConfig;
|
|
import com.bingce.totalstation.enums.SetupStationModeEnum;
|
|
import com.bingce.utils.Util;
|
|
import com.gyf.immersionbar.ImmersionBar;
|
|
import com.project.survey.R;
|
|
import com.project.survey.databinding.ActivityBaseSurveyNewBinding;
|
|
import com.project.survey.ui.interfacee.IUIProvider;
|
|
|
|
import java.util.Locale;
|
|
|
|
import blankj.utilcode.util.Utils;
|
|
|
|
public class BaseSurveyActivityUtils {
|
|
public ActivityBaseSurveyNewBinding activityBaseSurveyBinding;
|
|
public final AppCompatActivity activity;
|
|
private final IUIProvider uiProvider;
|
|
private final int onRootSetBackgroundColor;
|
|
|
|
public BaseSurveyActivityUtils(AppCompatActivity activity, IUIProvider uiProvider, int onRootSetBackgroundColor) {
|
|
this.activity = activity;
|
|
this.uiProvider = uiProvider;
|
|
this.onRootSetBackgroundColor = onRootSetBackgroundColor;
|
|
}
|
|
|
|
public void onCreate() {
|
|
SystemUtils.SystemVerticalScreen(activity);
|
|
activityBaseSurveyBinding = ActivityBaseSurveyNewBinding.inflate(activity.getLayoutInflater());
|
|
activity.setContentView(activityBaseSurveyBinding.getRoot());
|
|
int layoutId = uiProvider.getLayoutId();
|
|
View contentView = uiProvider.getContentView();
|
|
if (contentView == null && layoutId > 0) {
|
|
contentView = LayoutInflater.from(activity).inflate(layoutId, activityBaseSurveyBinding.baseView, false);
|
|
}
|
|
if (contentView != null) {
|
|
activityBaseSurveyBinding.baseView.addView(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
|
}
|
|
|
|
if (onRootSetBackgroundColor == -1) {
|
|
if (!uiProvider.isShowTimeStatusBar()) {
|
|
ImmersionBar.with(activity).fitsSystemWindows(true).statusBarDarkFont(false).init();
|
|
} else {
|
|
ImmersionBar.with(activity).fitsSystemWindows(true).statusBarDarkFont(true).init();
|
|
}
|
|
} else {
|
|
ImmersionBar.with(activity).fitsSystemWindows(true).statusBarDarkFont(true).init();
|
|
}
|
|
|
|
activityBaseSurveyBinding.rlBack.setOnClickListener(v -> {
|
|
activity.onBackPressed();
|
|
});
|
|
|
|
resetTopStatus();
|
|
}
|
|
|
|
public void resetTopStatus() {
|
|
if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_TS) {
|
|
if (TsConfig.getInstance().getSetupStationMethod().getMode() == SetupStationModeEnum.ON_TOTAL_STATION) {
|
|
activityBaseSurveyBinding.tvSolutionState.setVisibility(View.GONE);
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.GONE);
|
|
activityBaseSurveyBinding.tvRtkStatusHrms.setVisibility(View.GONE);
|
|
activityBaseSurveyBinding.tvRtkStatusVrms.setVisibility(View.GONE);
|
|
activityBaseSurveyBinding.pivPowerIcon.setVisibility(View.GONE);
|
|
activityBaseSurveyBinding.tvPowerNum.setVisibility(View.GONE);
|
|
} else {
|
|
activityBaseSurveyBinding.tvSolutionState.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvRtkStatusHrms.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvRtkStatusVrms.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.pivPowerIcon.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvPowerNum.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.pivPowerIcon.setProgress(0);
|
|
activityBaseSurveyBinding.pivPowerIcon.setTextSize(0);
|
|
activityBaseSurveyBinding.tvSolutionState.setText(String.format("Ha %s", Util.radianToDmsString(0, 0, true)));
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setText(String.format("Va %s", Util.radianToDmsString(0, 0, true)));
|
|
activityBaseSurveyBinding.tvRtkStatusHrms.setText(String.format("Hd %s", Util.formatDouble2String(0, 3)));
|
|
activityBaseSurveyBinding.tvRtkStatusVrms.setText(String.format("Sd %s", Util.formatDouble2String(0, 3)));
|
|
}
|
|
activityBaseSurveyBinding.tvPoleHighHr.setText("0.000m");
|
|
activityBaseSurveyBinding.ivPoleHighHr.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.icon_hr_white));
|
|
activityBaseSurveyBinding.ivRtkStatusSatellite.setImageDrawable(ContextCompat.getDrawable(activity, R.mipmap.icon_edm_np));
|
|
activityBaseSurveyBinding.tvRtkStatusSatellite.setText(R.string.laser);
|
|
} else {
|
|
activityBaseSurveyBinding.tvSolutionState.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvRtkStatusHrms.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvRtkStatusVrms.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.pivPowerIcon.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvPowerNum.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvSolutionState.setText("");
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setText("");
|
|
activityBaseSurveyBinding.tvRtkStatusHrms.setText(Utils.getApp().getString(R.string.no_data));
|
|
activityBaseSurveyBinding.tvRtkStatusVrms.setText(Utils.getApp().getString(R.string.no_delay));
|
|
activityBaseSurveyBinding.tvPoleHighHr.setText("0.000m");
|
|
activityBaseSurveyBinding.tvPowerNum.setText("0%");
|
|
activityBaseSurveyBinding.ivPoleHighHr.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.icon_pole_high_white));
|
|
activityBaseSurveyBinding.ivRtkStatusSatellite.setImageDrawable(ContextCompat.getDrawable(activity, R.mipmap.icon_home_satellite));
|
|
activityBaseSurveyBinding.tvRtkStatusSatellite.setText(String.format("%s %s/%s", Utils.getApp().getString(R.string.satellite), 0, 0));
|
|
activityBaseSurveyBinding.pivPowerIcon.setProgress(0);
|
|
activityBaseSurveyBinding.pivPowerIcon.setTextSize(0);
|
|
}
|
|
}
|
|
|
|
public void refreshRtkStatus() {
|
|
if (Device.getInstance().deviceType != DeviceTypeEnum.DEVICE_TYPE_RTK)
|
|
return;
|
|
if (!Device.getInstance().isDeviceConnected()) {
|
|
activityBaseSurveyBinding.llRtkStatus.setVisibility(View.GONE);
|
|
return;
|
|
}
|
|
if (Gnss.getInstance().getDevice().getWorkMode() == WorkModeEnum.STATIC) {
|
|
activityBaseSurveyBinding.tvSolutionState.setText(R.string.static_mode);
|
|
} else {
|
|
activityBaseSurveyBinding.tvSolutionState.setText(GnssPosition.getInstance().getSolutionState());
|
|
}
|
|
switch (Gnss.getInstance().getDevice().getWorkMode()) {
|
|
case ROVER:
|
|
case BASE:
|
|
if (Gnss.getInstance().getDevice().getWorkMode() == WorkModeEnum.BASE) {
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.GONE);
|
|
} else {
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.VISIBLE);
|
|
}
|
|
activityBaseSurveyBinding.tvRtkStatusHrms.setText(TextFactory.distanceFormatDouble2String("H: ", GnssPosition.getInstance().getHrms(), 3));
|
|
activityBaseSurveyBinding.tvRtkStatusVrms.setText(TextFactory.distanceFormatDouble2String("V: ", GnssPosition.getInstance().getVrms(), 3));
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setText(String.format(Locale.US, "%s%s", "延迟" + " ", GnssPosition.getInstance().getDiffAge()));
|
|
activityBaseSurveyBinding.tvRtkStatusSatellite.setText(String.format(Locale.US, "%s %s/%s", activity.getString(R.string.satellite), GnssPosition.getInstance().getSatSolutionNum(), GnssPosition.getInstance().getSatTrackNum()));
|
|
break;
|
|
case STATIC:
|
|
activityBaseSurveyBinding.tvRtkStatusHrms.setVisibility(View.GONE);
|
|
activityBaseSurveyBinding.tvRtkStatusVrms.setVisibility(View.GONE);
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.GONE);
|
|
activityBaseSurveyBinding.tvRtkStatusSatellite.setVisibility(View.GONE);
|
|
break;
|
|
}
|
|
if (Gnss.getInstance().getDevice().getPowerLevel2() >= 0) {
|
|
int title_num = Gnss.getInstance().getDevice().getPowerLevel() + Gnss.getInstance().getDevice().getPowerLevel2();
|
|
activityBaseSurveyBinding.pivPowerIcon.setProgress(Math.round(title_num / 2f));
|
|
activityBaseSurveyBinding.tvPowerNum.setText(Math.round(title_num / 2f) + "%");
|
|
} else if (Gnss.getInstance().getDevice().getPowerLevel() >= 0) {
|
|
activityBaseSurveyBinding.pivPowerIcon.setProgress(Gnss.getInstance().getDevice().getPowerLevel());
|
|
activityBaseSurveyBinding.tvPowerNum.setText(Gnss.getInstance().getDevice().getPowerLevel() + "%");
|
|
}
|
|
activityBaseSurveyBinding.pivPowerIcon.setTextSize(0);
|
|
}
|
|
|
|
public void refreshHaVa(double originalHa, double originalVa) {
|
|
activityBaseSurveyBinding.tvSolutionState.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.VISIBLE);
|
|
if (TotalStation.getInstance().getOriginalHa() >= 0) {
|
|
activityBaseSurveyBinding.tvSolutionState.setText(String.format("Ha %s", Util.radianToDmsString(originalHa, 0, true)));
|
|
} else {
|
|
activityBaseSurveyBinding.tvSolutionState.setText(String.format("Ha %s", activity.getString(R.string.tilt_over)));
|
|
}
|
|
if (TotalStation.getInstance().getOriginalVa() >= 0) {
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setText(String.format("Va %s", Util.radianToDmsString(originalVa, 0, true)));
|
|
} else {
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setText(String.format("Va %s", activity.getString(R.string.tilt_over)));
|
|
}
|
|
}
|
|
|
|
public void onMeasSdAngleSuccess(double originalHa, double originalVa, double sd, double clockwiseHa, double topVa, double hd, double vd) {
|
|
activityBaseSurveyBinding.tvSolutionState.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvRtkStatusHrms.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvRtkStatusVrms.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.pivPowerIcon.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvPowerNum.setVisibility(View.VISIBLE);
|
|
activityBaseSurveyBinding.tvSolutionState.setText(String.format("Ha %s", Util.radianToDmsString(originalHa, 0, true)));
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setText(String.format("Va %s", Util.radianToDmsString(originalVa, 0, true)));
|
|
activityBaseSurveyBinding.tvRtkStatusHrms.setText(String.format("Hd %s", Util.formatDouble2String(hd, 3)));
|
|
activityBaseSurveyBinding.tvRtkStatusVrms.setText(String.format("Sd %s", Util.formatDouble2String(sd, 3)));
|
|
}
|
|
|
|
public void refreshBatteryLevel(double percent) {
|
|
if (percent >= 0) {
|
|
int title_num = TotalStation.getInstance().getPowerLevel() + TotalStation.getInstance().getPowerLevel2();
|
|
activityBaseSurveyBinding.pivPowerIcon.setProgress(Math.round(title_num / 2f));
|
|
activityBaseSurveyBinding.tvPowerNum.setText(String.format(Locale.US, "%d%%", Math.round(title_num / 2f)));
|
|
} else {
|
|
activityBaseSurveyBinding.pivPowerIcon.setTextSize(0);
|
|
}
|
|
}
|
|
}
|
|
|