This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun BadgeEnvelope(count: Int) { | |
Envelope(fire = count > 99, paper = count > 0) { | |
if (count > 0) { | |
Badge(text = "$count") | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun print() { | |
val someData = SomeData("Hello", 1) | |
worker.execute(TransferMode.Safe, { someData }) { | |
printlnt(it) | |
}.result | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public fun <T1, T2> execute( | |
mode: TransferMode, | |
producer: () -> T1, | |
job: (T1) -> T2 | |
): Future<T2> {...} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val worker = Worker.start() | |
worker.execute(TransferMode.SAFE, {"Hello"}) { | |
println(it) | |
}.result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val job = launch(Dispatchers.Default) { | |
repeat (5) { | |
println("Hello $it") | |
delay(500) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val scope = CoroutineScope(Job()) | |
val job = scope.launch { | |
// Coroutine | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
io.ktro.server.netty.EngineMain.main(args) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
} |
NewerOlder