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 0259371..64b1871 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 @@ -1,8 +1,10 @@ package cc.niushuai.project.devcontrol.base.util; +import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.util.TypedValue; +import android.widget.TextView; public class UiUtil { @@ -11,4 +13,8 @@ public class UiUtil { return (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, dipValue, r.getDisplayMetrics()); } + + public static String getTextViewTextById(Activity activity, int id) { + return ((TextView) activity.findViewById(id)).getText().toString(); + } } diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/ui/deviceadd/DeviceAddPowerSwitchActivity.java b/app/src/main/java/cc/niushuai/project/devcontrol/ui/deviceadd/DeviceAddPowerSwitchActivity.java index 462d01b..1429efd 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/ui/deviceadd/DeviceAddPowerSwitchActivity.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/ui/deviceadd/DeviceAddPowerSwitchActivity.java @@ -3,10 +3,14 @@ package cc.niushuai.project.devcontrol.ui.deviceadd; import android.os.Bundle; import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; import cc.niushuai.project.devcontrol.R; import cc.niushuai.project.devcontrol.base.enums.YesNoEnum; import cc.niushuai.project.devcontrol.base.util.IdWorker; +import cc.niushuai.project.devcontrol.base.util.UiUtil; import cc.niushuai.project.devcontrol.db.DB; import cc.niushuai.project.devcontrol.db.entity.Device; import cc.niushuai.project.devcontrol.vo.DeviceInfo; @@ -74,12 +78,12 @@ public class DeviceAddPowerSwitchActivity extends BaseActivity { device.setIconId(R.drawable.ic_device_type_switch); device.setDeviceType(DeviceTypeEnum.Power_Switch.getValue()); device.setOnOff(OnOffEnum.OFF.getValue()); - device.setDeviceName(binding.deviceAddName.getText().toString()); - device.setCommandPath(binding.deviceAddParamProgram.getText().toString()); - device.setCommandStatus(binding.deviceAddParamStatus.getText().toString()); - device.setCommandOpen(binding.deviceAddParamOpen.getText().toString()); - device.setCommandClose(binding.deviceAddParamClose.getText().toString()); - device.setRemark(binding.deviceAddParamRemark.getText().toString()); + device.setDeviceName(UiUtil.getTextViewTextById(this, R.id.device_add_name)); + device.setCommandPath(UiUtil.getTextViewTextById(this,R.id.device_add_param_program)); + device.setCommandStatus(UiUtil.getTextViewTextById(this,R.id.device_add_param_status)); + device.setCommandOpen(UiUtil.getTextViewTextById(this,R.id.device_add_param_open)); + device.setCommandClose(UiUtil.getTextViewTextById(this,R.id.device_add_param_close)); + device.setRemark(UiUtil.getTextViewTextById(this,R.id.device_add_param_remark)); device.setCreateTime(DateUtil.now()); device.setOrder(1); device.setIsDeleted(YesNoEnum.NO.getIntegerValue()); @@ -95,4 +99,6 @@ public class DeviceAddPowerSwitchActivity extends BaseActivity { this.finish(); ActivityUtil.startActivity(this, PowerSwitchActivity.class, new String[]{Keys.ID}, new String[]{device.getId() + ""}); } + + } \ No newline at end of file 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 40c0d85..fc3dc05 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 @@ -32,7 +32,8 @@ public class PowerSwitchSetParamActivity extends BaseActivity { protected void init() { device = GlobalVariables.getDeviceInfo(getIntentDeviceId()); - super.setTitle(getString(R.string.power_switch_set_paramSet), null); + this.setTitle(null, getString(R.string.power_switch_set_paramSet), null, R.drawable.ic_confrim_32); + } @Override @@ -40,10 +41,8 @@ public class PowerSwitchSetParamActivity extends BaseActivity { // 隐藏更多按钮 super.activityButtonBackClickListener(this); - super.activityButtonMoreSetClickListener(false, null, null, null); - // 保存监听事件 - binding.powerSwitchSetActivityItemParamSetBtnSave.setOnClickListener(this::btnSaveParamClickListener); + super.activityButtonMoreSetClickListener(this::btnSaveParamClickListener); } private void btnSaveParamClickListener(View view) { diff --git a/app/src/main/res/layout/activity_common_content.xml b/app/src/main/res/layout/activity_common_content.xml new file mode 100644 index 0000000..cdf96dd --- /dev/null +++ b/app/src/main/res/layout/activity_common_content.xml @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_device_add_power_switch.xml b/app/src/main/res/layout/activity_device_add_power_switch.xml index 265a92c..2d8426f 100644 --- a/app/src/main/res/layout/activity_device_add_power_switch.xml +++ b/app/src/main/res/layout/activity_device_add_power_switch.xml @@ -17,211 +17,7 @@ android:layout_height="match_parent" android:layout_below="@id/activity_layout_title"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/app/src/main/res/layout/activity_power_switch_set_param.xml b/app/src/main/res/layout/activity_power_switch_set_param.xml index 934e819..74ffc8e 100644 --- a/app/src/main/res/layout/activity_power_switch_set_param.xml +++ b/app/src/main/res/layout/activity_power_switch_set_param.xml @@ -9,65 +9,13 @@ - + android:layout_height="match_parent" + android:layout_below="@id/activity_layout_title"> - - - - - - - - - - - - -