This file contains hidden or 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
<application | |
.. | |
android:icon="@drawable/ic_launcher_overlaid" | |
..> | |
<activity | |
..> | |
</activity> | |
</application> |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > | |
<item> | |
<!-- Your original launcher icon --> | |
<bitmap android:src="@mipmap/ic_launcher" /> | |
</item> | |
<item | |
android:left="100dp" | |
android:top="100dp"> |
This file contains hidden or 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 lock = Any() | |
var latestValue: Int = 0 | |
suspend fun runSuspendFunctionBadly(input: Int) { | |
println("running suspend function with input $input") | |
synchronized(lock) { | |
delay(1000) | |
latestValue = input | |
} |
This file contains hidden or 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 saveUsernameAndPassword(username: String, password: String) { | |
val result = StorageService.getInstance()::saveUsernameAndPassword suspendAndInvokeWith Pair(username, password) | |
handleResult(result) | |
} | |
private suspend infix fun <Input1, Input2, Output> ((Input1, Input2, (Output) -> Unit) -> Unit).suspendAndInvokeWith(pair: Pair<Input1, Input2>): Output { | |
return suspendAsync(this, pair.first, pair.second) | |
} |
This file contains hidden or 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 saveUsername(username: String) { | |
val result = StorageService.getInstance()::saveUsername suspendAndInvokeWith username | |
handleResult(result) | |
} | |
private suspend infix fun <Input, Output> ((Input, (Output) -> Unit) -> Unit).suspendAndInvokeWith(input: Input): Output { | |
return suspendAsync(this, input) | |
} |
This file contains hidden or 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
suspend fun saveUsernameAndPassword(username: String, password: String) { | |
val result = suspendAsync(StorageService.getInstance()::saveUsernameAndPassword, username, password) | |
handleResult(result) | |
} | |
suspend fun <Input1, Input2, Output> suspendAsync(function: (Input1, Input2, (Output) -> Unit) -> Unit, | |
inputOne: Input1, inputTwo: Input2) = suspendCoroutine<Output> { continuation -> | |
function(inputOne, inputTwo) { output -> | |
continuation.resume(output) |
This file contains hidden or 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
suspend fun saveUsername(username: String) { | |
val result = suspendAsync(StorageService.getInstance()::saveUsername, username) | |
handleResult(result) | |
} | |
suspend fun <Input, Output> suspendAsync(function: (Input, (Output) -> Unit) -> Unit, | |
input: Input) = suspendCoroutine<Output> { continuation -> | |
function(input) { output -> | |
continuation.resume(output) |
This file contains hidden or 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
suspend fun saveUsername(username: String) { | |
val result = suspendedSaveUsername(username) | |
handleResult(result) | |
} | |
suspend fun suspendedSaveUsername(username: String) = suspendCoroutine<String> { continuation -> | |
StorageService.getInstance().saveUsername(username) { result -> | |
continuation.resume(result) |
This file contains hidden or 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 saveUsername(username: String) { | |
StorageService.getInstance().saveUsername(username) { result -> | |
handleResult(result) | |
} | |
} |
This file contains hidden or 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
inline fun <reified Interface, Input, Result> callFunction( | |
apiCall: [THE INTERCHANGEABLE BIT], | |
input: Input //If there is an input | |
): Result? |
NewerOlder