blob: 8d42f6a587d9e676fb934a6607c1e3c5f17f6b15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package org.pihole.dnsproxy;
import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import kotlinx.coroutines.*
class MainActivity : AppCompatActivity() {
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
findViewById<TextView>(R.id.tv_label).text = "Hello Bazel, from Kotlin!"
`kotlin_13_test`("test")
launchCoroutine()
}
private fun kotlin_13_test(x: String?) {
if (!x.isNullOrEmpty()) {
println("length of '$x' is ${x.length}") // Yay, smartcasted to not-null!
}
}
private fun launchCoroutine() {
GlobalScope.launch(context = Dispatchers.Default) {
delay(1000)
withContext(context = Dispatchers.Main) {
findViewById<TextView>(R.id.tv_label).text = "Hello Bazel, from Kotlin And Coroutine!"
}
}
}
}
|