Commit 4bf0a6e0 authored by Andreas Schildbach's avatar Andreas Schildbach
Browse files

ScannerListAdapter: Update devices if they advertise again.

parent 2b5e9837
......@@ -42,7 +42,7 @@ class ScannerFragment : Fragment() {
override fun onScanResult(callbackType: Int, result: ScanResult) {
System.out.println("===== onScanResult " + result)
val device = result.device
listAdapter.maybeAdd(
listAdapter.put(
Device(
btMac = device.address,
name = device.name,
......
......@@ -37,10 +37,9 @@ class ScannerListAdapter(val clickListener: (Device) -> Unit) : RecyclerView.Ada
override fun getItemCount(): Int = list.size
fun maybeAdd(device: Device) {
if (!list.contains(device)) {
list.add(device)
notifyDataSetChanged()
}
fun put(device: Device) {
list.remove(device)
list.add(device)
notifyDataSetChanged()
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment