Skip to content

Instantly share code, notes, and snippets.

@Composable
fun BadgeEnvelope(count: Int) {
Envelope(fire = count > 99, paper = count > 0) {
if (count > 0) {
Badge(text = "$count")
}
}
}
fun print() {
val someData = SomeData("Hello", 1)
worker.execute(TransferMode.Safe, { someData }) {
printlnt(it)
}.result
}
public fun <T1, T2> execute(
mode: TransferMode,
producer: () -> T1,
job: (T1) -> T2
): Future<T2> {...}
val worker = Worker.start()
worker.execute(TransferMode.SAFE, {"Hello"}) {
println(it)
}.result
val job = launch(Dispatchers.Default) {
repeat (5) {
println("Hello $it")
delay(500)
}
}
val startTime = System.currentTimeMillis()
val job = launch (Dispatchers.Default) {
var nextPrintTime = startTime
var i = 0
while (i < 5) {
if (System.currentTimeMillis() >= nextPrintTime) {
println("Hello ${i++}")
nextPrintTime += 500L
}
}
val scope = CoroutineScope(Job())
val job = scope.launch {
// Coroutine
}
fun Application.main() {
// DefaultHeaders adds date and server headers to each response, allowing you to expand with additional data if necessary
install(DefaultHeaders)
// CallLogging – adds logging of responses/queries
install(CallLogging)
// routing – responsible for routing queries and, in our case, uses DSL to formulate a response
routing {
get("/") {
call.respondHtml {
fun main(args: Array<String>) {
io.ktro.server.netty.EngineMain.main(args)
}
private fun createActualInput(lengthCount: Int) = EditText(context)
.apply {
inputType = InputType.TYPE_CLASS_NUMBER
isClickable = false
maxHeight = 0
maxWidth = 0
alpha = 0F
addOrUpdateFilter(InputFilter.LengthFilter(lengthCount))
}