From ba82a08a6e30d7c0ccffffc9d12caf584bd638f5 Mon Sep 17 00:00:00 2001 From: niushuai233 Date: Fri, 21 Oct 2022 09:38:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B7=B3=E8=BD=AC=E5=88=B0=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E8=AE=BE=E5=A4=87=E6=B7=BB=E5=8A=A0=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeviceAddPowerSwitchActivity.java | 11 +++++++++-- .../nav/device/DeviceAddDialogFragment.java | 19 +++++++++++-------- .../ui/powerswitch/PowerSwitchActivity.java | 6 +++++- .../powerswitch/PowerSwitchSetActivity.java | 6 ++++++ .../PowerSwitchSetParamActivity.java | 6 ++++++ 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/ui/deviceadd/DeviceAddPowerSwitchActivity.java b/app/src/main/java/cc/niushuai/project/devcontrol/ui/deviceadd/DeviceAddPowerSwitchActivity.java index 8569066..7c7db48 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/ui/deviceadd/DeviceAddPowerSwitchActivity.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/ui/deviceadd/DeviceAddPowerSwitchActivity.java @@ -3,15 +3,22 @@ package cc.niushuai.project.devcontrol.ui.deviceadd; import android.os.Bundle; -import cc.niushuai.project.devcontrol.R; import cc.niushuai.project.devcontrol.base.ui.BaseActivity; +import cc.niushuai.project.devcontrol.databinding.ActivityDeviceAddPowerSwitchBinding; public class DeviceAddPowerSwitchActivity extends BaseActivity { + private ActivityDeviceAddPowerSwitchBinding binding; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_device_add_power_switch); + + binding = ActivityDeviceAddPowerSwitchBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + + this.init(); + this.addListener(); } @Override diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/ui/nav/device/DeviceAddDialogFragment.java b/app/src/main/java/cc/niushuai/project/devcontrol/ui/nav/device/DeviceAddDialogFragment.java index ec42a34..c30db28 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/ui/nav/device/DeviceAddDialogFragment.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/ui/nav/device/DeviceAddDialogFragment.java @@ -1,6 +1,5 @@ package cc.niushuai.project.devcontrol.ui.nav.device; -import android.app.Dialog; import android.content.DialogInterface; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; @@ -12,15 +11,9 @@ import android.widget.AdapterView; import android.widget.GridView; import android.widget.SimpleAdapter; import android.widget.TextView; -import android.widget.Toast; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; -import org.w3c.dom.Text; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -92,9 +85,13 @@ public class DeviceAddDialogFragment extends DialogFragment { * @date: 2022/10/20 16:59 */ private void deviceTypeListItemClickListener(AdapterView parent, View view, int position, long id) { - TextView keyView = view.findViewById(R.id.device_type_list_key); + // 跳转到相应的activity + TextView keyView = view.findViewById(R.id.device_type_list_key); ActivityUtil.startActivity(getActivity(), DeviceTypeEnum.matchByValue(keyView.getText().toString()).getDeviceAddActivity()); + + // 关闭弹出框 + this.dismiss(); } /** @@ -120,4 +117,10 @@ public class DeviceAddDialogFragment extends DialogFragment { return gvData; } + + @Override + public void onDismiss(DialogInterface dialog) { + super.onDismiss(dialog); + binding = null; + } } 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 46d67bc..1d858f4 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 @@ -95,5 +95,9 @@ public class PowerSwitchActivity extends BaseActivity { ((AppCompatImageView) findViewById(R.id.power_switch_activity_content_icon)).setImageResource(iconImageId); } - + @Override + protected void onDestroy() { + super.onDestroy(); + binding = null; + } } 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 index d6b4b87..a5091f3 100644 --- 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 @@ -59,4 +59,10 @@ public class PowerSwitchSetActivity extends BaseActivity { private void outsideLogViewClickListener(View view) { Toast.makeText(this, "日志暂未实现哦", Toast.LENGTH_SHORT).show(); } + + @Override + protected void onDestroy() { + super.onDestroy(); + binding = null; + } } \ No newline at end of file diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetParamActivity.java b/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetParamActivity.java index 69b0da6..9346857 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetParamActivity.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/ui/powerswitch/PowerSwitchSetParamActivity.java @@ -49,4 +49,10 @@ public class PowerSwitchSetParamActivity extends BaseActivity { Toast.makeText(this, "已保存", Toast.LENGTH_SHORT).show(); } + + @Override + protected void onDestroy() { + super.onDestroy(); + binding = null; + } }