diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-01-26 14:51:36 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-01-26 14:52:57 +0100 |
commit | d3bf2d09f740221771806789b00bf915c9f5f2e3 (patch) | |
tree | 95f99eabd763dff1907f107393504ee75aa747d7 /mobile-kt/app/src/MainActivity.kt | |
parent | 466d03a38cb01e9ff9a2d11be113a81c2bdce34a (diff) |
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!" + } + } + } +} |