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