【发布时间】:2022-07-25 12:58:36
【问题描述】:
我的 ViewModel 函数 patchProfileEmailAddress 函数需要 emailAddress 变量
'
private fun saveUserEmailChanges(email: String?) {
profileRepository.patchProfileEmailAddress(emailAddress)
.onEach {
when (it) {
is Result.Success -> {
setLoading(false)
emailAddress = email
updateActionState(
MyProfilePersonInformationASMActionState.DismissBottomSheet)
updateActionState(MyProfilePersonInformationASMActionState.OnSuccess)}
is Result.Error -> {
setLoading(false)
updateActionState(
MyProfilePersonInformationASMActionState
.ShowErrorMessage(it.errorResponse?.message))}
is Result.Loading -> setLoading(true)} }
.launchIn(viewModelScope)}'
我的片段部分
'
var usersNewMail : String? =null
private fun setOnClickListeners() {
binding.apply {
adressArrowImageView.setOnClickListener{ openBodyBottomSheet() }
mailArrowImageView.setOnClickListener{ clickMailArrowImageView() }
checkOkeyImageView.setOnClickListener{ clickOkeyCheckImageView() }}}
private fun getMailChange(){
viewModel.saveUserEmailChanges(usersNewMail)
}
private fun clickMailArrowImageView(){
binding.apply {
txtEditMail.isEnabled = true
checkOkeyImageView.isVisible = true
mailArrowImageView.isVisible = false
}
}
private fun clickOkeyCheckImageView(){
binding.apply {
txtEditMail.isEnabled = false
checkOkeyImageView.isVisible = false
mailArrowImageView.isVisible = true
usersNewMail = txtEditMail.text.toString()
getMailChange()
}
}'
邮递员工作正常。在应用程序补丁响应 500 内部服务器错误。我的 API 需要字符串,而我正在提供字符串。
【问题讨论】:
标签: android kotlin retrofit2 patch http-status-code-500