Compare commits

...

2 Commits

Author SHA1 Message Date
huangwei ef78de301c [军测] 9 months ago
huangwei e552c6d3fc [军测] 9 months ago
  1. 9
      app/src/main/AndroidManifest.xml
  2. 266
      app/src/main/java/com/bingce/controlnetwork/activity/MainActivity.java
  3. 62
      app/src/main/java/com/bingce/controlnetwork/activity/ViewRecentCrashActivity.java
  4. 5
      app/src/main/java/com/bingce/controlnetwork/fragment/stationsurvey/heighttraverse/MeasureHeightTraverseFragment.kt
  5. 10
      app/src/main/java/com/bingce/controlnetwork/newui/configfragment/ConfigFragment.kt
  6. 9
      app/src/main/java/com/bingce/controlnetwork/newui/mefragment/MeFragment.kt
  7. 5
      app/src/main/java/com/bingce/controlnetwork/newui/stationsettingheighttraverse/IStationSettingOperate.kt
  8. 213
      app/src/main/java/com/bingce/controlnetwork/newui/stationsettingheighttraverse/StationSettingEnvironmentHeightTraverseFragment.kt
  9. 151
      app/src/main/java/com/bingce/controlnetwork/newui/stationsettingheighttraverse/StationSettingHeightHeightTraverseFragment.kt
  10. 21
      app/src/main/java/com/bingce/controlnetwork/newui/stationsettingheighttraverse/StationSettingHeightTraverseVm.kt
  11. 317
      app/src/main/java/com/bingce/controlnetwork/newui/stationsettingheighttraverse/StationSettingsHeightTraverseActivity.kt
  12. 38
      app/src/main/java/com/bingce/controlnetwork/newui/stationsettingheighttraverse/model/StationSettingEnvironmentData.kt
  13. 58
      app/src/main/java/com/bingce/controlnetwork/newui/stationsettingheighttraverse/model/StationSettingHeightData.kt
  14. 101
      app/src/main/java/com/bingce/controlnetwork/util/CrashCollectUtils.java
  15. 21
      app/src/main/java/com/bingce/controlnetwork/util/SelectDeviceTypeUtil.java
  16. 21
      app/src/main/res/layout/activity_view_recent_crash_log.xml
  17. 34
      app/src/main/res/layout/new_fragment_config.xml
  18. 37
      app/src/main/res/layout/new_fragment_me.xml
  19. 88
      app/src/main/res/layout/new_fragment_station_setting_environment_height_traverse.xml
  20. 91
      app/src/main/res/layout/new_fragment_station_setting_height_height_traverse.xml
  21. BIN
      app/src/main/res/mipmap-xxhdpi/ic_level_connect.png

@ -187,6 +187,10 @@
android:name=".newui.stationsetting.StationSettingsActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true" />
<activity
android:name=".newui.stationsettingheighttraverse.StationSettingsHeightTraverseActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true" />
<activity
android:name=".newui.projectedit.ProjectCreateEditActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
@ -211,7 +215,10 @@
android:name=".func.level.idetection.LevelIDetectionStationSettingActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="i角检测" />
<activity
android:name=".activity.ViewRecentCrashActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/view_recent_log" />
</application>
</manifest>

