From d3bf2d09f740221771806789b00bf915c9f5f2e3 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Fri, 26 Jan 2024 14:51:36 +0100 Subject: initial commit --- mobile-kt/app/src/MainActivity.kt | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 mobile-kt/app/src/MainActivity.kt (limited to 'mobile-kt/app/src/MainActivity.kt') 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(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(R.id.tv_label).text = "Hello Bazel, from Kotlin And Coroutine!" + } + } + } +} -- cgit v1.2.3