From 7f31b633943a2a403b07606e662835afae42acd5 Mon Sep 17 00:00:00 2001 From: Mygod Date: Sat, 10 Feb 2018 23:03:45 -0800 Subject: [PATCH] Prefer p2p client list --- .../java/be/mygod/vpnhotspot/RepeaterFragment.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterFragment.kt b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterFragment.kt index 451f0737..c26bbecb 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterFragment.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterFragment.kt @@ -101,14 +101,13 @@ class RepeaterFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClickL fun recreate() { clients.clear() - val map = HashMap(p2p.associateBy { it.deviceAddress }) - for (neighbour in neighbours) { - val client = map.remove(neighbour.lladdr) - if (client != null) clients.add(Client(client, neighbour)) - else if (tetheredInterfaces.contains(neighbour.dev) || neighbour.dev == p2pInterface) - clients.add(Client(neighbour = neighbour)) - } - clients.addAll(map.map { Client(it.value) }) + val p2p = HashMap(p2p.associateBy { it.deviceAddress }) + for (neighbour in neighbours) + if (neighbour.dev == p2pInterface) { + val client = p2p.remove(neighbour.lladdr) + if (client != null) clients.add(Client(client, neighbour)) + } else if (tetheredInterfaces.contains(neighbour.dev)) clients.add(Client(neighbour = neighbour)) + clients.addAll(p2p.map { Client(it.value) }) clients.sortWith(compareBy { it.ip }.thenBy { it.mac }) notifyDataSetChanged() // recreate everything binding.swipeRefresher.isRefreshing = false