From cf354a8c02904fc01dd4d57b6f8e353a4db30b0d Mon Sep 17 00:00:00 2001 From: niushuai233 Date: Mon, 17 Oct 2022 18:02:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=BE=E5=A4=87=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devcontrol/ui/device/DeviceOperate.java | 32 +++++++++++++++++++ .../ui/nav/device/NavDeviceFragment.java | 10 ++++-- app/src/main/res/layout/device_item.xml | 7 ++++ app/src/main/res/layout/device_operate.xml | 14 ++++++++ app/src/main/res/values/ids.xml | 3 ++ 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/cc/niushuai/project/devcontrol/ui/device/DeviceOperate.java create mode 100644 app/src/main/res/layout/device_operate.xml diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/ui/device/DeviceOperate.java b/app/src/main/java/cc/niushuai/project/devcontrol/ui/device/DeviceOperate.java new file mode 100644 index 0000000..2f732d2 --- /dev/null +++ b/app/src/main/java/cc/niushuai/project/devcontrol/ui/device/DeviceOperate.java @@ -0,0 +1,32 @@ +package cc.niushuai.project.devcontrol.ui.device; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.fragment.app.Fragment; + +import cc.niushuai.project.devcontrol.databinding.DeviceOperateBinding; +/** + * 设备操作页面 + * + * @author niushuai + * @date: 2022/10/17 17:41 + * @return: {@link } + */ +public class DeviceOperate extends Fragment { + + private DeviceOperateBinding thisBinding; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + thisBinding = DeviceOperateBinding.inflate(inflater, container, false); + + CharSequence text = thisBinding.deviceOperateFullInfo.getText(); + System.out.println(text); + + return thisBinding.getRoot(); + } + +} diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/ui/nav/device/NavDeviceFragment.java b/app/src/main/java/cc/niushuai/project/devcontrol/ui/nav/device/NavDeviceFragment.java index 95d7c7b..ee96c17 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/ui/nav/device/NavDeviceFragment.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/ui/nav/device/NavDeviceFragment.java @@ -1,5 +1,6 @@ package cc.niushuai.project.devcontrol.ui.nav.device; +import android.content.Intent; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; @@ -23,6 +24,7 @@ import cc.niushuai.project.devcontrol.R; import cc.niushuai.project.devcontrol.base.entity.device.DeviceInfo; import cc.niushuai.project.devcontrol.databinding.DeviceItemBinding; import cc.niushuai.project.devcontrol.databinding.MainNavFragmentDeviceBinding; +import cc.niushuai.project.devcontrol.ui.device.DeviceOperate; import cn.hutool.core.util.RandomUtil; /** @@ -64,12 +66,14 @@ public class NavDeviceFragment extends Fragment { deviceGv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { - View text = view.findViewById(R.id.device_item_cardView_text); + View text = view.findViewById(R.id.device_item_cardView_id); String x = ";"; if (text != null) { x = ((TextView) text).getText().toString(); } Toast.makeText(getContext(), "Item Clicked" + x, Toast.LENGTH_SHORT).show(); + + startActivity(new Intent(getActivity(), DeviceOperate.class)); } }); @@ -77,7 +81,8 @@ public class NavDeviceFragment extends Fragment { // new String[]{"device_item_cardView_text"}, new int[]{R.id.device_item_cardView_text}); SimpleAdapter gvAdapter = new SimpleAdapter(getContext(), loadDeviceInfo(), R.layout.device_item, - new String[]{"device_item_cardView_image", "device_item_cardView_text"}, new int[]{R.id.device_item_cardView_image, R.id.device_item_cardView_text}); + new String[]{"device_item_cardView_id", "device_item_cardView_image", "device_item_cardView_text"}, + new int[]{R.id.device_item_cardView_id, R.id.device_item_cardView_image, R.id.device_item_cardView_text}); deviceGv.setAdapter(gvAdapter); } @@ -100,6 +105,7 @@ public class NavDeviceFragment extends Fragment { HashMap m1 = new HashMap<>(); // 设置当前设备的图标和名称 + m1.put("device_item_cardView_id", deviceInfo.getId()); m1.put("device_item_cardView_image", deviceInfo.getIconId()); m1.put("device_item_cardView_text", deviceInfo.getName()); diff --git a/app/src/main/res/layout/device_item.xml b/app/src/main/res/layout/device_item.xml index 770285c..114dec2 100644 --- a/app/src/main/res/layout/device_item.xml +++ b/app/src/main/res/layout/device_item.xml @@ -25,6 +25,13 @@ android:layout_height="wrap_content" android:layout_marginLeft="10dp"> + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/ids.xml b/app/src/main/res/values/ids.xml index ec06172..d70b4bc 100644 --- a/app/src/main/res/values/ids.xml +++ b/app/src/main/res/values/ids.xml @@ -11,8 +11,11 @@ + + + \ No newline at end of file