Refine monitor

This commit is contained in:
Mygod
2018-01-21 01:57:21 -08:00
parent b91cb126a9
commit 9a3606a59e
3 changed files with 13 additions and 17 deletions

View File

@@ -97,11 +97,11 @@ class RepeaterFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClickL
fun recreate() {
clients.clear()
val map = HashMap(p2p.associateBy { it.deviceAddress })
val tethered = (tetheredInterfaces + p2pInterface).filterNotNull()
for (neighbour in neighbours) {
val client = map.remove(neighbour.lladdr)
if (client != null) clients.add(Client(client, neighbour))
else if (tethered.contains(neighbour.dev)) clients.add(Client(neighbour = neighbour))
else if (tetheredInterfaces.contains(neighbour.dev) || neighbour.dev == p2pInterface)
clients.add(Client(neighbour = neighbour))
}
clients.addAll(map.map { Client(it.value) })
clients.sortWith(compareBy<Client> { it.ip }.thenBy { it.mac })