| | |
| | | public void onItemClick(View view, int position) { |
| | | Context context = view.getContext(); |
| | | Intent intent = new Intent(context,MainActivity.class); |
| | | intent.putExtra("message", items.get(position).getIp()); |
| | | intent.putExtra("ip", items.get(position).getIp()); |
| | | intent.putExtra("agvNo", items.get(position).getAgvNo()); |
| | | startActivityForResult(intent,1); |
| | | } |
| | | }); |
| | |
| | | @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(); |
| | | } |