feat: 提交内容

This commit is contained in:
niushuai233 2022-10-24 18:02:14 +08:00
parent 05a79e5094
commit f904d4aa60
8 changed files with 235 additions and 273 deletions

View File

@ -1,8 +1,10 @@
package cc.niushuai.project.devcontrol.base.util; package cc.niushuai.project.devcontrol.base.util;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.util.TypedValue; import android.util.TypedValue;
import android.widget.TextView;
public class UiUtil { public class UiUtil {
@ -11,4 +13,8 @@ public class UiUtil {
return (int) TypedValue.applyDimension( return (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, dipValue, r.getDisplayMetrics()); TypedValue.COMPLEX_UNIT_DIP, dipValue, r.getDisplayMetrics());
} }
public static String getTextViewTextById(Activity activity, int id) {
return ((TextView) activity.findViewById(id)).getText().toString();
}
} }

View File

@ -3,10 +3,14 @@ package cc.niushuai.project.devcontrol.ui.deviceadd;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import cc.niushuai.project.devcontrol.R; import cc.niushuai.project.devcontrol.R;
import cc.niushuai.project.devcontrol.base.enums.YesNoEnum; import cc.niushuai.project.devcontrol.base.enums.YesNoEnum;
import cc.niushuai.project.devcontrol.base.util.IdWorker; 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.DB;
import cc.niushuai.project.devcontrol.db.entity.Device; import cc.niushuai.project.devcontrol.db.entity.Device;
import cc.niushuai.project.devcontrol.vo.DeviceInfo; 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.setIconId(R.drawable.ic_device_type_switch);
device.setDeviceType(DeviceTypeEnum.Power_Switch.getValue()); device.setDeviceType(DeviceTypeEnum.Power_Switch.getValue());
device.setOnOff(OnOffEnum.OFF.getValue()); device.setOnOff(OnOffEnum.OFF.getValue());
device.setDeviceName(binding.deviceAddName.getText().toString()); device.setDeviceName(UiUtil.getTextViewTextById(this, R.id.device_add_name));
device.setCommandPath(binding.deviceAddParamProgram.getText().toString()); device.setCommandPath(UiUtil.getTextViewTextById(this,R.id.device_add_param_program));
device.setCommandStatus(binding.deviceAddParamStatus.getText().toString()); device.setCommandStatus(UiUtil.getTextViewTextById(this,R.id.device_add_param_status));
device.setCommandOpen(binding.deviceAddParamOpen.getText().toString()); device.setCommandOpen(UiUtil.getTextViewTextById(this,R.id.device_add_param_open));
device.setCommandClose(binding.deviceAddParamClose.getText().toString()); device.setCommandClose(UiUtil.getTextViewTextById(this,R.id.device_add_param_close));
device.setRemark(binding.deviceAddParamRemark.getText().toString()); device.setRemark(UiUtil.getTextViewTextById(this,R.id.device_add_param_remark));
device.setCreateTime(DateUtil.now()); device.setCreateTime(DateUtil.now());
device.setOrder(1); device.setOrder(1);
device.setIsDeleted(YesNoEnum.NO.getIntegerValue()); device.setIsDeleted(YesNoEnum.NO.getIntegerValue());
@ -95,4 +99,6 @@ public class DeviceAddPowerSwitchActivity extends BaseActivity {
this.finish(); this.finish();
ActivityUtil.startActivity(this, PowerSwitchActivity.class, new String[]{Keys.ID}, new String[]{device.getId() + ""}); ActivityUtil.startActivity(this, PowerSwitchActivity.class, new String[]{Keys.ID}, new String[]{device.getId() + ""});
} }
} }

View File

