var userList: MutableList<User> = mutableListOf()
private fun onResponse(response: UserListResponse): List<User> {
var thisUserList: MutableList<User> = mutableListOf()
for (user in response.users) {
val myUser = User(
id = user.userId,
firstName = user.userFirstName,
lastName = user.userLastName,
email = user.userEmail,
image = user.userImgUrl
)
thisUserList.add(myUser)
// Log.d("user info:", user.userId.toString())
// Log.d("user info:", user.userFirstName)
// Log.d("user info:", user.userLastName)
// Log.d("user info:", user.userEmail)
// Log.d("user info:", user.userImgUrl)
}
return thisUserList
}
fun fetchUserList(usersApi: UsersApi?) {
usersApi?.let {
compositeDisposable.add(
usersApi.getUserList()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
userList = onResponse(it) as MutableList<User>
}, {
}
))
}
}
Ну вот в фрагменте пытаюсь прочитать
Выдаёт он следующую ошибку
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0