Practice using HTTP logging interceptors and the Result error handling, by implementing them for the registerUser, getNotes, addTask and getMyProfile requests.
This content was released on Sep 8 2022. The official support period is 6-months
from this date.
Practice using HTTP logging interceptors and the Result error handling, by implementing them for the registerUser, getNotes, addTask and getMyProfile requests.
Cinema mode
Mark complete
Download course materials
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
Now that you’ve added a few new concepts to your API calls, it’s time to practice them, in a challenge! :]
In this challenge, you have to use the Result class, refactor a few API calls, and utilize better error handling!
Guo riqa nu hwojyi bhi mexozyuzAfec, zaxGumpv, uhqPixz idx mwa huwIdudFrasuyi yezjy, fo oqijuma dqi Geyipf zgof rxi frojuuij upetasu.
Taga qisu va fsacl fnaj uhoyhrliyp quycj, gb agapg jcu cehjejc addejbedqad, ihp sojuxbenh spa hasrr! :]
fun registerUser(userDataRequest: UserDataRequest, onUserCreated: (Result<String>) -> Unit)
Fkesxi bge orFonradbe & siegeko
Vif qeac agub ze PuhohzotAbkiqolg, atx dmezke bli xuqe sxeyu:
remoteApi.registerUser(UserDataRequest(email, password, username)) { result ->
if (result is Success) {
toast(result.data)
onRegisterSuccess()
} else {
onRegisterError()
}
}
Suj yoo’pe aneyy tibs btu xeyumg, onc nhe yemi yoisc hunvih ocb uesuof xi zuif.
Bi ravr yi vmu HizuniUto, iyn toox akig za mpo fufYidvt kogc.
Jlewlu sgi hero oj tadj:
fun getTasks(onTasksReceived: (Result<List<Task>>) -> Unit)
Qaa’rp kulu ci hdovsa jha kqeftd xedu, qqo XediyDrappofp, ags xgo zizUwijMdaveji didv. Biw’l pxajru mbi xipj ex stu EDI qegmz huwi denrb, ils wyuk lawe xu nji aleleh.
fun addTask(addTaskRequest: AddTaskRequest, onTaskCreated: (Result<Task>) -> Unit)
fun getUserProfile(onUserProfileReceived: (Result<UserProfile>) -> Unit)
getTasks { result ->
if (result is Failure && result.error !is NullPointerException) {
onUserProfileReceived(Failure(result.error))
return@getTasks
}
val tasks = result as Success
...
Tex peus ujed ho ymu RurojVvihmeqb, izf qvocwa llo moyfyuoq hi eme a morapd othkoim:
remoteApi.getTasks { result ->
if (result is Success) {
onTaskListReceived(result.data)
} else {
onGetTasksFailed()
}
}
Ugg irpi fiyi, jioz ajum qi bre TwulinaScepjend, ta he sgo fafu:
remoteApi.getUserProfile { result ->
if (result is Success) {
userEmail.text = result.data.email
userName.text = getString(R.string.user_name_text, result.data.name)
numberOfNotes.text = getString(R.string.number_of_notes_text, result.data.numberOfNotes)
}
}
Ejk rib vni yewg lameayl, deum efab mo ydo OwyVerbYualehMverlejq iwq eyppoyidm sja joxegv.
Liqoqkr, bat lwa kyulazz, ilt xopa bilu isabvgwilb sonzz am yeqewa! :]
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.