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 sendCreateUserRequest(firstName: String, lastName: String) { | |
launch(parentJob + UI) { | |
try { | |
val listOfUsers = run(CommonPool) { | |
val user = User(firstName, lastName) | |
RestClient.apiDefinition.createUser(user).execute() | |
} | |
toast("Created user id is ${listOfUsers.body()?.id}") | |
} catch (ex: IOException) { |
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
kotlin { | |
experimental { | |
coroutines "enable" | |
} | |
} |
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
launch(UI) { | |
val value = run(CommonPool) { | |
dataStorageImplementation.getStringValue("some_key") | |
} | |
textView.text = value | |
} |
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
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.19.3" | |
compile "org.jetbrains.kotlinx:kotlinx-coroutines-android:0.19.3" |
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
launch { | |
// some code | |
val value = dataStorageImplementation.getStringValue("some_key") | |
// some code | |
launch (UI) { | |
textView.text = value | |
} | |
} |
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
interface RESTClient{ | |
void getUsersList(RESTListener<List<User>> listListener); | |
void createUser(CreateUserForm userForm, RESTListener<User> listener); | |
void updateUser(String userId, CreateUserForm userForm, RESTListener<User> listener); | |
void getUserDetails(String userId, RESTListener<User> listener); | |
void deleteUser(String userId, RESTListener<String> listener); | |
} |
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
launch { | |
// some code | |
val value = dataStorageImplementation.getStringValue("some_key") | |
// some code | |
} |
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
interface DataStorageContract { | |
suspend fun storeValue(key: String, value: String) | |
suspend fun storeValue(key: String, value: Int) | |
suspend fun getStringValue(key: String): String | |
suspend fun getIntValue(key: String): Int | |
} |
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
interface RESTListener<T>{ | |
void operationFailed(String reason); | |
void operationSuccess(T object); | |
} |
NewerOlder