| | |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | |
| | | private List<Item> items; |
| | | private ItemAdapter adapter; |
| | | SocketManager socketManager; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.activity_start); |
| | | |
| | | |
| | | recyclerView = findViewById(R.id.recyclerView); |
| | | recyclerView.setLayoutManager(new LinearLayoutManager(this)); |
| | |
| | | public void onItemClick(View view, int position) { |
| | | Context context = view.getContext(); |
| | | Intent intent = new Intent(context,MainActivity.class); |
| | | intent.putExtra("ip", items.get(position).getIp()); |
| | | intent.putExtra("agvNo", items.get(position).getAgvNo()); |
| | | String ip = items.get(position).getIp(); |
| | | String clientId = items.get(position).getClientId(); |
| | | String agvNo = items.get(position).getAgvNo(); |
| | | |
| | | |
| | | intent.putExtra("ip", ip); |
| | | intent.putExtra("agvNo", agvNo); |
| | | intent.putExtra("clientId", clientId); |
| | | startActivityForResult(intent,1); |
| | | } |
| | | }); |
| | |
| | | Log.i("EventBus", "Received device connected: " + deviceAddress); |
| | | |
| | | |
| | | if (items.size() > 0) { |
| | | if (!items.isEmpty()) { |
| | | int sameIp = 0; |
| | | for (Item item : items) { |
| | | if (item.getIp().equals(deviceAddress.getIp())) { |
| | | item.setAgvNo(deviceAddress.getAgvNo()); |
| | | item.setPort(deviceAddress.getPort()); |
| | | item.setClientId(deviceAddress.getClientId()); |
| | | item.setStatus(deviceAddress.getStatus()); |
| | | adapter.notifyItemChanged(items.indexOf(item)); |
| | | MainActivity.upClient(deviceAddress.getClientId()); |
| | | sameIp++; |
| | | } |
| | | Log.i("Item",item.getIp()); |
| | | Log.i("Item",item.getClientId()); |
| | | } |
| | | if (sameIp == 0) { |
| | | items.add(new Item(deviceAddress.getText(),deviceAddress.getIp(),deviceAddress.getAgvNo())); |
| | | items.add(new Item(deviceAddress.getClientId() |
| | | ,deviceAddress.getIp() |
| | | ,deviceAddress.getPort() |
| | | ,deviceAddress.getAgvNo() |
| | | ,deviceAddress.getStatus())); |
| | | } |
| | | } else { |
| | | items.add(new Item(deviceAddress.getText(),deviceAddress.getIp(),deviceAddress.getAgvNo())); |
| | | items.add(new Item(deviceAddress.getClientId() |
| | | ,deviceAddress.getIp() |
| | | ,deviceAddress.getPort() |
| | | ,deviceAddress.getAgvNo() |
| | | ,deviceAddress.getStatus())); |
| | | } |
| | | adapter.notifyDataSetChanged(); |
| | | } |