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.
104 lines
6.6 KiB
104 lines
6.6 KiB
package com.project.survey.util;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.view.View;
|
|
|
|
import com.bingce.AppChannel;
|
|
import com.bingce.device.Device;
|
|
import com.bingce.device.enums.DeviceTypeEnum;
|
|
import com.bingce.device.ui.ConnectRtkActivity;
|
|
import com.bingce.device.ui.ConnectTSActivity;
|
|
import com.bingce.surveyor.util.ConstUtils;
|
|
import com.bingce.surveyor.util.PreferencesUtil;
|
|
import com.bingce.surveyor.util.dialog.CustomRecycleDialog;
|
|
import com.bingce.surveyorBase.R;
|
|
import com.bingce.totalstation.TsConfig;
|
|
import com.bingce.totalstation.enums.SetupStationModeEnum;
|
|
import com.bingce.utils.Util;
|
|
import com.project.survey.databinding.ActivityBaseSurveyNewBinding;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import blankj.utilcode.util.ActivityUtils;
|
|
import blankj.utilcode.util.Utils;
|
|
|
|
public class DeviceConnectUtil {
|
|
|
|
public static boolean isDeviceConnectSelectDialog(Context context, ActivityBaseSurveyNewBinding activityBaseSurveyBinding) {
|
|
|
|
if (!Device.getInstance().isDeviceConnected()) {
|
|
List<String> stringListDevice = new ArrayList<>();
|
|
stringListDevice.add(context.getString(R.string.total_station));
|
|
stringListDevice.add(context.getString(R.string.rtk));
|
|
CustomRecycleDialog.showDialog(context, R.string.choose_instrument_type, stringListDevice, PreferencesUtil.getLastConnectDeviceType(), false, (index, itemString) -> {
|
|
PreferencesUtil.putPreference(ConstUtils.preferConst.lastConnectDeviceType, index);
|
|
switch (index) {
|
|
case 0:
|
|
Intent intent = new Intent(ActivityUtils.getTopActivity(), ConnectTSActivity.class);
|
|
intent.putExtra("customChannel", AppChannel.customChannel);
|
|
ActivityUtils.getTopActivity().startActivity(intent);
|
|
|
|
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(Utils.getApp().getResources().getDrawable(R.drawable.icon_hr_high_white));
|
|
activityBaseSurveyBinding.ivRtkStatusSatellite.setImageDrawable(Utils.getApp().getResources().getDrawable(R.mipmap.icon_edm_np));
|
|
activityBaseSurveyBinding.tvRtkStatusSatellite.setText(R.string.laser);
|
|
break;
|
|
case 1:
|
|
Intent intent2 = new Intent(ActivityUtils.getTopActivity(), ConnectRtkActivity.class);
|
|
ActivityUtils.getTopActivity().startActivity(intent2);
|
|
|
|
activityBaseSurveyBinding.tvRtkStatusHrms.setText(Utils.getApp().getString(R.string.no_data));
|
|
activityBaseSurveyBinding.tvRtkStatusVrms.setText(Utils.getApp().getString(R.string.no_delay));
|
|
activityBaseSurveyBinding.tvSolutionState.setText("");
|
|
activityBaseSurveyBinding.tvRtkStatusDiffAge.setText("");
|
|
activityBaseSurveyBinding.pivPowerIcon.setProgress(0);
|
|
activityBaseSurveyBinding.pivPowerIcon.setTextSize(0);
|
|
activityBaseSurveyBinding.tvPoleHighHr.setText("0.000m");
|
|
activityBaseSurveyBinding.ivPoleHighHr.setImageDrawable(Utils.getApp().getResources().getDrawable(R.drawable.icon_pole_high_white));
|
|
activityBaseSurveyBinding.ivRtkStatusSatellite.setImageDrawable(Utils.getApp().getResources().getDrawable(R.mipmap.icon_home_satellite));
|
|
activityBaseSurveyBinding.tvRtkStatusSatellite.setText(String.format("%s %s/%s", Utils.getApp().getString(R.string.satellite), 0, 0));
|
|
break;
|
|
}
|
|
});
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public static void startDeviceConnected(Context context, ActivityBaseSurveyNewBinding activityBaseSurveyBinding) {
|
|
if (DeviceConnectUtil.isDeviceConnectSelectDialog(context, activityBaseSurveyBinding)) {
|
|
if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_TS) {
|
|
Intent intent = new Intent(ActivityUtils.getTopActivity(), ConnectTSActivity.class);
|
|
intent.putExtra("customChannel", AppChannel.customChannel);
|
|
ActivityUtils.getTopActivity().startActivity(intent);
|
|
} else {
|
|
Intent intent2 = new Intent(ActivityUtils.getTopActivity(), ConnectRtkActivity.class);
|
|
ActivityUtils.getTopActivity().startActivity(intent2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|