feat: 更名

This commit is contained in:
niushuai233 2022-10-19 15:21:22 +08:00
parent dd1d7c0b0a
commit ee1d6d5bb8
6 changed files with 50 additions and 18 deletions

View File

@ -20,7 +20,7 @@
</activity>
<activity
android:name=".ui.device.DeviceActivity"
android:name=".ui.powerswitch.PowerSwitchActivity"
android:exported="true">
<intent-filter>

View File

@ -11,7 +11,6 @@ import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
@ -25,7 +24,7 @@ import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo;
import cc.niushuai.project.devcontrol.base.util.Keys;
import cc.niushuai.project.devcontrol.databinding.DeviceItemBinding;
import cc.niushuai.project.devcontrol.databinding.MainNavFragmentDeviceBinding;
import cc.niushuai.project.devcontrol.ui.device.DeviceActivity;
import cc.niushuai.project.devcontrol.ui.powerswitch.PowerSwitchActivity;
import cn.hutool.core.util.RandomUtil;
/**
@ -117,7 +116,7 @@ public class NavDeviceFragment extends Fragment {
private void onItemClick(AdapterView<?> parent, View view, int position, long id) {
TextView textId = view.findViewById(R.id.device_item_cardView_id);
Intent intent = new Intent(getActivity(), DeviceActivity.class);
Intent intent = new Intent(getActivity(), PowerSwitchActivity.class);
intent.putExtra(Keys.ID, textId.getText());
startActivity(intent);
}

View File

@ -1,5 +1,6 @@
package cc.niushuai.project.devcontrol.ui.device;
package cc.niushuai.project.devcontrol.ui.powerswitch;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
@ -7,16 +8,16 @@ import android.widget.TextView;
import androidx.appcompat.widget.AppCompatImageView;
import cc.niushuai.project.devcontrol.R;
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
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.GlobalVariables;
import cc.niushuai.project.devcontrol.base.util.Keys;
import cc.niushuai.project.devcontrol.databinding.DeviceActivityBinding;
import cc.niushuai.project.devcontrol.databinding.DevicePowerSwitchActivityBinding;
public class DeviceActivity extends BaseActivity {
public class PowerSwitchActivity extends BaseActivity {
private DeviceActivityBinding binding;
private DevicePowerSwitchActivityBinding binding;
private DeviceInfo device;
@Override
@ -25,7 +26,7 @@ public class DeviceActivity extends BaseActivity {
// 隐藏自带的标题栏
getSupportActionBar().hide();
binding = DeviceActivityBinding.inflate(getLayoutInflater());
binding = DevicePowerSwitchActivityBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
// 初始化页面数据
@ -67,8 +68,40 @@ public class DeviceActivity extends BaseActivity {
* @date: 2022/10/19 11:49
*/
private void addListener() {
// 开关点击事件
binding.deviceActivityContentSwitch.setOnClickListener(this::imageSwitchClickListener);
binding.deviceActivityContentSwitch.setOnClickListener(this::switchClickListener);
// 标题栏 返回
binding.deviceActivityTitleBack.setOnClickListener(this::buttonBackClickListener);
// 标题栏 更多设置
binding.deviceActivityTitleMoreSet.setOnClickListener(this::buttonMoreSetClickListener);
}
/**
* 更多设置 打开fragment
*
* @param view
* @author niushuai
* @date: 2022/10/19 14:47
*/
private void buttonMoreSetClickListener(View view) {
}
/**
* 返回上一页
*
* @param view
* @author niushuai
* @date: 2022/10/19 14:46
*/
private void buttonBackClickListener(View view) {
// AppCompatImageButton buttonBack = (AppCompatImageButton) view;
PowerSwitchActivity.this.finish();
}
/**
@ -78,7 +111,7 @@ public class DeviceActivity extends BaseActivity {
* @author niushuai
* @date: 2022/10/19 11:52
*/
private void switchClickListener(View view) {
private void imageSwitchClickListener(View view) {
AppCompatImageView appCompatImageView = (AppCompatImageView) view;
int switchImageId, iconImageId;

View File

@ -1,15 +1,15 @@
package cc.niushuai.project.devcontrol.ui.device;
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 DeviceViewModel extends ViewModel {
public class PowerSwitchViewModel extends ViewModel {
private MutableLiveData<DeviceInfo> deviceInfo;
public DeviceViewModel() {
public PowerSwitchViewModel() {
}
public MutableLiveData<DeviceInfo> getDeviceInfo() {

View File

@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".ui.device.DeviceActivity">
tools:context=".ui.powerswitch.PowerSwitchActivity">
<RelativeLayout
android:id="@id/device_activity_layout"

View File

@ -15,7 +15,7 @@
<item name="device_item_cardView_image" type="id"/>
<item name="device_item_cardView_text" type="id"/>
<!--设备操作页 start-->
<!--开关操作页 start-->
<item name="device_activity" type="id"/>
<item name="device_activity_layout" type="id"/>
<item name="device_activity_layout_title" type="id"/>
@ -31,7 +31,7 @@
<item name="device_activity_content_icon" type="id"/>
<item name="device_activity_content_switch" type="id"/>
<item name="device_activity_content_text" type="id"/>
<!--设备操作页 end-->
<!--开关操作页 end-->
<!--设备页 end-->
</resources>