Prefer p2p client list

This commit is contained in:
Mygod
2018-02-10 23:03:45 -08:00
parent 70468bfbd1
commit 7f31b63394

View File

@@ -101,14 +101,13 @@ class RepeaterFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClickL
fun recreate() { fun recreate() {
clients.clear() clients.clear()
val map = HashMap(p2p.associateBy { it.deviceAddress }) val p2p = HashMap(p2p.associateBy { it.deviceAddress })
for (neighbour in neighbours) { for (neighbour in neighbours)
val client = map.remove(neighbour.lladdr) if (neighbour.dev == p2pInterface) {
if (client != null) clients.add(Client(client, neighbour)) val client = p2p.remove(neighbour.lladdr)
else if (tetheredInterfaces.contains(neighbour.dev) || neighbour.dev == p2pInterface) if (client != null) clients.add(Client(client, neighbour))
clients.add(Client(neighbour = neighbour)) } else if (tetheredInterfaces.contains(neighbour.dev)) clients.add(Client(neighbour = neighbour))
} clients.addAll(p2p.map { Client(it.value) })
clients.addAll(map.map { Client(it.value) })
clients.sortWith(compareBy<Client> { it.ip }.thenBy { it.mac }) clients.sortWith(compareBy<Client> { it.ip }.thenBy { it.mac })
notifyDataSetChanged() // recreate everything notifyDataSetChanged() // recreate everything
binding.swipeRefresher.isRefreshing = false binding.swipeRefresher.isRefreshing = false