| | |
| | | package com.example.agvcontroller; |
| | | |
| | | import static androidx.core.content.ContextCompat.startActivity; |
| | | |
| | | import android.content.Intent; |
| | | import android.graphics.Color; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | |
| | | |
| | | public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.ViewHolder> { |
| | | |
| | | private List<Item> itemList; |
| | | private List<AGVCar> itemList; |
| | | |
| | | public ItemAdapter(List<Item> itemList) { |
| | | public ItemAdapter(List<AGVCar> itemList) { |
| | | this.itemList = itemList; |
| | | } |
| | | |
| | |
| | | // 默认显示页面 |
| | | //return 1; |
| | | } else { |
| | | Item item = itemList.get(position); |
| | | AGVCar item = itemList.get(position); |
| | | int status = item.getStatus(); |
| | | switch (status) { |
| | | case 0: |
| | | holder.itemView.setBackgroundColor(Color.GRAY); |
| | | holder.itemView.setBackgroundColor(Color.parseColor("#D3D3D3")); |
| | | break; |
| | | default: |
| | | holder.itemView.setBackgroundColor(Color.GREEN); |
| | | holder.itemView.setBackgroundColor(Color.parseColor("#90EE90")); |
| | | break; |
| | | } |
| | | holder.agvNo.setText("AGV_NO: " + item.getAgvNo()); |
| | |
| | | } |
| | | } |
| | | |
| | | public void addItem (Item item) { |
| | | public void addItem (AGVCar item) { |
| | | itemList.add(item); |
| | | notifyItemInserted(itemList.size() - 1); |
| | | } |