mirror of
https://github.com/niushuai233/DevControl.git
synced 2024-10-27 22:43:20 +08:00
feat: 根据开关状态初始化灯状态
This commit is contained in:
parent
944705062c
commit
129553f1f7
@ -51,6 +51,21 @@ public class PowerSwitchActivity extends BaseActivity {
|
|||||||
// 开关底部的名称
|
// 开关底部的名称
|
||||||
TextView contentTextTextView = findViewById(R.id.power_switch_activity_content_text);
|
TextView contentTextTextView = findViewById(R.id.power_switch_activity_content_text);
|
||||||
contentTextTextView.setText(device.getDeviceName());
|
contentTextTextView.setText(device.getDeviceName());
|
||||||
|
|
||||||
|
|
||||||
|
int switchImageId, iconImageId;
|
||||||
|
if (OnOffEnum.OFF.equals(device.getOnOff())) {
|
||||||
|
device.setOnOff(OnOffEnum.ON);
|
||||||
|
switchImageId = R.drawable.img_switch_open;
|
||||||
|
iconImageId = R.drawable.ic_device_light_1_on;
|
||||||
|
} else {
|
||||||
|
device.setOnOff(OnOffEnum.OFF);
|
||||||
|
switchImageId = R.drawable.img_switch_close;
|
||||||
|
iconImageId = R.drawable.ic_device_light_1_close;
|
||||||
|
}
|
||||||
|
|
||||||
|
((AppCompatImageView) findViewById(R.id.power_switch_activity_content_switch)).setImageResource(switchImageId);
|
||||||
|
((AppCompatImageView) findViewById(R.id.power_switch_activity_content_icon)).setImageResource(iconImageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user