@ -5,7 +5,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
@ -44,12 +43,10 @@ import com.bingce.controlnetwork.activity.backup.launch.BackupImportHelper;
import com.bingce.controlnetwork.activity.user.LoginActivity;
import com.bingce.controlnetwork.activity.user.RegisterActivity;
import com.bingce.controlnetwork.activity.user.UserInfoActivity;
import com.bingce.controlnetwork.bean.MainUserBean;
import com.bingce.controlnetwork.fragment.MainSurveyFragment;
import com.bingce.controlnetwork.fragment.ProjectListFragment;
import com.bingce.controlnetwork.newui.configfragment.ConfigFragment;
import com.bingce.controlnetwork.newui.mefragment.MeFragment;
import com.bingce.controlnetwork.util.CheckControlUpdateUtil;
import com.bingce.controlnetwork.viewmodel.MainActivityViewModel;
import com.bingce.data.sync.GlobalFlowCenter;
import com.bingce.data.sync.utils.LeanCloudConfigLoader;
@ -63,21 +60,15 @@ import com.bingce.surveyor.agentweb.AgentWebActivity;
import com.bingce.totalstation.TotalStation;
import com.bingce.ui.TabEntity;
import com.bingce.utils.ColorUtil;
import com.bingce.utils.CrashCollector;
import com.bingce.utils.DateUtils;
import com.bingce.utils.LCDeviceUtil;
import com.bingce.utils.SdkUtils;
import com.bingce.utils.ServiceDateUtils;
import com.bingce.utils.SoundPoolUtil;
import com.bingce.utils.StringUtil;
import com.bingce.utils.ThreadPoolUtil;
import com.bingce.utils.Util;
import com.bingce.utils.VipManager;
import com.daimajia.numberprogressbar.NumberProgressBar;
import com.flyco.tablayout.CommonTabLayout;
import com.flyco.tablayout.listener.CustomTabEntity;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.jkyeo.splashview.SplashView;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.material_design_iconic_typeface_library.MaterialDesignIconic;
import com.tencent.mm.opensdk.openapi.IWXAPI;
@ -98,11 +89,9 @@ import java.util.List;
import blankj.utilcode.util.ActivityUtils;
import blankj.utilcode.util.ServiceUtils;
import blankj.utilcode.util.StringUtils;
import blankj.utilcode.util.ToastUtils;
import blankj.utilcode.util.Utils;
import cn.leancloud.LCException;
import cn.leancloud.LCFile;
import cn.leancloud.LCObject;
import cn.leancloud.LCQuery;
import cn.leancloud.LCUser;
@ -163,19 +152,6 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
}
});
}
updateHeaderResult();
LCDeviceUtil.updateDeviceInfo("controlnetwork", ((App) Utils.getApp()).registerCodeV2, null);
checkAgreementPermission();
//解决某个版本的bug:
//由于升级数据库,导致限差方案丢失,所以启动的时候检测所有project,为没有限差的项目重新添加限差
// DatabaseFixUtils.changeDefaultTolerance();
//尝试上传crashLog
ThreadPoolUtil.execute(() -> CrashCollector.tryUploadCrashLogInWorkerThread(this, CrashCollector.APP_LABEL_CONTROL));
LeanCloudConfigLoader.loadLeanCloudConfig();
}
/**
@ -475,14 +451,6 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
//如果是从其他Activity返回到MainActivity时,不显示广告,如果是从后台切换出来,检查并显示广告;
//一定放到super.onResume前,否则TopActivity始终是MainActivity,因为App的onActivityResumed在super.onResume内执行
if (((App) Utils.getApp()).isUserStatusChanged) {
((App) Utils.getApp()).isUserStatusChanged = false;
// if (drawerLeft != null)
// drawerLeft.openDrawer();
// if (accountHeader != null)
// accountHeader.toggleSelectionList(MainActivity.this);
updateHeaderResult();
}
//按照设置选项,保持屏幕常亮,放在onResume而不放在onCreate里是因为,用户更改设置后返回主页就要开始常亮了
boolean isWakeLock = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("key_is_wake_lock", false);
if (isWakeLock) {
@ -693,240 +661,6 @@ public class MainActivity extends BaseMainActivity implements Device.IDeviceConn
}
}
/**
* 教程列表
*/
public void showTutorialListDialog() {
new MaterialDialog.Builder(this)
.title(R.string.video_tutorial)
.items(new String[]{getString(R.string.bilibili)
, getString(R.string.tencent_video)
, getString(R.string.baidudisk)
, getString(R.string.surveyor_home)})
.itemsCallback(new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
switch (which) {
case 0:
// Intent intent1 = new Intent();
// intent1.setClass(Utils.getApp(), AgentWebActivity.class);
// intent1.putExtra("short_url", "android_url_bilibili_tutorial");
// startActivity(intent1);
AgentWebActivity.navigation2(
MainActivity.this, "android_url_bilibili_tutorial"
);
break;
case 1:
// Intent intent2 = new Intent();
// intent2.setClass(Utils.getApp(), AgentWebActivity.class);
// intent2.putExtra("short_url", "android_url_tencent_video_tutorial");
// startActivity(intent2);
AgentWebActivity.navigation2(
MainActivity.this, "android_url_tencent_video_tutorial"
);
break;
case 2:
// Intent intent3 = new Intent();
// intent3.setClass(Utils.getApp(), AgentWebActivity.class);
// intent3.putExtra("short_url", "android_url_baidu_pan_tutorial");
// startActivity(intent3);
AgentWebActivity.navigation2(
MainActivity.this, "android_url_baidu_pan_tutorial"
);
break;
case 3:
// Intent intent4 = new Intent();
// intent4.setClass(Utils.getApp(), AgentWebActivity.class);
// intent4.putExtra("short_url", "android_url_surveyor_home");
// startActivity(intent4);
AgentWebActivity.navigation2(
MainActivity.this, "android_url_surveyor_home"
);
break;
}
}
}).show();
}
/**
* 刷新左侧用户信息
*/
public void updateHeaderResult() {
Log.d("updateHeaderResult", "updateHeaderResult");
// if (drawerLeft == null || accountHeader == null)
// return;
// for (int i = accountHeader.getProfiles().size() - 1; i >= 0; i--) {
// accountHeader.removeProfile(accountHeader.getProfiles().get(i));
// }
// if (LCUser.getCurrentUser() == null || !LCUser.getCurrentUser().isAuthenticated()) {
// accountHeader.addProfiles(
// new ProfileSettingDrawerItem().withName(getString(R.string.log_in))
// .withIcon(new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_sign_in).paddingDp(5))
// .withIdentifier(1000).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
// @Override
// public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
// Intent intent = new Intent(Utils.getApp(), LoginActivity.class);
// intent.putExtra("finishTo", UserInfoActivity.class.getName());
// startActivity(intent);
// return false;
// }
// }));
// } else {
// accountHeader.addProfiles(new ProfileSettingDrawerItem().withName(getString(R.string.user_info)).withIcon(new IconicsDrawable(this).icon(MaterialDesignIconic.Icon.gmi_account).paddingDp(5)).withIdentifier(1000).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
// @Override
// public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
// startActivity(new Intent(MainActivity.this, UserInfoActivity.class));
// return false;
// }
// }));
// }
updateProfileItem();
}
private void updateProfileItem() {
if (LCUser.getCurrentUser() != null) {
String nickname = LCUser.getCurrentUser().getString("nickname");
LCFile avatarFile = LCUser.getCurrentUser().getLCFile("avatar");
if (!StringUtils.isEmpty(nickname)) {
// ProfileDrawerItem item = new ProfileDrawerItem().withName(nickname).withEmail(LCUser.getCurrentUser().getUsername()).withIdentifier(1003);
// if (avatarFile == null) {
// item.withIcon(R.drawable.app_logo);
// } else {
// item.withIcon(avatarFile.getUrl());
// }
// accountHeader.addProfiles(item);
String avatarUrl = null;
if (avatarFile != null) {
avatarUrl = avatarFile.getUrl();
}
mainActivityViewModel.getRefreshLoginUserLiveData().setValue(
new MainUserBean(LCUser.getCurrentUser().getUsername(),
nickname, avatarUrl));
} else {
LCObject userProfile = LCUser.getCurrentUser().getLCObject("profile");
if (userProfile != null) {
userProfile.fetchInBackground().subscribe(new Observer<LCObject>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(LCObject avObject) {
if (isFinishing()) return;
String nickname = avObject.getString("nickname");
LCFile avatarFile = avObject.getLCFile("avatar");
if (!StringUtils.isEmpty(nickname)) {
// ProfileDrawerItem item = new ProfileDrawerItem().withName(nickname).withEmail(LCUser.getCurrentUser().getUsername()).withIdentifier(1003);
// if (avatarFile == null) {
// item.withIcon(R.drawable.app_logo);
// } else {
// item.withIcon(avatarFile.getUrl());
// }
// accountHeader.addProfiles(item);
//保存到_User,下次不再查Profile
LCUser.getCurrentUser().put("nickname", nickname);
String avatarUrl = null;
if (avatarFile != null) {
LCUser.getCurrentUser().put("avatar", avatarFile);
avatarUrl = avatarFile.getUrl();
}
LCUser.getCurrentUser().saveInBackground().subscribe();
mainActivityViewModel.getRefreshLoginUserLiveData().setValue(
new MainUserBean(LCUser.getCurrentUser().getUsername(),
nickname, avatarUrl));
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
} else {
new LCQuery<>("Profile")
.whereEqualTo("creatorId", LCUser.getCurrentUser().getObjectId())
.findInBackground()
.subscribe(new Observer<List<LCObject>>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(List<LCObject> list) {
if (isFinishing()) return;
if (list != null && !list.isEmpty()) {
String nickname = list.get(0).getString("nickname");
LCFile avatarFile = list.get(0).getLCFile("avatar");
if (!StringUtils.isEmpty(nickname)) {
// ProfileDrawerItem item = new ProfileDrawerItem().withName(nickname).withEmail(LCUser.getCurrentUser().getUsername()).withIdentifier(1003);
// if (avatarFile == null) {
// item.withIcon(R.drawable.app_logo);
// } else {
// item.withIcon(avatarFile.getUrl());
// }
// accountHeader.addProfiles(item);
String avatarUrl = null;
//保存到_User,下次不再查Profile
LCUser.getCurrentUser().put("nickname", nickname);
if (avatarFile != null) {
LCUser.getCurrentUser().put("avatar", avatarFile);
avatarUrl = avatarFile.getUrl();
}
LCUser.getCurrentUser().saveInBackground().subscribe();
mainActivityViewModel.getRefreshLoginUserLiveData().setValue(
new MainUserBean(LCUser.getCurrentUser().getUsername(),
nickname, avatarUrl));
}
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
}
}
} else {
// accountHeader.addProfiles(new ProfileDrawerItem().withEmail(getString(R.string.click_avatar_to_log_in)).withIcon(R.drawable.app_logo).withIdentifier(1003));
mainActivityViewModel.getRefreshLoginUserLiveData().setValue(
new MainUserBean(null,
null, null));
}
}
/**
* 开启左侧菜单
*/
public void openLeftDrawer() {
// if (drawerLeft != null)
// drawerLeft.openDrawer();
}
@Override
public void onDeviceConnectLost() {
mainActivityUtils.onDeviceConnectLost();

@ -0,0 +1,62 @@
package com.bingce.controlnetwork.activity;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.WindowManager;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.util.CrashCollectUtils;
import com.bingce.utils.ThreadPoolUtil;
import org.polaric.colorful.ColorfulActivity;
public class ViewRecentCrashActivity extends ColorfulActivity {
@SuppressLint("SourceLockedOrientationActivity")
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_recent_crash_log);
Toolbar mToolbar = findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
TextView textView = findViewById(R.id.tv_content);
if (textView != null) {
ThreadPoolUtil.execute(() -> {
CrashCollectUtils.collectCrashLogInWorkerThread((cloudTable, appLabelKey, fileNameKey, contentKey, uuidKey, crashContent) -> {
if (!TextUtils.isEmpty(crashContent)) {
runOnUiThread(() -> textView.setText(crashContent));
}
});
});
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
}
return super.onOptionsItemSelected(item);
}
public static void start(Context context) {
Intent intent = new Intent(context, ViewRecentCrashActivity.class);
context.startActivity(intent);
}
}

@ -15,8 +15,8 @@ import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.activity.fragmentcontainer.FragmentContainerActivity
import com.bingce.controlnetwork.fragment.SurveyorSettingsFragment
import com.bingce.controlnetwork.fragment.TipsWith2OptionFragment
import com.bingce.controlnetwork.fragment.stationsetting.StationSettingHeightTraverseFragment
import com.bingce.controlnetwork.fragment.stationsurvey.base.MeasureBaseFragment
import com.bingce.controlnetwork.newui.stationsettingheighttraverse.StationSettingsHeightTraverseActivity
import com.bingce.controlnetwork.surveyor.state.heighttraverse.__BaseState
import com.bingce.controlnetwork.surveyor.surveyor.TestDataSelectFragment
import com.bingce.utils.ThreadPoolUtil
@ -171,7 +171,8 @@ class MeasureHeightTraverseFragment : MeasureBaseFragment() {
currentFragment.goBack()
} else if (R.id.menu_item_station_environment_prism_settings == item.itemId) {
//环境、棱镜设置
StationSettingHeightTraverseFragment.start(requireContext(), stationId())
// StationSettingHeightTraverseFragment.start(requireContext(), stationId())
StationSettingsHeightTraverseActivity.start(requireContext(), stationId())
} else if (R.id.menu_item_surveyor_settings == item.itemId) {
//测量设置 设置是否显示平距
ThreadPoolUtil.execute {

@ -30,10 +30,12 @@ class ConfigFragment : BaseFragmentBinding<NewFragmentConfigBinding>() {
//管理
mBinding.ilInstrumentManagement.iv.setImageResource(R.mipmap.icon_ts_connecting)
mBinding.ilInstrumentManagement.tv.setText(R.string.total_station_online)
mBinding.ilLevelConnect.iv.setImageResource(R.mipmap.ic_level_connect)
mBinding.ilLevelConnect.tv.text = "水准仪联机"
mBinding.ilPrismManagement.iv.setImageResource(R.mipmap.icon_prism_manager)
mBinding.ilPrismManagement.tv.setText(R.string.prism_manager)
mBinding.ilCustomTolerance.iv.setImageResource(R.mipmap.ic_tolerance_24)
mBinding.ilCustomTolerance.tv.setText("自定义限差")
mBinding.ilCustomTolerance.tv.text = "自定义限差"
//三角导线联系测量
mBinding.ilExportMeasure.iv.setImageResource(R.mipmap.ic_export)
mBinding.ilExportMeasure.tv.setText(R.string.export)
@ -56,7 +58,11 @@ class ConfigFragment : BaseFragmentBinding<NewFragmentConfigBinding>() {
// val intent = Intent(activity, ConnectTSActivity::class.java)
// intent.putExtra("customChannel", AppChannel.customChannel)
// startActivity(intent)
SelectDeviceTypeUtil.showDeviceTypeDialog()
SelectDeviceTypeUtil.connectTsActivity()
}
mBinding.ilLevelConnect.root.setOnClickListener {
//水准仪联机
SelectDeviceTypeUtil.connectLevelActivity()
}
mBinding.ilPrismManagement.root.setOnClickListener {
//棱镜管理

@ -15,6 +15,7 @@ import cn.leancloud.LCUser
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.activity.AboutActivity
import com.bingce.controlnetwork.activity.SettingsActivity
import com.bingce.controlnetwork.activity.ViewRecentCrashActivity
import com.bingce.controlnetwork.activity.backup.BackupExportActivity
import com.bingce.controlnetwork.activity.backup.launch.BackupImportHelper
import com.bingce.controlnetwork.activity.user.LoginActivity
@ -22,7 +23,6 @@ import com.bingce.controlnetwork.activity.user.UserInfoActivity
import com.bingce.controlnetwork.databinding.NewFragmentMeBinding
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding
import com.bingce.controlnetwork.viewmodel.MainActivityViewModel
import com.bingce.surveyor.agentweb.AgentWebActivity
import com.bumptech.glide.Glide
/**
@ -84,6 +84,8 @@ class MeFragment : BaseFragmentBinding<NewFragmentMeBinding>() {
}
mBinding.llAbout.setOnClickListener {
//关于
Log.d("hwhw", "ss" + 5 / 0)
startActivity(Intent(requireContext(), AboutActivity::class.java))
}
mBinding.llUser.setOnClickListener {
@ -95,6 +97,11 @@ class MeFragment : BaseFragmentBinding<NewFragmentMeBinding>() {
startActivity(intent)
}
}
mBinding.llViewException.setOnClickListener {
//查看异常
startActivity(Intent(requireContext(), ViewRecentCrashActivity::class.java))
}
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {

@ -0,0 +1,5 @@
package com.bingce.controlnetwork.newui.stationsettingheighttraverse
interface IStationSettingOperate {
fun checkSaveNot(): Boolean
}

@ -0,0 +1,213 @@
package com.bingce.controlnetwork.newui.stationsettingheighttraverse
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.EditText
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import blankj.utilcode.util.ToastUtils
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants
import com.bingce.controlapphelper.datasource.database.heighttraverse.stationsetting.model.StationSettingHeightTraverseRecord
import com.bingce.controlapphelper.util.Tools
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.databinding.NewFragmentStationSettingEnvironmentHeightTraverseBinding
import com.bingce.controlnetwork.fragment.stationsetting.BaseStationSettingFragment.Companion.DEFAULT_AIR_PRESSURE
import com.bingce.controlnetwork.fragment.stationsetting.BaseStationSettingFragment.Companion.DEFAULT_CONSTANT
import com.bingce.controlnetwork.fragment.stationsetting.BaseStationSettingFragment.Companion.DEFAULT_TEMPERATURE
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
/**
* 测站设置-环境信息
*/
class StationSettingEnvironmentHeightTraverseFragment :
BaseFragmentBinding<NewFragmentStationSettingEnvironmentHeightTraverseBinding>(),
IStationSettingOperate {
private val viewModel by activityViewModels<StationSettingHeightTraverseVm>()
override fun getViewBinding(
inflater: LayoutInflater,
container: ViewGroup?
): NewFragmentStationSettingEnvironmentHeightTraverseBinding {
return NewFragmentStationSettingEnvironmentHeightTraverseBinding.inflate(
inflater,
container,
false
)
}
override fun initView() {
mBinding.ilDryTemperature.tvName.text = getString(R.string.dry_temperature)
mBinding.ilDryTemperature.etValue.hint = getString(R.string.dry_temperature)
mBinding.ilDryTemperature.tvUnit.text = ""
mBinding.ilHumidityTemperature.tvName.text = getString(R.string.humidity_temperature)
mBinding.ilHumidityTemperature.etValue.hint = getString(R.string.humidity_temperature)
mBinding.ilHumidityTemperature.tvUnit.text = ""
mBinding.ilAirPressure.tvName.text = getString(R.string.hint_air_pressure)
mBinding.ilAirPressure.etValue.hint = getString(R.string.hint_air_pressure)
mBinding.ilAirPressure.tvUnit.text = "hPa"
mBinding.ilAdditionConstant.tvName.text = getString(R.string.addition_constant)
mBinding.ilAdditionConstant.etValue.hint = getString(R.string.addition_constant)
mBinding.ilAdditionConstant.tvUnit.text = "mm"
mBinding.ilmultiplicationConstant.tvName.text = getString(R.string.multiplication_constant)
mBinding.ilmultiplicationConstant.etValue.hint = getString(R.string.multiplication_constant)
mBinding.ilmultiplicationConstant.tvUnit.text = "ppm"
initListener()
}
private fun initListener() {
mBinding.tvLastData.setOnClickListener {
useLastData()
}
mBinding.tvStandardData.setOnClickListener {
setDataFromRecord(null)
}
}
private fun useLastData() {
lifecycleScope.launch {
val record = withContext(Dispatchers.IO) {
val dryTemperature = getValueFromLastKey(ConfigConstants.KEY_LAST_DRY_TEMPERATURE)
val humidityTemperature =
getValueFromLastKey(ConfigConstants.KEY_LAST_HUMIDITY_TEMPERATURE)
val airPressure = getValueFromLastKey(ConfigConstants.KEY_LAST_AIR_PRESSURE)
val additionConstant =
getValueFromLastKey(ConfigConstants.KEY_LAST_ADDITION_CONSTANT)
val multiplicationConstant =
getValueFromLastKey(ConfigConstants.KEY_LAST_MULTIPLICATION_CONSTANT)
val instrumentHeightBefore =
getValueFromLastKey(ConfigConstants.KEY_LAST_INSTRUMENT_HEIGHT_BEFORE)
val instrumentHeightAfter =
getValueFromLastKey(ConfigConstants.KEY_LAST_INSTRUMENT_HEIGHT_AFTER)
val backPrismHeightBefore =
getValueFromLastKey(ConfigConstants.KEY_LAST_BACK_PRISM_HEIGHT_BEFORE)
val backPrismHeightAfter =
getValueFromLastKey(ConfigConstants.KEY_LAST_BACK_PRISM_HEIGHT_AFTER)
val frontPrismHeightBefore =
getValueFromLastKey(ConfigConstants.KEY_LAST_FRONT_PRISM_HEIGHT_BEFORE)
val frontPrismHeightAfter =
getValueFromLastKey(ConfigConstants.KEY_LAST_FRONT_PRISM_HEIGHT_AFTER)
if (dryTemperature == null
|| humidityTemperature == null
|| airPressure == null
|| additionConstant == null
|| multiplicationConstant == null
|| instrumentHeightBefore == null
|| instrumentHeightAfter == null
|| backPrismHeightBefore == null
|| backPrismHeightAfter == null
|| frontPrismHeightBefore == null
|| frontPrismHeightAfter == null
) {
return@withContext null
}
StationSettingHeightTraverseRecord.newInstance(
viewModel.stationId,
dryTemperature,
humidityTemperature,
airPressure,
additionConstant,
multiplicationConstant,
instrumentHeightBefore,
instrumentHeightAfter,
backPrismHeightBefore,
backPrismHeightAfter,
frontPrismHeightBefore,
frontPrismHeightAfter
)
}
setDataFromRecord(record)
}
}
private fun getValueFromLastKey(key: String): String? {
val record =
SurveyorDatabaseFactory.instance.configDataSource.getByKeySync(key)
return record?.configValue
}
override fun initData() {
lifecycleScope.launch {
val record = withContext(Dispatchers.IO) {
SurveyorDatabaseFactory.instance.getStationSettingHeightTraverseDataSource()
.getRecordByStationId(viewModel.stationId)
}
setDataFromRecord(record)
}
}
private fun setDataFromRecord(record: StationSettingHeightTraverseRecord?) {
mBinding.ilDryTemperature.etValue.setText(
record?.dryTemperature ?: DEFAULT_TEMPERATURE
)
mBinding.ilHumidityTemperature.etValue.setText(
record?.humidityTemperature ?: DEFAULT_TEMPERATURE
)
mBinding.ilAirPressure.etValue.setText(record?.airPressure ?: DEFAULT_AIR_PRESSURE)
mBinding.ilAdditionConstant.etValue.setText(
record?.additionConstant ?: DEFAULT_CONSTANT
)
mBinding.ilmultiplicationConstant.etValue.setText(
record?.multiplicationConstant ?: DEFAULT_CONSTANT
)
}
override fun checkSaveNot(): Boolean {
if (editTextEmpty(mBinding.ilDryTemperature.etValue)) {
ToastUtils.showShort(R.string.please_enter_dry_temperature)
return true
}
if (editTextEmpty(mBinding.ilHumidityTemperature.etValue)) {
ToastUtils.showShort(R.string.please_enter_humidity_temperature)
return true
}
if (editTextEmpty(mBinding.ilAirPressure.etValue)) {
ToastUtils.showShort(Tools.getString(R.string.please_enter_air_pressure))
return true
}
if (editTextEmpty(mBinding.ilAdditionConstant.etValue)) {
ToastUtils.showShort(R.string.please_enter_addition_constant)
return true
}
if (editTextEmpty(mBinding.ilmultiplicationConstant.etValue)) {
ToastUtils.showShort(R.string.please_enter_multiplication_constant)
return true
}
setDataToViewModel()
return false
}
private fun setDataToViewModel() {
val dryTemperature = getEtText(mBinding.ilDryTemperature.etValue)
val humidityTemperature = getEtText(mBinding.ilHumidityTemperature.etValue)
val airPressure = getEtText(mBinding.ilAirPressure.etValue)
val additionConstant = getEtText(mBinding.ilAdditionConstant.etValue)
val multiplicationConstant = getEtText(mBinding.ilmultiplicationConstant.etValue)
viewModel.dryTemperature = dryTemperature
viewModel.humidityTemperature = humidityTemperature
viewModel.airPressure = airPressure
viewModel.additionConstant = additionConstant
viewModel.multiplicationConstant = multiplicationConstant
}
private fun editTextEmpty(et: EditText): Boolean {
return TextUtils.isEmpty(getEtText(et))
}
private fun getEtText(et: EditText) = et.text.toString().trim()
}

@ -0,0 +1,151 @@
package com.bingce.controlnetwork.newui.stationsettingheighttraverse
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.EditText
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import blankj.utilcode.util.ToastUtils
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.heighttraverse.stationsetting.model.StationSettingHeightTraverseRecord
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.databinding.NewFragmentStationSettingHeightHeightTraverseBinding
import com.bingce.controlnetwork.fragment.stationsetting.BaseStationSettingFragment.Companion.DEFAULT_INSTRUMEN_HEIGHT
import com.bingce.controlnetwork.newui.base.BaseFragmentBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
/**
* 高程导线-仪高镜高
*/
class StationSettingHeightHeightTraverseFragment :
BaseFragmentBinding<NewFragmentStationSettingHeightHeightTraverseBinding>(),
IStationSettingOperate {
private val viewModel by activityViewModels<StationSettingHeightTraverseVm>()
override fun getViewBinding(
inflater: LayoutInflater,
container: ViewGroup?
): NewFragmentStationSettingHeightHeightTraverseBinding {
return NewFragmentStationSettingHeightHeightTraverseBinding.inflate(
inflater,
container,
false
)
}
override fun initView() {
mBinding.ilInstrumentHeight.tvName.text = getString(R.string.instrument_height)
mBinding.ilBackPrismHeight.tvName.text = getString(R.string.back_prism_height)
mBinding.ilFrontPrismHeight.tvName.text = getString(R.string.front_prism_height)
//仪器高,棱镜高
mBinding.ilInstrumentHeight.button1.setOnClickListener {
mBinding.ilInstrumentHeight.etValueAfter.setText(
getEtText(mBinding.ilInstrumentHeight.etValueBefore)
)
}
mBinding.ilBackPrismHeight.button1.setOnClickListener {
mBinding.ilBackPrismHeight.etValueAfter.setText(
getEtText(mBinding.ilBackPrismHeight.etValueBefore)
)
}
mBinding.ilFrontPrismHeight.button1.setOnClickListener {
mBinding.ilFrontPrismHeight.etValueAfter.setText(
getEtText(mBinding.ilFrontPrismHeight.etValueBefore)
)
}
}
private fun getEtText(et: EditText) = et.text.toString().trim()
override fun initData() {
lifecycleScope.launch {
val record = withContext(Dispatchers.IO) {
SurveyorDatabaseFactory.instance.getStationSettingHeightTraverseDataSource()
.getRecordByStationId(viewModel.stationId)
}
setDataFromRecord(record)
}
}
private fun setDataFromRecord(record: StationSettingHeightTraverseRecord?) {
mBinding.ilInstrumentHeight.etValueBefore.setText(
record?.instrumentHeightBefore ?: DEFAULT_INSTRUMEN_HEIGHT
)
mBinding.ilInstrumentHeight.etValueAfter.setText(
record?.instrumentHeightAfter ?: DEFAULT_INSTRUMEN_HEIGHT
)
mBinding.ilBackPrismHeight.etValueBefore.setText(
record?.backPrismHeightBefore ?: DEFAULT_INSTRUMEN_HEIGHT
)
mBinding.ilBackPrismHeight.etValueAfter.setText(
record?.backPrismHeightAfter ?: DEFAULT_INSTRUMEN_HEIGHT
)
mBinding.ilFrontPrismHeight.etValueBefore.setText(
record?.frontPrismHeightBefore ?: DEFAULT_INSTRUMEN_HEIGHT
)
mBinding.ilFrontPrismHeight.etValueAfter.setText(
record?.frontPrismHeightAfter ?: DEFAULT_INSTRUMEN_HEIGHT
)
}
override fun checkSaveNot(): Boolean {
if (editTextEmpty(mBinding.ilInstrumentHeight.etValueBefore)) {
ToastUtils.showShort(R.string.please_enter_instrument_height_before)
return true
}
if (editTextEmpty(mBinding.ilInstrumentHeight.etValueAfter)) {
ToastUtils.showShort(R.string.please_enter_instrument_height_after)
return true
}
if (editTextEmpty(mBinding.ilBackPrismHeight.etValueBefore)) {
ToastUtils.showShort(R.string.please_enter_back_prism_height_before)
return true
}
if (editTextEmpty(mBinding.ilBackPrismHeight.etValueAfter)) {
ToastUtils.showShort(R.string.please_enter_back_prism_height_after)
return true
}
if (editTextEmpty(mBinding.ilFrontPrismHeight.etValueBefore)) {
ToastUtils.showShort(R.string.please_enter_front_prism_height_before)
return true
}
if (editTextEmpty(mBinding.ilFrontPrismHeight.etValueAfter)) {
ToastUtils.showShort(R.string.please_enter_front_prism_height_after)
return true
}
setDataToViewModel()
return false
}
private fun setDataToViewModel() {
val instrumentHeightBefore = getEtText(mBinding.ilInstrumentHeight.etValueBefore)
val instrumentHeightAfter = getEtText(mBinding.ilInstrumentHeight.etValueAfter)
val backPrismHeightBefore = getEtText(mBinding.ilBackPrismHeight.etValueBefore)
val backPrismHeightAfter = getEtText(mBinding.ilBackPrismHeight.etValueAfter)
val frontPrismHeightBefore = getEtText(mBinding.ilFrontPrismHeight.etValueBefore)
val frontPrismHeightAfter = getEtText(mBinding.ilFrontPrismHeight.etValueAfter)
viewModel.instrumentHeightBefore = instrumentHeightBefore
viewModel.instrumentHeightAfter = instrumentHeightAfter
viewModel.backPrismHeightBefore = backPrismHeightBefore
viewModel.backPrismHeightAfter = backPrismHeightAfter
viewModel.frontPrismHeightBefore = frontPrismHeightBefore
viewModel.frontPrismHeightAfter = frontPrismHeightAfter
}
private fun editTextEmpty(et: EditText): Boolean {
return TextUtils.isEmpty(getEtText(et))
}
}

@ -0,0 +1,21 @@
package com.bingce.controlnetwork.newui.stationsettingheighttraverse
import androidx.lifecycle.ViewModel
class StationSettingHeightTraverseVm : ViewModel() {
lateinit var stationId: String
var instrumentHeightBefore: String? = null
var instrumentHeightAfter: String? = null
var backPrismHeightBefore: String? = null
var backPrismHeightAfter: String? = null
var frontPrismHeightBefore: String? = null
var frontPrismHeightAfter: String? = null
var dryTemperature: String? = null
var humidityTemperature: String? = null
var airPressure: String? = null
var additionConstant: String? = null
var multiplicationConstant: String? = null
}

@ -0,0 +1,317 @@
package com.bingce.controlnetwork.newui.stationsettingheighttraverse
import android.content.Context
import android.content.Intent
import android.view.Menu
import android.view.MenuItem
import androidx.activity.viewModels
import androidx.annotation.WorkerThread
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.lifecycle.lifecycleScope
import androidx.viewpager.widget.ViewPager.OnPageChangeListener
import blankj.utilcode.util.ToastUtils
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants
import com.bingce.controlapphelper.datasource.database.config.ConfigRecord
import com.bingce.controlapphelper.datasource.database.heighttraverse.stationsetting.model.StationSettingHeightTraverseRecord
import com.bingce.controlapphelper.model.BundleConstants
import com.bingce.controlapphelper.util.FastClickUtil
import com.bingce.controlnetwork.R
import com.bingce.controlnetwork.databinding.NewActivityStationSettingBinding
import com.bingce.controlnetwork.newui.base.BaseBindingActivity
import com.bingce.controlnetwork.util.KeyboardUtil
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class StationSettingsHeightTraverseActivity :
BaseBindingActivity<NewActivityStationSettingBinding>() {
private val viewModel by viewModels<StationSettingHeightTraverseVm>()
private val fragments = mutableListOf<Fragment>()
private val fragmentTitleList = listOf("仪高镜高", "环境信息")
companion object {
@JvmStatic
fun start(context: Context, stationId: String?) {
if (stationId == null) {
return
}
context.startActivity(
Intent(
context,
StationSettingsHeightTraverseActivity::class.java
).apply {
putExtra(BundleConstants.KEY_SURVEYOR_STATION_ID, stationId)
})
}
}
override fun getBinding(): NewActivityStationSettingBinding {
return NewActivityStationSettingBinding.inflate(layoutInflater)
}
override fun initView() {
viewModel.stationId = getStationId()
initViewPager()
}
override fun initData() {
}
private fun initViewPager() {
fragments.add(StationSettingHeightHeightTraverseFragment())
fragments.add(StationSettingEnvironmentHeightTraverseFragment())
mBinding.vp.offscreenPageLimit = 3
mBinding.vp.adapter = MyPagerAdapter(supportFragmentManager)
mBinding.tabLayout.setViewPager(mBinding.vp)
mBinding.vp.addOnPageChangeListener(object : OnPageChangeListener {
override fun onPageScrolled(
position: Int,
positionOffset: Float,
positionOffsetPixels: Int
) {
}
override fun onPageSelected(position: Int) {
}
override fun onPageScrollStateChanged(state: Int) {
}
})
// //设置当前tab为仪高镜高
// mBinding.vp.currentItem = 1
}
private inner class MyPagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
override fun getCount(): Int {
return fragments.size
}
override fun getPageTitle(position: Int): CharSequence {
return fragmentTitleList[position]
}
override fun getItem(position: Int): Fragment {
return fragments[position]
}
override fun getItemPosition(`object`: Any): Int {
return POSITION_NONE
}
}
private fun getStationId(): String {
return intent.getStringExtra(BundleConstants.KEY_SURVEYOR_STATION_ID)!!
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_save, menu)
return super.onCreateOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.menuSave) {
FastClickUtil.click {
KeyboardUtil.hideSoftInput()
startSave()
}
}
return super.onOptionsItemSelected(item)
}
private fun startSave() {
//检查未完成的选项
for (fragment in fragments) {
val operate = fragment as IStationSettingOperate
if (operate.checkSaveNot()) {
val fragmentNotFinishPos = fragments.indexOf(fragment)
if (mBinding.vp.currentItem != fragmentNotFinishPos) {
mBinding.tabLayout.currentTab = fragmentNotFinishPos
}
return
}
}
//保存到数据库
saveData()
}
private fun saveData() {
lifecycleScope.launch(Dispatchers.IO) {
val stationId = getStationId()
val stationSettingHeightTraverseRecord =
SurveyorDatabaseFactory.instance.getStationSettingHeightTraverseDataSource()
.getRecordByStationId(stationId)
if (stationSettingHeightTraverseRecord == null) {
val stationSettingHeightTraverseRecordNew =
StationSettingHeightTraverseRecord.newInstance(
stationId,
viewModel.dryTemperature!!,
viewModel.humidityTemperature!!,
viewModel.airPressure!!,
viewModel.additionConstant!!,
viewModel.multiplicationConstant!!,
viewModel.instrumentHeightBefore!!,
viewModel.instrumentHeightAfter!!,
viewModel.backPrismHeightBefore!!,
viewModel.backPrismHeightAfter!!,
viewModel.frontPrismHeightBefore!!,
viewModel.frontPrismHeightAfter!!
)
SurveyorDatabaseFactory.instance.getStationSettingHeightTraverseDataSource()
.saveRecord(stationSettingHeightTraverseRecordNew)
} else {
stationSettingHeightTraverseRecord.dryTemperature = viewModel.dryTemperature!!
stationSettingHeightTraverseRecord.humidityTemperature =
viewModel.humidityTemperature!!
stationSettingHeightTraverseRecord.airPressure = viewModel.airPressure!!
stationSettingHeightTraverseRecord.additionConstant = viewModel.additionConstant!!
stationSettingHeightTraverseRecord.multiplicationConstant =
viewModel.multiplicationConstant!!
stationSettingHeightTraverseRecord.instrumentHeightBefore =
viewModel.instrumentHeightBefore!!
stationSettingHeightTraverseRecord.instrumentHeightAfter =
viewModel.instrumentHeightAfter!!
stationSettingHeightTraverseRecord.backPrismHeightBefore =
viewModel.backPrismHeightBefore!!
stationSettingHeightTraverseRecord.backPrismHeightAfter =
viewModel.backPrismHeightAfter!!
stationSettingHeightTraverseRecord.frontPrismHeightBefore =
viewModel.frontPrismHeightBefore!!
stationSettingHeightTraverseRecord.frontPrismHeightAfter =
viewModel.frontPrismHeightAfter!!
SurveyorDatabaseFactory.instance.getStationSettingHeightTraverseDataSource()
.updateRecord(stationSettingHeightTraverseRecord)
}
val stationRecord =
SurveyorDatabaseFactory.instance.surveyorStation.getRecordSync(stationId)
if (stationRecord != null) {
stationRecord.instrumentHeight = viewModel.instrumentHeightBefore
if (!stationRecord.items.isNullOrEmpty()) {
stationRecord.items.last().prismHeight = viewModel.frontPrismHeightBefore
if (stationRecord.items.size > 2) {
stationRecord.items[1].prismHeight = viewModel.backPrismHeightBefore
}
}
}
SurveyorDatabaseFactory.instance.surveyorStation.update(stationRecord)
saveLastData(
viewModel.dryTemperature!!,
viewModel.humidityTemperature!!,
viewModel.airPressure!!,
viewModel.additionConstant!!,
viewModel.multiplicationConstant!!,
viewModel.instrumentHeightBefore!!,
viewModel.instrumentHeightAfter!!,
viewModel.backPrismHeightBefore!!,
viewModel.backPrismHeightAfter!!,
viewModel.frontPrismHeightBefore!!,
viewModel.frontPrismHeightAfter!!
)
ToastUtils.showShort(R.string.save_success)
}
}
@WorkerThread
private fun saveLastData(
dryTemperature: String,
humidityTemperature: String,
airPressure: String,
additionConstant: String,
multiplicationConstant: String,
instrumentHeightBefore: String,
instrumentHeightAfter: String,
backPrismHeightBefore: String,
backPrismHeightAfter: String,
frontPrismHeightBefore: String,
frontPrismHeightAfter: String
) {
SurveyorDatabaseFactory.instance.configDataSource.recordSync(
ConfigRecord(
ConfigConstants.KEY_LAST_DRY_TEMPERATURE,
dryTemperature
)
)
SurveyorDatabaseFactory.instance.configDataSource.recordSync(
ConfigRecord(
ConfigConstants.KEY_LAST_HUMIDITY_TEMPERATURE,
humidityTemperature
)
)
SurveyorDatabaseFactory.instance.configDataSource.recordSync(
ConfigRecord(
ConfigConstants.KEY_LAST_AIR_PRESSURE,
airPressure
)
)
SurveyorDatabaseFactory.instance.configDataSource.recordSync(
ConfigRecord(
ConfigConstants.KEY_LAST_ADDITION_CONSTANT,
additionConstant
)
)
SurveyorDatabaseFactory.instance.configDataSource.recordSync(
ConfigRecord(
ConfigConstants.KEY_LAST_MULTIPLICATION_CONSTANT,
multiplicationConstant
)
)
SurveyorDatabaseFactory.instance.configDataSource.recordSync(
ConfigRecord(
ConfigConstants.KEY_LAST_INSTRUMENT_HEIGHT_BEFORE,
instrumentHeightBefore
)
)
SurveyorDatabaseFactory.instance.configDataSource.recordSync(
ConfigRecord(
ConfigConstants.KEY_LAST_INSTRUMENT_HEIGHT_AFTER,
instrumentHeightAfter
)
)
SurveyorDatabaseFactory.instance.configDataSource.recordSync(
ConfigRecord(
ConfigConstants.KEY_LAST_BACK_PRISM_HEIGHT_BEFORE,
backPrismHeightBefore
)
)
SurveyorDatabaseFactory.instance.configDataSource.recordSync(
ConfigRecord(
ConfigConstants.KEY_LAST_BACK_PRISM_HEIGHT_AFTER,
backPrismHeightAfter
)
)
SurveyorDatabaseFactory.instance.configDataSource.recordSync(
ConfigRecord(
ConfigConstants.KEY_LAST_FRONT_PRISM_HEIGHT_BEFORE,
frontPrismHeightBefore
)
)
SurveyorDatabaseFactory.instance.configDataSource.recordSync(
ConfigRecord(
ConfigConstants.KEY_LAST_FRONT_PRISM_HEIGHT_AFTER,
frontPrismHeightAfter
)
)
}
override fun onBackPressed() {
if (isFinishAtOnce()) {
super.onBackPressed()
}
}
}

@ -0,0 +1,38 @@
package com.bingce.controlnetwork.newui.stationsettingheighttraverse.model
import androidx.annotation.WorkerThread
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.config.ConfigConstants
import com.bingce.controlapphelper.surveyor.method.model.MeasureConstant
class StationSettingEnvironmentData {
var temperature: String? = null
var humidity: String? = null
var airPress: String? = null
/**
* 获取上次数据
*/
@WorkerThread
fun getLastData() {
val configDataSource = SurveyorDatabaseFactory.instance.getConfigDataSource()
val temperature = configDataSource.getByKeySync(ConfigConstants.KEY_LAST_TEMPERATURE)
val humidity = configDataSource.getByKeySync(ConfigConstants.KEY_LAST_HUMIDITY)
val airPress = configDataSource.getByKeySync(ConfigConstants.KEY_LAST_AIR_PRESSURE)
this.temperature = temperature?.configValue
this.humidity = humidity?.configValue
this.airPress = airPress?.configValue
}
/**
* 获取标准气象数据
*/
fun getStandardData() {
this.temperature = MeasureConstant.DEFAULT_TEMPERATURE
this.humidity = MeasureConstant.DEFAULT_HUMIDITY
this.airPress = MeasureConstant.DEFAULT_AIR_PRESSURE
}
}

@ -0,0 +1,58 @@
package com.bingce.controlnetwork.newui.stationsettingheighttraverse.model
import androidx.annotation.WorkerThread
import com.bingce.controlapphelper.datasource.database.SurveyorDatabaseFactory
import com.bingce.controlapphelper.datasource.database.surveyorstation.SurveyorStationRecord
import com.bingce.controlapphelper.datasource.database.surveyorstation.model.SurveyorPoint
/**
* 高度tab相关数据
*/
class StationSettingHeightData {
private var instrumentHeight: String? = null
val pointList = mutableListOf<SurveyorPoint>()
private val pointNameMap = hashMapOf<String, String>()
private val pointHeightMap = hashMapOf<String, String?>()
@WorkerThread
fun initData(stationRecord: SurveyorStationRecord?) {
if (stationRecord?.items == null) return
instrumentHeight = stationRecord.instrumentHeight
for (point in stationRecord.items) {
if (point.type == SurveyorPoint.TYPE_STATION || point.isWellSteel) {
//忽略站点和钢丝点
continue
}
pointList.add(point)
val pointRecord =
SurveyorDatabaseFactory.instance.getPointDataSource().findByIdSync(point.originalPointId)
pointNameMap[point.originalPointId] = pointRecord.name
pointHeightMap[point.originalPointId] = point.prismHeight
}
}
fun getPointName(pointId: String) = pointNameMap[pointId]
fun getPointHeight(pointId: String): String {
return pointHeightMap[pointId] ?: "0"
}
fun getInstrumentHeight(): String {
return instrumentHeight ?: "0"
}
/**
* 保存时
*/
fun updatePointData(pointIndex: Int, pointHeight: String) {
val surveyorPoint = pointList[pointIndex]
//点高
surveyorPoint.prismHeight = pointHeight
}
}

@ -0,0 +1,101 @@
package com.bingce.controlnetwork.util;
import android.content.Context;
import com.bingce.utils.FileUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import blankj.utilcode.util.FileUtils;
import blankj.utilcode.util.Utils;
public class CrashCollectUtils {
public static File crashLogFolder(Context context) {
File cacheFolder = context.getExternalCacheDir();
if (!cacheFolder.exists() || cacheFolder.isFile()) {
cacheFolder.mkdir();
}
File dir = new File(cacheFolder, "crash");
if (!dir.exists() || dir.isFile()) {
dir.mkdir();
}
return dir;
}
//收集崩溃日志,在处理完成后根据结果删除
public static void collectCrashLogInWorkerThread(ICrashLogCollectListener listener) {
File dir = crashLogFolder(Utils.getApp().getApplicationContext());
//读取其下面的数据
if (!dir.exists() || dir.isFile()) {
return;
}
StringBuilder sb = new StringBuilder();
File[] files = dir.listFiles();
if (files != null) {
List<File> needMoveFileList = new ArrayList<>();
File lastFile = null;
for (File file : files) {
if (file == null || !file.isFile()) {
continue;
}
if (lastFile == null) {
lastFile = file;
} else {
if (file.lastModified() > lastFile.lastModified()) {
lastFile = file;
}
}
needMoveFileList.add(file);
}
needMoveFileList.remove(lastFile);
for (File file : needMoveFileList) {
moveToBackedUpFolder(dir, file);
}
if (lastFile != null) {
FileUtil.ReadFileResult readFileResult = FileUtil.readStringFrom(lastFile);
if (readFileResult.success) {
sb.append(readFileResult.string).append("\n");
}
}
}
String CRASH_LOG_TABLE = "CloudCrashLog";
final String contentKey = "crash_content";
final String fileNameKey = "file_name";
final String appLabelKey = "app";
final String uuidKey = "UUID";
listener.onCollected(CRASH_LOG_TABLE, appLabelKey, fileNameKey, contentKey, uuidKey, sb.toString());
}
private static void moveToBackedUpFolder(File dir, File targetLogFile) {
File repeatedFolder = new File(dir, "BACKED_UP");
if (!repeatedFolder.exists()) {
repeatedFolder.mkdirs();
}
FileUtils.move(targetLogFile, new File(repeatedFolder, targetLogFile.getName()));
}
public interface ICrashLogCollectListener {
void onCollected(String cloudTable, String appLabelKey, String fileNameKey, String contentKey, String uuidKey,
String content);
}
public static class CrashItem {
public final File file;
public final String content;
CrashItem(File file, String content) {
this.file = file;
this.content = content;
}
}
}

@ -21,18 +21,27 @@ public class SelectDeviceTypeUtil {
public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
switch (which) {
case 0:
Intent intent = new Intent(ActivityUtils.getTopActivity(), ConnectTSActivity.class);
intent.putExtra("customChannel", AppChannel.customChannel);
ActivityUtils.getTopActivity().startActivity(intent);
connectTsActivity();
break;
case 1:
Intent intent2 = new Intent(ActivityUtils.getTopActivity(), ConnectLevelActivity.class);
intent2.putExtra("customChannel", AppChannel.customChannel);
ActivityUtils.getTopActivity().startActivity(intent2);
connectLevelActivity();
break;
}
}
}).show();
}
public static void connectTsActivity() {
Intent intent = new Intent(ActivityUtils.getTopActivity(), ConnectTSActivity.class);
intent.putExtra("customChannel", AppChannel.customChannel);
ActivityUtils.getTopActivity().startActivity(intent);
}
public static void connectLevelActivity() {
Intent intent2 = new Intent(ActivityUtils.getTopActivity(), ConnectLevelActivity.class);
intent2.putExtra("customChannel", AppChannel.customChannel);
ActivityUtils.getTopActivity().startActivity(intent2);
}
}

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp">
<TextView
android:id="@+id/tv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp" />
</ScrollView>
</LinearLayout>

@ -35,6 +35,14 @@
android:layout_height="wrap_content"
android:layout_weight="1" />
<include
android:id="@+id/ilLevelConnect"
layout="@layout/new_item_config"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_weight="1" />
<include
android:id="@+id/ilPrismManagement"
layout="@layout/new_item_config"
@ -43,14 +51,38 @@
android:layout_marginStart="12dp"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:orientation="horizontal"
android:weightSum="3">
<include
android:id="@+id/ilCustomTolerance"
layout="@layout/new_item_config"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_weight="1" />
<include
layout="@layout/new_item_config"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_weight="1"
android:visibility="invisible" />
<include
layout="@layout/new_item_config"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_weight="1"
android:visibility="invisible" />
</LinearLayout>
<TextView

@ -213,6 +213,43 @@
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginHorizontal="20dp"
android:background="@color/hor_line" />
<LinearLayout
android:id="@+id/llViewException"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="12dp">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@mipmap/ic_view_exception" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_weight="1"
android:text="查看异常"
android:textColor="@color/text_color_1"
android:textSize="@dimen/text_size_one" />
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:padding="6dp"
android:src="@drawable/ic_arrow_to_right_dark" />
</LinearLayout>
</LinearLayout>

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:background="@drawable/round_white_16"
android:orientation="vertical"
android:showDividers="middle">
<include
android:id="@+id/ilDryTemperature"
layout="@layout/item_station_setting_1_edittext" />
<include
android:id="@+id/ilHumidityTemperature"
layout="@layout/item_station_setting_1_edittext" />
<include
android:id="@+id/ilAirPressure"
layout="@layout/item_station_setting_1_edittext" />
<include
android:id="@+id/ilAdditionConstant"
layout="@layout/item_station_setting_1_edittext" />
<include
android:id="@+id/ilmultiplicationConstant"
layout="@layout/item_station_setting_1_edittext" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal"
android:padding="12dp"
android:visibility="visible">
<TextView
android:id="@+id/tvLastData"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="1"
android:background="@drawable/round_btn_bg_gray_3"
android:gravity="center"
android:text="使用上次数据"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/edit_text" />
<TextView
android:id="@+id/tvStandardData"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_marginStart="15dp"
android:layout_weight="1"
android:background="@drawable/round_btn_bg_colormay_3"
android:gravity="center"
android:text="使用标准气象"
android:textColor="@color/white"
android:textSize="@dimen/edit_text" />
</LinearLayout>
</LinearLayout>

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="12dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/round_white_16"
android:orientation="vertical"
android:showDividers="middle">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.6"
android:padding="10dp"
android:text="@string/category"
android:textAppearance="?attr/textAppearanceListItem" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:padding="10dp"
android:text="@string/pre_test"
android:textAppearance="?attr/textAppearanceListItem" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:padding="10dp"
android:text="@string/post_test"
android:textAppearance="?attr/textAppearanceListItem" />
<Button
android:id="@+id/button1"
style="@style/alert_dialog_button_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="9dp"
android:textColor="?colorPrimary"
android:textSize="15sp"
android:visibility="invisible" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/color_cccccc" />
<include
android:id="@+id/ilInstrumentHeight"
layout="@layout/item_station_setting_2_edit_text_height_traverse" />
<include
android:id="@+id/ilBackPrismHeight"
layout="@layout/item_station_setting_2_edit_text_height_traverse" />
<include
android:id="@+id/ilFrontPrismHeight"
layout="@layout/item_station_setting_2_edit_text_height_traverse" />
</LinearLayout>
<TextView
android:layout_marginTop="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/staton_setting_height_traverse_hint"
android:textColor="@color/nliveo_red_colorPrimary" />
</LinearLayout>
</ScrollView>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Loading…
Cancel
Save