Created
January 25, 2019 11:02
-
-
Save andijakl/092369476bd08ccd011dc038b9e2ab09 to your computer and use it in GitHub Desktop.
Functions to perform Add, Delete and Update operations with the web service using Retrofit and Kotlin Coroutines
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 addPart(partItem: PartData) { | |
GlobalScope.launch(Dispatchers.Main) { | |
val webResponse = WebAccess.partsApi.addPartAsync(partItem).await() | |
Log.d(tag, "Add success: ${webResponse.isSuccessful}") | |
// TODO: Re-load list for the recycler view | |
} | |
} | |
private fun deletePart(itemId : Long) { | |
GlobalScope.launch(Dispatchers.Main) { | |
val webResponse = WebAccess.partsApi.deletePartAsync(itemId).await() | |
Log.d(tag, "Delete success: ${webResponse.isSuccessful}") | |
} | |
} | |
private fun updatePart(originalItemId: Long, newItem: PartData) { | |
GlobalScope.launch(Dispatchers.Main) { | |
val webResponse = WebAccess.partsApi.updatePartAsync(originalItemId, newItem).await() | |
Log.d(tag, "Update success: ${webResponse.isSuccessful}") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment