mirror of
https://github.com/niushuai233/DevControl.git
synced 2024-10-27 22:43:20 +08:00
refactor: 修改字段名为deviceType
This commit is contained in:
parent
d238867bc4
commit
61e6a875ed
@ -30,7 +30,7 @@ public class DeviceInfo {
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private DeviceTypeEnum type;
|
||||
private DeviceTypeEnum deviceType;
|
||||
|
||||
/**
|
||||
* 开关状态
|
||||
@ -79,12 +79,12 @@ public class DeviceInfo {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public DeviceTypeEnum getType() {
|
||||
return type;
|
||||
public DeviceTypeEnum getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public void setType(DeviceTypeEnum type) {
|
||||
this.type = type;
|
||||
public void setDeviceType(DeviceTypeEnum deviceType) {
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
public OnOffEnum getOnOff() {
|
||||
@ -148,7 +148,7 @@ public class DeviceInfo {
|
||||
device.setName("卧室灯开关" + (i + 1));
|
||||
device.setIconId(iconId);
|
||||
device.setDescription("卧室灯开关-树莓派");
|
||||
device.setType(DeviceTypeEnum.Switch);
|
||||
device.setDeviceType(DeviceTypeEnum.Switch);
|
||||
device.setOnOff(OnOffEnum.OFF);
|
||||
device.setCommandPath("/path/file");
|
||||
device.setCommandArgs("-c light -t 1");
|
||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo;
|
||||
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
||||
|
||||
public class GlobalVariables {
|
||||
|
||||
@ -13,5 +14,8 @@ public class GlobalVariables {
|
||||
*/
|
||||
public static final Map<String, DeviceInfo> DEVICE_INFO_MAP = new HashMap<>(16);
|
||||
|
||||
public static Class<? extends BaseActivity> getDeviceOperateActivity(String deviceId) {
|
||||
return DEVICE_INFO_MAP.get(deviceId).getDeviceType().getActivity();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -117,8 +117,7 @@ public class NavDeviceFragment extends Fragment {
|
||||
private void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
TextView textId = view.findViewById(R.id.device_item_cardView_id);
|
||||
|
||||
DeviceInfo deviceInfo = GlobalVariables.DEVICE_INFO_MAP.get(textId.getText());
|
||||
Intent intent = new Intent(getActivity(), deviceInfo.getType().getActivity());
|
||||
Intent intent = new Intent(getActivity(), GlobalVariables.getDeviceOperateActivity(textId.getText().toString()));
|
||||
intent.putExtra(Keys.ID, textId.getText());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user