From 79f922d1df63e0b67d3c673233d2de8225f9fad7 Mon Sep 17 00:00:00 2001 From: niushuai233 Date: Tue, 25 Oct 2022 13:55:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AE=BE=E7=BD=AE=E5=9B=9E=E6=98=BE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/devcontrol/base/util/UiUtil.java | 14 +++++++++++++ .../PowerSwitchSetParamActivity.java | 21 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/base/util/UiUtil.java b/app/src/main/java/cc/niushuai/project/devcontrol/base/util/UiUtil.java index 64b1871..bff2e9e 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/base/util/UiUtil.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/base/util/UiUtil.java @@ -4,8 +4,11 @@ import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.util.TypedValue; +import android.widget.ImageView; import android.widget.TextView; +import androidx.appcompat.widget.AppCompatImageView; + public class UiUtil { public static int dip2px(Context context, float dipValue) { @@ -17,4 +20,15 @@ public class UiUtil { public static String getTextViewTextById(Activity activity, int id) { return ((TextView) activity.findViewById(id)).getText().toString(); } + + public static void setTextViewTextById(Activity activity, int id, String text) { + ((TextView) activity.findViewById(id)).setText(text); + } + + public static void setImageResource(Activity activity, int id, int resId) { + ((ImageView) activity.findViewById(id)).setImageResource(resId); + } + public static void setAppImageCompatResource(Activity activity, int id, int resId) { + ((AppCompatImageView) activity.findViewById(id)).setImageResource(resId); + } } diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetParamActivity.java b/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetParamActivity.java index fc3dc05..ebc73ab 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetParamActivity.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetParamActivity.java @@ -2,6 +2,7 @@ package cc.niushuai.project.devcontrol.ui.powerswitch; import android.os.Bundle; import android.view.View; +import android.widget.TextView; import android.widget.Toast; import androidx.annotation.Nullable; @@ -10,6 +11,7 @@ import cc.niushuai.project.devcontrol.R; import cc.niushuai.project.devcontrol.base.ui.BaseActivity; import cc.niushuai.project.devcontrol.base.util.GlobalVariables; import cc.niushuai.project.devcontrol.base.util.ToastUtil; +import cc.niushuai.project.devcontrol.base.util.UiUtil; import cc.niushuai.project.devcontrol.databinding.ActivityPowerSwitchSetParamBinding; @@ -34,8 +36,27 @@ public class PowerSwitchSetParamActivity extends BaseActivity { this.setTitle(null, getString(R.string.power_switch_set_paramSet), null, R.drawable.ic_confrim_32); + this.echoData(); + } + /** + * 回显数据 + * + * @author niushuai + * @date: 2022/10/25 9:01 + */ + private void echoData() { + + UiUtil.setTextViewTextById(this, R.id.device_add_name, device.getDeviceName()); + UiUtil.setTextViewTextById(this, R.id.device_add_param_program, device.getCommandPath()); + UiUtil.setTextViewTextById(this, R.id.device_add_param_status, device.getCommandStatus()); + UiUtil.setTextViewTextById(this, R.id.device_add_param_open, device.getCommandOpen()); + UiUtil.setTextViewTextById(this, R.id.device_add_param_close, device.getCommandClose()); + UiUtil.setTextViewTextById(this, R.id.device_add_param_remark, device.getRemark()); + + UiUtil.setAppImageCompatResource(this, R.id.device_add_select_icon, device.getIconId()); + } @Override protected void addListener() {