New file |
| | |
| | | package com.dayu.qihealonelibrary.activity; |
| | | |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.view.LayoutInflater; |
| | | |
| | | import com.dayu.baselibrary.utils.TipUtil; |
| | | |
| | | import com.dayu.qihealonelibrary.databinding.ActivityDomainQhaBinding; |
| | | import com.dayu.qihealonelibrary.dbBean.DomainBean; |
| | | |
| | | |
| | | /** |
| | | * Created by Android Studio. |
| | | * author: zuo |
| | | * Date: 2023-11-14 |
| | | * Time: 10:19 |
| | | * 备注: 设置卡域名和ip |
| | | */ |
| | | public class DomainActivityQHAlone extends QHAloneBaseActivity { |
| | | ActivityDomainQhaBinding binding; |
| | | DomainBean domainBean; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | binding = ActivityDomainQhaBinding.inflate(LayoutInflater.from(this)); |
| | | setContentView(binding.getRoot()); |
| | | initData(); |
| | | binding.electricOk.setOnClickListener(v -> { |
| | | String domainNumber = binding.domainNumber.getText().toString(); |
| | | String domain = binding.domain.getText().toString(); |
| | | String port = binding.port.getText().toString(); |
| | | int portInt = 0; |
| | | if (TextUtils.isEmpty(domainNumber)) { |
| | | TipUtil.show("请输入正确的域名序号"); |
| | | return; |
| | | } |
| | | if (TextUtils.isEmpty(port)) { |
| | | TipUtil.show("请输入正确的端口号"); |
| | | return; |
| | | } else { |
| | | portInt = Integer.valueOf(port); |
| | | } |
| | | if (TextUtils.isEmpty(domain)) { |
| | | TipUtil.show("请输入域名"); |
| | | return; |
| | | } else if (portInt <= 0 || portInt > 65535) { |
| | | TipUtil.show("请输入正确的端口号"); |
| | | return; |
| | | } |
| | | domainBean.setDomainNumber(domainNumber); |
| | | domainBean.setDomain(domain); |
| | | domainBean.setPort(portInt); |
| | | baseDao.domainPortDao().insert(domainBean); |
| | | TipUtil.show("保存成功"); |
| | | initData(); |
| | | }); |
| | | initData(); |
| | | } |
| | | |
| | | private void initData() { |
| | | domainBean = baseDao.domainPortDao().findFirst(); |
| | | if (domainBean != null) { |
| | | binding.domainOldTV.setText("序号:" + domainBean.getDomainNumber() + "\n" + "域名:" + domainBean.getDomain() + "\n" + "端口号:" + domainBean.getPort()); |
| | | } else { |
| | | domainBean = new DomainBean(); |
| | | binding.domainOldTV.setText("请设置新的域名卡信息"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |