I have a little bit of a confusion when it comes to what is considered the better implementation.
One the one hand,
LinkedHashMap
provides the following benefits:
- Prevents duplicate items (I need to be able to prevent a scanned Bluetooth device to not repeatedly enter the list.)
- Provides easy access to items for updating values.
And the following pitfalls:
- Not supported naturally by the
BaseAdapter
class? I cannot seem to retrieve elements usinggetItem
for a customListView
Adapter
.
However with an ArrayList
- I can easily access items via their indices.
- Can easily replace items for updating values.
Works easily with custom
BaseAdapter
class. But...I receive duplicated items.
- I cannot easily compare or check with the
ArrayList.contains
method unless I implement some customcomparators
of theArrayList
's objects' parameters.
Is there an easier way to achieve the following:
- Scan via BLE, construct a custom object from the scan results. (already complete).
- Stick that custom object in an array list if it isn't already in it.
- If it is already in the array list, replace the previous object with the new one?