From 00fd3eb5037f07763d4e8d3e5729066d3dc097ea Mon Sep 17 00:00:00 2001
From: whycq <913841844@qq.com>
Date: 星期三, 08 一月 2025 14:47:43 +0800
Subject: [PATCH] #

---
 app/src/main/java/com/example/agvcontroller/StartActivity.java |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/app/src/main/java/com/example/agvcontroller/StartActivity.java b/app/src/main/java/com/example/agvcontroller/StartActivity.java
index adb74d2..e2b4401 100644
--- a/app/src/main/java/com/example/agvcontroller/StartActivity.java
+++ b/app/src/main/java/com/example/agvcontroller/StartActivity.java
@@ -58,11 +58,21 @@
     @Subscribe(threadMode = ThreadMode.MAIN)
     public void onDeviceConnected(Item deviceAddress) {
         Log.i("EventBus", "Received device connected: " + deviceAddress);
-        items.add(new Item("1",deviceAddress.getIp(),"3"));
+
+
         if (items.size() > 0) {
+            int sameIp = 0;
             for (Item item : items) {
+                if (item.getIp().equals(deviceAddress.getIp())) {
+                    sameIp++;
+                }
                 Log.i("Item",item.getIp());
             }
+            if (sameIp == 0) {
+                items.add(new Item(deviceAddress.getText(),deviceAddress.getIp(),deviceAddress.getAgvNo()));
+            }
+        } else {
+            items.add(new Item(deviceAddress.getText(),deviceAddress.getIp(),deviceAddress.getAgvNo()));
         }
         adapter.notifyDataSetChanged();
     }

--
Gitblit v1.9.1