New file |
| | |
| | | package com.dayu.qihealonelibrary.activity; |
| | | |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | |
| | | import com.dayu.baselibrary.utils.TipUtil; |
| | | import com.dayu.qihealonelibrary.databinding.ActivityRegionQhaBinding; |
| | | import com.dayu.qihealonelibrary.dbBean.RegionBean; |
| | | |
| | | |
| | | /** |
| | | * author: zuo |
| | | * Date: 2024-03-06 |
| | | * Time: 17:28 |
| | | * 备注:区域标号卡设置界面 |
| | | */ |
| | | public class RegionActivity extends BaseActivity { |
| | | |
| | | |
| | | ActivityRegionQhaBinding binding; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | binding = ActivityRegionQhaBinding.inflate(LayoutInflater.from(this)); |
| | | setContentView(binding.getRoot()); |
| | | initView(); |
| | | initData(); |
| | | } |
| | | |
| | | private void initData() { |
| | | RegionBean regionBean = baseDao.regionDao().findFirst(); |
| | | if (regionBean!=null){ |
| | | binding.controllerOldText.setText(regionBean.getControllerCodel()); |
| | | binding.regionOldText.setText(regionBean.getRegion()); |
| | | }else { |
| | | binding.controllerOldText.setText("当前为默认值"); |
| | | binding.regionOldText.setText("当前为默认值"); |
| | | } |
| | | } |
| | | |
| | | private void initView() { |
| | | |
| | | |
| | | binding.electricOk.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | String region = binding.regionNewET.getText().toString(); |
| | | String controller = binding.controllerNewET.getText().toString(); |
| | | if (TextUtils.isEmpty(region)) { |
| | | TipUtil.show("请输入新区域地址"); |
| | | return; |
| | | } |
| | | if (TextUtils.isEmpty(controller)) { |
| | | TipUtil.show("请输入新控制器编号"); |
| | | return; |
| | | } |
| | | RegionBean regionBean=new RegionBean(); |
| | | regionBean.setRegion(region); |
| | | regionBean.setControllerCodel(controller); |
| | | baseDao.regionDao().insert(regionBean); |
| | | TipUtil.show("保存成功"); |
| | | initData(); |
| | | } |
| | | }); |
| | | } |
| | | } |