From 129553f1f7f9df6a0d7bae0561140e48df9ba9f2 Mon Sep 17 00:00:00 2001 From: niushuai233 Date: Fri, 28 Oct 2022 16:45:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=B9=E6=8D=AE=E5=BC=80=E5=85=B3?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=88=9D=E5=A7=8B=E5=8C=96=E7=81=AF=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/powerswitch/PowerSwitchActivity.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchActivity.java b/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchActivity.java index 8d24127..c1900bb 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchActivity.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchActivity.java @@ -51,6 +51,21 @@ public class PowerSwitchActivity extends BaseActivity { // 开关底部的名称 TextView contentTextTextView = findViewById(R.id.power_switch_activity_content_text); 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); } /**