From fd1fb76537f1ada8ddbe9e3f6b65cc06b147239d Mon Sep 17 00:00:00 2001 From: niushuai233 Date: Wed, 19 Oct 2022 15:50:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B7=B3=E8=BD=AC=E5=88=B0=E5=BC=80?= =?UTF-8?q?=E5=85=B3=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 15 ++++++++-- .../devcontrol/base/util/ActivityUtil.java | 29 +++++++++++++++++++ .../ui/powerswitch/PowerSwitchActivity.java | 12 ++++---- .../powerswitch/PowerSwitchSetActivity.java | 17 +++++++++++ .../ui/powerswitch/PowerSwitchViewModel.java | 22 -------------- ...activity.xml => activity_power_switch.xml} | 0 .../res/layout/activity_power_switch_set.xml | 18 ++++++++++++ 7 files changed, 82 insertions(+), 31 deletions(-) create mode 100644 app/src/main/java/cc/niushuai/project/devcontrol/base/util/ActivityUtil.java create mode 100644 app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetActivity.java delete mode 100644 app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchViewModel.java rename app/src/main/res/layout/{device_power_switch_activity.xml => activity_power_switch.xml} (100%) create mode 100644 app/src/main/res/layout/activity_power_switch_set.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3921051..7c42d08 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,6 +9,8 @@ android:roundIcon="@mipmap/app_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.DevControl"> + + @@ -19,12 +21,21 @@ + + android:exported="false"> + + + - + + + + diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/base/util/ActivityUtil.java b/app/src/main/java/cc/niushuai/project/devcontrol/base/util/ActivityUtil.java new file mode 100644 index 0000000..ff3ee7d --- /dev/null +++ b/app/src/main/java/cc/niushuai/project/devcontrol/base/util/ActivityUtil.java @@ -0,0 +1,29 @@ +package cc.niushuai.project.devcontrol.base.util; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; + +import java.util.HashMap; +import java.util.Map; + +import cc.niushuai.project.devcontrol.base.ui.BaseActivity; + +public class ActivityUtil { + + public static void startActivity(Activity sourceActivity, Class targetActivity) { + + startActivity(sourceActivity, targetActivity, null); + } + + public static void startActivity(Activity sourceActivity, Class targetActivity, + Map withData) { + Intent intent = new Intent(sourceActivity, targetActivity); + if (null != withData) { + for (String key : withData.keySet()) { + intent.putExtra(key, withData.get(key)); + } + } + sourceActivity.startActivity(intent); + } +} 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 fda78ee..fea4f21 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 @@ -11,13 +11,14 @@ import cc.niushuai.project.devcontrol.R; import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo; import cc.niushuai.project.devcontrol.base.enums.OnOffEnum; import cc.niushuai.project.devcontrol.base.ui.BaseActivity; +import cc.niushuai.project.devcontrol.base.util.ActivityUtil; import cc.niushuai.project.devcontrol.base.util.GlobalVariables; import cc.niushuai.project.devcontrol.base.util.Keys; -import cc.niushuai.project.devcontrol.databinding.DevicePowerSwitchActivityBinding; +import cc.niushuai.project.devcontrol.databinding.ActivityPowerSwitchBinding; public class PowerSwitchActivity extends BaseActivity { - private DevicePowerSwitchActivityBinding binding; + private ActivityPowerSwitchBinding binding; private DeviceInfo device; @Override @@ -26,7 +27,7 @@ public class PowerSwitchActivity extends BaseActivity { // 隐藏自带的标题栏 getSupportActionBar().hide(); - binding = DevicePowerSwitchActivityBinding.inflate(getLayoutInflater()); + binding = ActivityPowerSwitchBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); // 初始化页面数据 @@ -85,11 +86,8 @@ public class PowerSwitchActivity extends BaseActivity { * @author niushuai * @date: 2022/10/19 14:47 */ - private void buttonMoreSetClickListener(View view) { - - - + ActivityUtil.startActivity(this, PowerSwitchSetActivity.class); } /** diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetActivity.java b/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetActivity.java new file mode 100644 index 0000000..40f7ba2 --- /dev/null +++ b/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetActivity.java @@ -0,0 +1,17 @@ +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.ui.BaseActivity; + +public class PowerSwitchSetActivity extends BaseActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_power_switch_set); + } +} \ No newline at end of file diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchViewModel.java b/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchViewModel.java deleted file mode 100644 index 7818c7e..0000000 --- a/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchViewModel.java +++ /dev/null @@ -1,22 +0,0 @@ -package cc.niushuai.project.devcontrol.ui.powerswitch; - -import androidx.lifecycle.MutableLiveData; -import androidx.lifecycle.ViewModel; - -import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo; - -public class PowerSwitchViewModel extends ViewModel { - - private MutableLiveData deviceInfo; - - public PowerSwitchViewModel() { - } - - public MutableLiveData getDeviceInfo() { - return deviceInfo; - } - - public void setDeviceInfo(MutableLiveData deviceInfo) { - this.deviceInfo = deviceInfo; - } -} diff --git a/app/src/main/res/layout/device_power_switch_activity.xml b/app/src/main/res/layout/activity_power_switch.xml similarity index 100% rename from app/src/main/res/layout/device_power_switch_activity.xml rename to app/src/main/res/layout/activity_power_switch.xml diff --git a/app/src/main/res/layout/activity_power_switch_set.xml b/app/src/main/res/layout/activity_power_switch_set.xml new file mode 100644 index 0000000..a70323d --- /dev/null +++ b/app/src/main/res/layout/activity_power_switch_set.xml @@ -0,0 +1,18 @@ + + + + + + + + \ No newline at end of file