aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorpacien2018-04-19 00:02:32 +0200
committerpacien2018-04-19 00:02:32 +0200
commitf70e92199865745c1a01ea3a80ab974d7b568a40 (patch)
treeda557a683fbdca16f5322016956908bda7c2d5e9 /app/src
parent818943f7e8bad37af981fc01452822bb040c2ca9 (diff)
downloadtincapp-f70e92199865745c1a01ea3a80ab974d7b568a40.tar.gz
Small rewrite
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt11
1 files 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
146 } 146 }
147 147
148 private fun updateNodeList() { 148 private fun updateNodeList() {
149 getNodeNames().whenComplete { nodeList, _ -> runOnUiThread { writeNodeList(nodeList) } } 149 getNodeNames().thenAccept { nodeList -> runOnUiThread { writeNodeList(nodeList) } }
150 } 150 }
151 151
152 private fun updateView() = when { 152 private fun updateView() = when {
@@ -163,11 +163,8 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef
163 private const val REFRESH_RATE = 5000L 163 private const val REFRESH_RATE = 5000L
164 private const val NOW = 0L 164 private const val NOW = 0L
165 165
166 fun getNodeNames(): CompletableFuture<List<String>> = when { 166 fun getNodeNames(): CompletableFuture<List<String>> = TincVpnService.getCurrentNetName()?.let { netName ->
167 TincVpnService.isConnected() -> 167 Tinc.dumpNodes(netName).thenApply<List<String>> { it.map { it.substringBefore(' ') } }
168 Tinc.dumpNodes(TincVpnService.getCurrentNetName()!!).thenApply<List<String>> { it.map { it.substringBefore(' ') } } 168 } ?: Executor.supplyAsyncTask<List<String>> { emptyList() }
169 else ->
170 Executor.supplyAsyncTask<List<String>> { emptyList() }
171 }
172 } 169 }
173} 170}