mirror of
https://github.com/niushuai233/DevControl.git
synced 2024-10-27 22:43:20 +08:00
fix: 可根据设备类型跳转到不同的设备操作页
This commit is contained in:
parent
2dbdf57e26
commit
d238867bc4
@ -1,5 +1,8 @@
|
|||||||
package cc.niushuai.project.devcontrol.base.enums;
|
package cc.niushuai.project.devcontrol.base.enums;
|
||||||
|
|
||||||
|
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
||||||
|
import cc.niushuai.project.devcontrol.ui.powerswitch.PowerSwitchActivity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备类型枚举
|
* 设备类型枚举
|
||||||
*
|
*
|
||||||
@ -11,11 +14,31 @@ public enum DeviceTypeEnum {
|
|||||||
/**
|
/**
|
||||||
* 开关
|
* 开关
|
||||||
*/
|
*/
|
||||||
Switch,
|
Switch("Switch", PowerSwitchActivity.class),
|
||||||
|
;
|
||||||
|
|
||||||
/**
|
|
||||||
* 未知
|
|
||||||
*/
|
|
||||||
Unknown;
|
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
private Class<? extends BaseActivity> activity;
|
||||||
|
|
||||||
|
DeviceTypeEnum(String value, Class<? extends BaseActivity> activity) {
|
||||||
|
this.value = value;
|
||||||
|
this.activity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<? extends BaseActivity> getActivity() {
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivity(Class<? extends BaseActivity> activity) {
|
||||||
|
this.activity = activity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import cc.niushuai.project.devcontrol.R;
|
import cc.niushuai.project.devcontrol.R;
|
||||||
import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo;
|
import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo;
|
||||||
|
import cc.niushuai.project.devcontrol.base.util.GlobalVariables;
|
||||||
import cc.niushuai.project.devcontrol.base.util.Keys;
|
import cc.niushuai.project.devcontrol.base.util.Keys;
|
||||||
import cc.niushuai.project.devcontrol.databinding.DeviceItemBinding;
|
import cc.niushuai.project.devcontrol.databinding.DeviceItemBinding;
|
||||||
import cc.niushuai.project.devcontrol.databinding.MainNavFragmentDeviceBinding;
|
import cc.niushuai.project.devcontrol.databinding.MainNavFragmentDeviceBinding;
|
||||||
@ -116,7 +117,8 @@ public class NavDeviceFragment extends Fragment {
|
|||||||
private void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
private void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
TextView textId = view.findViewById(R.id.device_item_cardView_id);
|
TextView textId = view.findViewById(R.id.device_item_cardView_id);
|
||||||
|
|
||||||
Intent intent = new Intent(getActivity(), PowerSwitchActivity.class);
|
DeviceInfo deviceInfo = GlobalVariables.DEVICE_INFO_MAP.get(textId.getText());
|
||||||
|
Intent intent = new Intent(getActivity(), deviceInfo.getType().getActivity());
|
||||||
intent.putExtra(Keys.ID, textId.getText());
|
intent.putExtra(Keys.ID, textId.getText());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user