feat: 新增开关设备设置页面

This commit is contained in:
niushuai233 2022-10-19 17:00:33 +08:00
parent fd1fb76537
commit df2449c811
5 changed files with 50 additions and 15 deletions

View File

@ -2,11 +2,27 @@ package cc.niushuai.project.devcontrol.base.ui;
import androidx.appcompat.app.AppCompatActivity;
import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo;
import cc.niushuai.project.devcontrol.base.util.Keys;
/**
* Activity基类
*
* @author niushuai
* @date: 2022/10/18 14:24
*/
public class BaseActivity extends AppCompatActivity {
public abstract class BaseActivity extends AppCompatActivity {
protected DeviceInfo device;
protected String getIntentDeviceId() {
return getIntent().getStringExtra(Keys.ID);
}
/**
* 初始化方法
*
* @author niushuai
* @date: 2022/10/19 15:54
*/
public abstract void init();
}

View File

@ -15,7 +15,10 @@ public class GlobalVariables {
public static final Map<String, DeviceInfo> DEVICE_INFO_MAP = new HashMap<>(16);
public static Class<? extends BaseActivity> getDeviceOperateActivity(String deviceId) {
return DEVICE_INFO_MAP.get(deviceId).getDeviceType().getActivity();
return getDeviceInfo(deviceId).getDeviceType().getActivity();
}
public static DeviceInfo getDeviceInfo(String deviceId) {
return DEVICE_INFO_MAP.get(deviceId);
}
}

View File

@ -1,6 +1,7 @@
package cc.niushuai.project.devcontrol.ui.powerswitch;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
@ -19,7 +20,6 @@ import cc.niushuai.project.devcontrol.databinding.ActivityPowerSwitchBinding;
public class PowerSwitchActivity extends BaseActivity {
private ActivityPowerSwitchBinding binding;
private DeviceInfo device;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -42,10 +42,10 @@ public class PowerSwitchActivity extends BaseActivity {
* @author niushuai
* @date: 2022/10/19 11:18
*/
@Override
public void init() {
String deviceId = getIntent().getStringExtra(Keys.ID);
DeviceInfo data = GlobalVariables.DEVICE_INFO_MAP.get(deviceId);
DeviceInfo data = GlobalVariables.getDeviceInfo(getIntentDeviceId());
if (null != data) {
this.device = data;
// 标题名称
@ -87,7 +87,12 @@ public class PowerSwitchActivity extends BaseActivity {
* @date: 2022/10/19 14:47
*/
private void buttonMoreSetClickListener(View view) {
ActivityUtil.startActivity(this, PowerSwitchSetActivity.class);
// ActivityUtil.startActivity(this, PowerSwitchSetActivity.class);
Intent intent = new Intent(this, PowerSwitchSetActivity.class);
startActivity(intent);
}
/**

View File

@ -1,17 +1,32 @@
package cc.niushuai.project.devcontrol.ui.powerswitch;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import cc.niushuai.project.devcontrol.R;
import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo;
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
import cc.niushuai.project.devcontrol.base.util.GlobalVariables;
import cc.niushuai.project.devcontrol.base.util.Keys;
import cc.niushuai.project.devcontrol.databinding.ActivityPowerSwitchBinding;
import cc.niushuai.project.devcontrol.databinding.ActivityPowerSwitchSetBinding;
public class PowerSwitchSetActivity extends BaseActivity {
private ActivityPowerSwitchSetBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_power_switch_set);
getSupportActionBar().hide();
binding = ActivityPowerSwitchSetBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
}
@Override
public void init() {
device = GlobalVariables.getDeviceInfo(getIntentDeviceId());
}
}

View File

@ -6,13 +6,9 @@
android:layout_height="match_parent"
tools:context=".ui.powerswitch.PowerSwitchSetActivity">
<TextView
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/test_hello_blank_textview_3"
/>
</androidx.constraintlayout.widget.ConstraintLayout>