diff options
Diffstat (limited to 'app/src/main/java/com/javispedro/rempe/DeviceListRecyclerViewListAdapter.java')
-rw-r--r-- | app/src/main/java/com/javispedro/rempe/DeviceListRecyclerViewListAdapter.java | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/app/src/main/java/com/javispedro/rempe/DeviceListRecyclerViewListAdapter.java b/app/src/main/java/com/javispedro/rempe/DeviceListRecyclerViewListAdapter.java index 2288f20..102f1ec 100644 --- a/app/src/main/java/com/javispedro/rempe/DeviceListRecyclerViewListAdapter.java +++ b/app/src/main/java/com/javispedro/rempe/DeviceListRecyclerViewListAdapter.java @@ -16,6 +16,24 @@ public class DeviceListRecyclerViewListAdapter extends RecyclerView.Adapter<Devi private List<Device> mList; + public DeviceListRecyclerViewListAdapter() { + setHasStableIds(true); + } + + @Override + public int getItemCount() { + if (mList != null) { + return mList.size(); + } else { + return 0; + } + } + + @Override + public long getItemId(int position) { + return mList.get(position).getDeviceNumber(); + } + @Override @NonNull public DeviceViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { @@ -29,14 +47,7 @@ public class DeviceListRecyclerViewListAdapter extends RecyclerView.Adapter<Devi holder.setDevice(mList.get(position)); } - @Override - public int getItemCount() { - if (mList != null) { - return mList.size(); - } else { - return 0; - } - } + public void setDeviceList(List<Device> list) { mList = list; |