mirror of
https://github.com/niushuai233/DevControl.git
synced 2024-10-27 22:43:20 +08:00
refactor: 结构重组
This commit is contained in:
parent
af5212a0be
commit
b301ffff70
@ -0,0 +1,55 @@
|
||||
package cc.niushuai.project.devcontrol.base.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* vo基类
|
||||
*
|
||||
* @author niushuai233
|
||||
* @date 2022/10/24 15:58
|
||||
*/
|
||||
public class BaseVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6464433262287575127L;
|
||||
|
||||
private String id;
|
||||
|
||||
private Integer isDeleted;
|
||||
|
||||
private String remark;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getIsDeleted() {
|
||||
return isDeleted;
|
||||
}
|
||||
|
||||
public void setIsDeleted(Integer isDeleted) {
|
||||
this.isDeleted = isDeleted;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ import androidx.appcompat.widget.AppCompatImageButton;
|
||||
import java.util.Map;
|
||||
|
||||
import cc.niushuai.project.devcontrol.R;
|
||||
import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo;
|
||||
import cc.niushuai.project.devcontrol.vo.DeviceInfo;
|
||||
import cc.niushuai.project.devcontrol.base.util.ActivityUtil;
|
||||
import cc.niushuai.project.devcontrol.base.util.Keys;
|
||||
import cc.niushuai.project.devcontrol.base.util.UiUtil;
|
||||
|
@ -3,7 +3,7 @@ package cc.niushuai.project.devcontrol.base.util;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo;
|
||||
import cc.niushuai.project.devcontrol.vo.DeviceInfo;
|
||||
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
||||
|
||||
public class GlobalVariables {
|
||||
|
@ -3,10 +3,9 @@ package cc.niushuai.project.devcontrol.ui.deviceadd;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import cc.niushuai.project.devcontrol.R;
|
||||
import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo;
|
||||
import cc.niushuai.project.devcontrol.vo.DeviceInfo;
|
||||
import cc.niushuai.project.devcontrol.base.enums.DeviceTypeEnum;
|
||||
import cc.niushuai.project.devcontrol.base.enums.OnOffEnum;
|
||||
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
||||
@ -70,15 +69,15 @@ public class DeviceAddPowerSwitchActivity extends BaseActivity {
|
||||
device.setIconId(R.drawable.ic_device_type_switch);
|
||||
device.setDeviceType(DeviceTypeEnum.Power_Switch);
|
||||
device.setOnOff(OnOffEnum.OFF);
|
||||
device.setName(binding.deviceAddName.getText().toString());
|
||||
device.setDescription("默认设备");
|
||||
device.setDeviceName(binding.deviceAddName.getText().toString());
|
||||
device.setRemark("默认设备");
|
||||
device.setCommandPath(binding.deviceAddParamProgram.getText().toString());
|
||||
device.setCommandOpen(binding.deviceAddParamOpen.getText().toString());
|
||||
device.setCommandClose(binding.deviceAddParamClose.getText().toString());
|
||||
|
||||
GlobalVariables.DEVICE_INFO_MAP.put(device.getId(), device);
|
||||
|
||||
ToastUtil.show(this, StrUtil.format("设备: {} 已新增", device.getName()));
|
||||
ToastUtil.show(this, StrUtil.format("设备: {} 已新增", device.getDeviceName()));
|
||||
|
||||
this.finish();
|
||||
ActivityUtil.startActivity(this, PowerSwitchActivity.class, new String[]{Keys.ID}, new String[]{device.getId()});
|
||||
|
@ -20,7 +20,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import cc.niushuai.project.devcontrol.R;
|
||||
import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo;
|
||||
import cc.niushuai.project.devcontrol.vo.DeviceInfo;
|
||||
import cc.niushuai.project.devcontrol.base.util.GlobalVariables;
|
||||
import cc.niushuai.project.devcontrol.base.util.Keys;
|
||||
import cc.niushuai.project.devcontrol.databinding.DeviceItemBinding;
|
||||
@ -107,7 +107,7 @@ public class NavDeviceFragment extends Fragment {
|
||||
// 设置当前设备的图标和名称
|
||||
m1.put("device_item_cardView_id", deviceInfo.getId());
|
||||
m1.put("device_item_cardView_image", deviceInfo.getIconId());
|
||||
m1.put("device_item_cardView_text", deviceInfo.getName());
|
||||
m1.put("device_item_cardView_text", deviceInfo.getDeviceName());
|
||||
|
||||
// 统一添加到data中
|
||||
gvData.add(m1);
|
||||
|
@ -9,7 +9,6 @@ import androidx.appcompat.widget.AppCompatImageView;
|
||||
import java.util.HashMap;
|
||||
|
||||
import cc.niushuai.project.devcontrol.R;
|
||||
import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo;
|
||||
import cc.niushuai.project.devcontrol.base.enums.OnOffEnum;
|
||||
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
||||
import cc.niushuai.project.devcontrol.base.util.GlobalVariables;
|
||||
@ -44,10 +43,10 @@ public class PowerSwitchActivity extends BaseActivity {
|
||||
|
||||
this.device = GlobalVariables.getDeviceInfo(getIntentDeviceId());
|
||||
// 标题名称
|
||||
super.setTitle(this.device.getName(), this.device.getDescription());
|
||||
super.setTitle(this.device.getDeviceName(), this.device.getRemark());
|
||||
// 开关底部的名称
|
||||
TextView contentTextTextView = findViewById(R.id.power_switch_activity_content_text);
|
||||
contentTextTextView.setText(device.getName());
|
||||
contentTextTextView.setText(device.getDeviceName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,13 +1,13 @@
|
||||
package cc.niushuai.project.devcontrol.base.entity.device;
|
||||
package cc.niushuai.project.devcontrol.vo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cc.niushuai.project.devcontrol.base.entity.BaseVO;
|
||||
import cc.niushuai.project.devcontrol.base.enums.DeviceTypeEnum;
|
||||
import cc.niushuai.project.devcontrol.base.enums.OnOffEnum;
|
||||
import cc.niushuai.project.devcontrol.base.util.GlobalVariables;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cc.niushuai.project.devcontrol.base.util.IdWorker;
|
||||
|
||||
/**
|
||||
* 设备信息实体数据类
|
||||
@ -15,17 +15,12 @@ import cn.hutool.core.util.StrUtil;
|
||||
* @author niushuai
|
||||
* @date: 2022/10/17 16:47
|
||||
*/
|
||||
public class DeviceInfo {
|
||||
|
||||
/**
|
||||
* 主id 唯一标识
|
||||
*/
|
||||
private String id;
|
||||
public class DeviceInfo extends BaseVO {
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String name;
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
@ -37,11 +32,6 @@ public class DeviceInfo {
|
||||
*/
|
||||
private OnOffEnum onOff;
|
||||
|
||||
/**
|
||||
* 设备描述信息
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 设备列表界面 list icon id
|
||||
*/
|
||||
@ -70,20 +60,12 @@ public class DeviceInfo {
|
||||
*/
|
||||
private List<String> commandExtra;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
public String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public DeviceTypeEnum getDeviceType() {
|
||||
@ -102,20 +84,12 @@ public class DeviceInfo {
|
||||
this.onOff = onOff;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int getIconId() {
|
||||
return iconId;
|
||||
}
|
||||
|
||||
public void setIconId(int listIconId) {
|
||||
this.iconId = listIconId;
|
||||
public void setIconId(int iconId) {
|
||||
this.iconId = iconId;
|
||||
}
|
||||
|
||||
public String getCommandPath() {
|
||||
@ -162,10 +136,10 @@ public class DeviceInfo {
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
DeviceInfo device = new DeviceInfo();
|
||||
device.setId(IdUtil.nanoId());
|
||||
device.setName("卧室灯开关" + (i + 1));
|
||||
device.setId(IdWorker.getNextIdStr());
|
||||
device.setDeviceName("卧室灯开关" + (i + 1));
|
||||
device.setIconId(iconId);
|
||||
device.setDescription("卧室灯开关-树莓派");
|
||||
device.setRemark("卧室灯开关-树莓派");
|
||||
device.setDeviceType(DeviceTypeEnum.Power_Switch);
|
||||
device.setOnOff(OnOffEnum.OFF);
|
||||
device.setCommandPath("/path/file");
|
Loading…
x
Reference in New Issue
Block a user