@ -32,7 +32,8 @@ public class PowerSwitchSetParamActivity extends BaseActivity {
protected void init() { protected void init() {
device = GlobalVariables.getDeviceInfo(getIntentDeviceId()); 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 @Override
@ -40,10 +41,8 @@ public class PowerSwitchSetParamActivity extends BaseActivity {
// 隐藏更多按钮 // 隐藏更多按钮
super.activityButtonBackClickListener(this); super.activityButtonBackClickListener(this);
super.activityButtonMoreSetClickListener(false, null, null, null);
// 保存监听事件 // 保存监听事件
binding.powerSwitchSetActivityItemParamSetBtnSave.setOnClickListener(this::btnSaveParamClickListener); super.activityButtonMoreSetClickListener(this::btnSaveParamClickListener);
} }
private void btnSaveParamClickListener(View view) { private void btnSaveParamClickListener(View view) {

View File

@ -0,0 +1,207 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!--设备名称-->
<LinearLayout
android:id="@id/device_add_ll_name"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/device_add_name"
android:textSize="16sp" />
<EditText
android:id="@id/device_add_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:inputType="text" />
</LinearLayout>
<!--选择icon-->
<LinearLayout
android:id="@id/device_add_ll_select_icon"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/device_add_ll_name"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/device_add_select_icon"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="8" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@id/device_add_select_icon"
app:srcCompat="@drawable/ic_next_16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<!--关联程序-->
<LinearLayout
android:id="@id/device_add_ll_program"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/device_add_ll_select_icon"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/device_add_param_program"
android:textSize="16sp" />
<EditText
android:id="@id/device_add_param_program"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:inputType="text" />
</LinearLayout>
<!--状态指令-->
<LinearLayout
android:id="@id/device_add_ll_status"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/device_add_ll_program"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/device_add_param_status"
android:textSize="16sp" />
<EditText
android:id="@id/device_add_param_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:inputType="text" />
</LinearLayout>
<!--开启指令-->
<LinearLayout
android:id="@id/device_add_ll_open"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/device_add_ll_status"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/device_add_param_open"
android:textSize="16sp" />
<EditText
android:id="@id/device_add_param_open"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:inputType="text" />
</LinearLayout>
<!--关闭指令-->
<LinearLayout
android:id="@id/device_add_ll_close"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/device_add_ll_open"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/device_add_param_close"
android:textSize="16sp" />
<EditText
android:id="@id/device_add_param_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:inputType="text" />
</LinearLayout>
<!--备注信息-->
<LinearLayout
android:id="@id/device_add_ll_remark"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/device_add_ll_close"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/device_add_param_remark"
android:textSize="16sp" />
<EditText
android:id="@id/device_add_param_remark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:inputType="text" />
</LinearLayout>
</RelativeLayout>

View File

@ -17,211 +17,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_below="@id/activity_layout_title"> android:layout_below="@id/activity_layout_title">
<RelativeLayout <include layout="@layout/activity_common_content"/>
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--设备名称-->
<LinearLayout
android:id="@id/device_add_ll_name"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/power_switch_name"
android:textSize="16sp" />
<EditText
android:id="@id/device_add_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:inputType="text" />
</LinearLayout>
<!--选择icon-->
<LinearLayout
android:id="@id/device_add_ll_select_icon"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:layout_below="@id/device_add_ll_name"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/device_add_select_icon"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="8" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@id/device_add_select_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@drawable/ic_next_16" />
</LinearLayout>
<!--关联程序-->
<LinearLayout
android:id="@id/device_add_ll_program"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/device_add_ll_select_icon"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/device_add_param_program"
android:textSize="16sp" />
<EditText
android:id="@id/device_add_param_program"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:inputType="text" />
</LinearLayout>
<!--状态指令-->
<LinearLayout
android:id="@id/device_add_ll_status"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/device_add_ll_program"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/device_add_param_status"
android:textSize="16sp" />
<EditText
android:id="@id/device_add_param_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:inputType="text" />
</LinearLayout>
<!--开启指令-->
<LinearLayout
android:id="@id/device_add_ll_open"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/device_add_ll_status"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/device_add_param_open"
android:textSize="16sp" />
<EditText
android:id="@id/device_add_param_open"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:inputType="text" />
</LinearLayout>
<!--关闭指令-->
<LinearLayout
android:id="@id/device_add_ll_close"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/device_add_ll_open"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/device_add_param_close"
android:textSize="16sp" />
<EditText
android:id="@id/device_add_param_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:inputType="text" />
</LinearLayout>
<!--备注信息-->
<LinearLayout
android:id="@id/device_add_ll_remark"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/device_add_ll_close"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/device_add_param_remark"
android:textSize="16sp" />
<EditText
android:id="@id/device_add_param_remark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:inputType="text" />
</LinearLayout>
</RelativeLayout>
</ScrollView> </ScrollView>
</RelativeLayout> </RelativeLayout>

View File

@ -9,65 +9,13 @@
<include layout="@layout/activity_common_title" /> <include layout="@layout/activity_common_title" />
<LinearLayout <ScrollView
android:id="@+id/power_switch_set_activity_item_paramSet_linear1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="50dp" android:layout_height="match_parent"
android:layout_below="@id/activity_layout_title" android:layout_below="@id/activity_layout_title">
android:layout_margin="10dp">
<TextView <include layout="@layout/activity_common_content"/>
android:id="@id/power_switch_set_activity_item_paramSet_open_tv" </ScrollView>
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/power_switch_set_paramSet_open"
android:textSize="16dp" />
<EditText
android:id="@id/power_switch_set_activity_item_paramSet_open_ev"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="9" />
</LinearLayout>
<LinearLayout
android:id="@+id/power_switch_set_activity_item_paramSet_linear2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@id/power_switch_set_activity_item_paramSet_linear1"
android:layout_margin="10dp">
<TextView
android:id="@id/power_switch_set_activity_item_paramSet_close_tv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/power_switch_set_paramSet_close"
android:textSize="16dp" />
<EditText
android:id="@id/power_switch_set_activity_item_paramSet_close_ev"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="9" />
</LinearLayout>
<Button
android:id="@id/power_switch_set_activity_item_paramSet_btn_save"
style="?android:borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/power_switch_set_activity_item_paramSet_linear2"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:layout_marginRight="30dp"
android:background="@drawable/shape_round"
android:text="@string/save"
android:textColor="@color/white"
android:textSize="16dp" />
</RelativeLayout> </RelativeLayout>

View File

@ -62,7 +62,6 @@
<item name="power_switch_set_activity_item_paramSet_open_ev" type="id"/> <item name="power_switch_set_activity_item_paramSet_open_ev" type="id"/>
<item name="power_switch_set_activity_item_paramSet_close_tv" type="id"/> <item name="power_switch_set_activity_item_paramSet_close_tv" type="id"/>
<item name="power_switch_set_activity_item_paramSet_close_ev" type="id"/> <item name="power_switch_set_activity_item_paramSet_close_ev" type="id"/>
<item name="power_switch_set_activity_item_paramSet_btn_save" type="id"/>
<!--日志查看--> <!--日志查看-->
<item name="power_switch_set_activity_item_logView_outside" type="id"/> <item name="power_switch_set_activity_item_logView_outside" type="id"/>

View File

@ -2,6 +2,7 @@
<resources> <resources>
<!--common--> <!--common-->
<string name="device_add_name">设备名称</string>
<string name="device_add_select_icon">选择图标</string> <string name="device_add_select_icon">选择图标</string>
<string name="device_add_param_status">状态指令</string> <string name="device_add_param_status">状态指令</string>
<string name="device_add_param_open">开启指令</string> <string name="device_add_param_open">开启指令</string>