feat: 跳转到对应的设备添加页面

This commit is contained in:
niushuai233 2022-10-21 09:38:16 +08:00
parent 7e5035fb6b
commit ba82a08a6e
5 changed files with 37 additions and 11 deletions

View File

@ -3,15 +3,22 @@ package cc.niushuai.project.devcontrol.ui.deviceadd;
import android.os.Bundle; import android.os.Bundle;
import cc.niushuai.project.devcontrol.R;
import cc.niushuai.project.devcontrol.base.ui.BaseActivity; import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
import cc.niushuai.project.devcontrol.databinding.ActivityDeviceAddPowerSwitchBinding;
public class DeviceAddPowerSwitchActivity extends BaseActivity { public class DeviceAddPowerSwitchActivity extends BaseActivity {
private ActivityDeviceAddPowerSwitchBinding binding;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_device_add_power_switch);
binding = ActivityDeviceAddPowerSwitchBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
this.init();
this.addListener();
} }
@Override @Override

View File

@ -1,6 +1,5 @@
package cc.niushuai.project.devcontrol.ui.nav.device; package cc.niushuai.project.devcontrol.ui.nav.device;
import android.app.Dialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
@ -12,15 +11,9 @@ import android.widget.AdapterView;
import android.widget.GridView; import android.widget.GridView;
import android.widget.SimpleAdapter; import android.widget.SimpleAdapter;
import android.widget.TextView; 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 androidx.fragment.app.DialogFragment;
import org.w3c.dom.Text;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -92,9 +85,13 @@ public class DeviceAddDialogFragment extends DialogFragment {
* @date: 2022/10/20 16:59 * @date: 2022/10/20 16:59
*/ */
private void deviceTypeListItemClickListener(AdapterView<?> parent, View view, int position, long id) { 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()); ActivityUtil.startActivity(getActivity(), DeviceTypeEnum.matchByValue(keyView.getText().toString()).getDeviceAddActivity());
// 关闭弹出框
this.dismiss();
} }
/** /**
@ -120,4 +117,10 @@ public class DeviceAddDialogFragment extends DialogFragment {
return gvData; return gvData;
} }
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
binding = null;
}
} }

View File

@ -95,5 +95,9 @@ public class PowerSwitchActivity extends BaseActivity {
((AppCompatImageView) findViewById(R.id.power_switch_activity_content_icon)).setImageResource(iconImageId); ((AppCompatImageView) findViewById(R.id.power_switch_activity_content_icon)).setImageResource(iconImageId);
} }
@Override
protected void onDestroy() {
super.onDestroy();
binding = null;
}
} }

View File

@ -59,4 +59,10 @@ public class PowerSwitchSetActivity extends BaseActivity {
private void outsideLogViewClickListener(View view) { private void outsideLogViewClickListener(View view) {
Toast.makeText(this, "日志暂未实现哦", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "日志暂未实现哦", Toast.LENGTH_SHORT).show();
} }
@Override
protected void onDestroy() {
super.onDestroy();
binding = null;
}
} }

View File

@ -49,4 +49,10 @@ public class PowerSwitchSetParamActivity extends BaseActivity {
Toast.makeText(this, "已保存", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "已保存", Toast.LENGTH_SHORT).show();
} }
@Override
protected void onDestroy() {
super.onDestroy();
binding = null;
}
} }