aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorpacien2018-08-01 16:19:29 +0200
committerpacien2018-08-01 16:19:29 +0200
commitea92a3f0797509d8f33833b00b5b5ae115b5d4d6 (patch)
treec74ba3ccf744d385a6d91da5b3af1b5c10687593 /app/src/main/java
parentac154eb8927ba7ace334213b8cd2a7607d11ddfa (diff)
downloadtincapp-ea92a3f0797509d8f33833b00b5b5ae115b5d4d6.tar.gz
Fix node info display race condition
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt34
1 files changed, 21 insertions, 13 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 8ea62cb..a7a1853 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt
@@ -113,19 +113,9 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef
113 refreshTimer?.schedule(timerTask { updateView() }, NOW) 113 refreshTimer?.schedule(timerTask { updateView() }, NOW)
114 } 114 }
115 115
116 override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { 116 override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) = when (view) {
117 val nodeName = (view as TextView).text.toString() 117 is TextView -> showNodeInfo(view.text.toString())
118 val dialogTextView = layoutInflater.inflate(R.layout.dialog_node_details, main_content, false) 118 else -> Unit
119 Tinc.info(TincVpnService.getCurrentNetName()!!, nodeName).thenAccept {
120 runOnUiThread {
121 dialogTextView.dialog_node_details.text = it
122 AlertDialog.Builder(this)
123 .setTitle(R.string.title_node_info)
124 .setView(dialogTextView)
125 .setPositiveButton(R.string.action_close) { _, _ -> Unit }
126 .show()
127 }
128 }
129 } 119 }
130 120
131 private fun onVpnShutdown() { 121 private fun onVpnShutdown() {
@@ -167,6 +157,24 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef
167 getNodeNames().thenAccept { nodeList -> runOnUiThread { writeNodeList(nodeList) } } 157 getNodeNames().thenAccept { nodeList -> runOnUiThread { writeNodeList(nodeList) } }
168 } 158 }
169 159
160 private fun showNodeInfo(nodeName: String) {
161 val dialogTextView = layoutInflater.inflate(R.layout.dialog_node_details, main_content, false)
162
163 runOnUiThread {
164 AlertDialog.Builder(this)
165 .setTitle(R.string.title_node_info)
166 .setView(dialogTextView)
167 .setPositiveButton(R.string.action_close) { _, _ -> Unit }
168 .show()
169 }
170
171 TincVpnService.getCurrentNetName()?.let { netName ->
172 Tinc.info(netName, nodeName).thenAccept { nodeInfo ->
173 runOnUiThread { dialogTextView.dialog_node_details.text = nodeInfo }
174 }
175 }
176 }
177
170 private fun updateView() = when { 178 private fun updateView() = when {
171 TincVpnService.isConnected() -> updateNodeList() 179 TincVpnService.isConnected() -> updateNodeList()
172 else -> openStartActivity() 180 else -> openStartActivity()