From f70e92199865745c1a01ea3a80ab974d7b568a40 Mon Sep 17 00:00:00 2001 From: pacien Date: Thu, 19 Apr 2018 00:02:32 +0200 Subject: Small rewrite --- .../main/java/org/pacien/tincapp/activities/StatusActivity.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt index 4206f7f..eb6989d 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt @@ -146,7 +146,7 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef } private fun updateNodeList() { - getNodeNames().whenComplete { nodeList, _ -> runOnUiThread { writeNodeList(nodeList) } } + getNodeNames().thenAccept { nodeList -> runOnUiThread { writeNodeList(nodeList) } } } private fun updateView() = when { @@ -163,11 +163,8 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef private const val REFRESH_RATE = 5000L private const val NOW = 0L - fun getNodeNames(): CompletableFuture> = when { - TincVpnService.isConnected() -> - Tinc.dumpNodes(TincVpnService.getCurrentNetName()!!).thenApply> { it.map { it.substringBefore(' ') } } - else -> - Executor.supplyAsyncTask> { emptyList() } - } + fun getNodeNames(): CompletableFuture> = TincVpnService.getCurrentNetName()?.let { netName -> + Tinc.dumpNodes(netName).thenApply> { it.map { it.substringBefore(' ') } } + } ?: Executor.supplyAsyncTask> { emptyList() } } } -- cgit v1.2.3