mirror of
https://github.com/niushuai233/DevControl.git
synced 2024-10-27 22:43:20 +08:00
feat: 跳转到开关设置页面
This commit is contained in:
parent
61e6a875ed
commit
fd1fb76537
@ -9,6 +9,8 @@
|
|||||||
android:roundIcon="@mipmap/app_launcher_round"
|
android:roundIcon="@mipmap/app_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.DevControl">
|
android:theme="@style/Theme.DevControl">
|
||||||
|
|
||||||
|
<!--主页面-->
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
@ -19,12 +21,21 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<!--开关操作-->
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.powerswitch.PowerSwitchActivity"
|
android:name=".ui.powerswitch.PowerSwitchActivity"
|
||||||
android:exported="true">
|
android:exported="false">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
<!--开关设置-->
|
||||||
|
<activity
|
||||||
|
android:name=".ui.powerswitch.PowerSwitchSetActivity"
|
||||||
|
android:exported="false">
|
||||||
|
<intent-filter>
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
@ -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<? extends BaseActivity> targetActivity) {
|
||||||
|
|
||||||
|
startActivity(sourceActivity, targetActivity, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startActivity(Activity sourceActivity, Class<? extends BaseActivity> targetActivity,
|
||||||
|
Map<String, String> withData) {
|
||||||
|
Intent intent = new Intent(sourceActivity, targetActivity);
|
||||||
|
if (null != withData) {
|
||||||
|
for (String key : withData.keySet()) {
|
||||||
|
intent.putExtra(key, withData.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sourceActivity.startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
@ -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.entity.device.DeviceInfo;
|
||||||
import cc.niushuai.project.devcontrol.base.enums.OnOffEnum;
|
import cc.niushuai.project.devcontrol.base.enums.OnOffEnum;
|
||||||
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
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.GlobalVariables;
|
||||||
import cc.niushuai.project.devcontrol.base.util.Keys;
|
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 {
|
public class PowerSwitchActivity extends BaseActivity {
|
||||||
|
|
||||||
private DevicePowerSwitchActivityBinding binding;
|
private ActivityPowerSwitchBinding binding;
|
||||||
private DeviceInfo device;
|
private DeviceInfo device;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -26,7 +27,7 @@ public class PowerSwitchActivity extends BaseActivity {
|
|||||||
// 隐藏自带的标题栏
|
// 隐藏自带的标题栏
|
||||||
getSupportActionBar().hide();
|
getSupportActionBar().hide();
|
||||||
|
|
||||||
binding = DevicePowerSwitchActivityBinding.inflate(getLayoutInflater());
|
binding = ActivityPowerSwitchBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
// 初始化页面数据
|
// 初始化页面数据
|
||||||
@ -85,11 +86,8 @@ public class PowerSwitchActivity extends BaseActivity {
|
|||||||
* @author niushuai
|
* @author niushuai
|
||||||
* @date: 2022/10/19 14:47
|
* @date: 2022/10/19 14:47
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void buttonMoreSetClickListener(View view) {
|
private void buttonMoreSetClickListener(View view) {
|
||||||
|
ActivityUtil.startActivity(this, PowerSwitchSetActivity.class);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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> deviceInfo;
|
|
||||||
|
|
||||||
public PowerSwitchViewModel() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public MutableLiveData<DeviceInfo> getDeviceInfo() {
|
|
||||||
return deviceInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDeviceInfo(MutableLiveData<DeviceInfo> deviceInfo) {
|
|
||||||
this.deviceInfo = deviceInfo;
|
|
||||||
}
|
|
||||||
}
|
|
18
app/src/main/res/layout/activity_power_switch_set.xml
Normal file
18
app/src/main/res/layout/activity_power_switch_set.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.powerswitch.PowerSwitchSetActivity">
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
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>
|
Loading…
x
Reference in New Issue
Block a user