diff options
Diffstat (limited to 'mobile-kt/app/src/MainActivity.kt')
-rw-r--r-- | mobile-kt/app/src/MainActivity.kt | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/mobile-kt/app/src/MainActivity.kt b/mobile-kt/app/src/MainActivity.kt new file mode 100644 index 0000000..8d42f6a --- /dev/null +++ b/mobile-kt/app/src/MainActivity.kt @@ -0,0 +1,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!" + } + } + } +} |