ProfileUpdateActivity 문자열 리소스화
This commit is contained in:
@@ -158,8 +158,9 @@ class ProfileUpdateActivity : BaseActivity<ActivityProfileUpdateBinding>(
|
||||
}
|
||||
|
||||
viewModel.toastLiveData.observe(this) {
|
||||
it?.let {
|
||||
Toast.makeText(applicationContext, it, Toast.LENGTH_LONG).show()
|
||||
val message = it?.resId?.let(::getString) ?: it?.message
|
||||
message?.let { text ->
|
||||
Toast.makeText(applicationContext, text, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +198,7 @@ class ProfileUpdateActivity : BaseActivity<ActivityProfileUpdateBinding>(
|
||||
}
|
||||
|
||||
override fun setupView() {
|
||||
binding.toolbar.tvBack.text = "프로필 수정"
|
||||
binding.toolbar.tvBack.text = getString(R.string.screen_my_edit_profile)
|
||||
binding.toolbar.tvBack.setOnClickListener { finish() }
|
||||
|
||||
loadingDialog = LoadingDialog(this, layoutInflater)
|
||||
@@ -226,8 +227,12 @@ class ProfileUpdateActivity : BaseActivity<ActivityProfileUpdateBinding>(
|
||||
.into(binding.ivProfile)
|
||||
}
|
||||
},
|
||||
onError = { e ->
|
||||
Toast.makeText(this, "${e.message}", Toast.LENGTH_SHORT).show()
|
||||
onError = {
|
||||
Toast.makeText(
|
||||
this,
|
||||
getString(R.string.msg_profile_update_image_pick_failed),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -5,8 +5,10 @@ import androidx.lifecycle.MutableLiveData
|
||||
import com.orhanobut.logger.Logger
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.base.BaseViewModel
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.common.ToastMessage
|
||||
import kr.co.vividnext.sodalive.user.Gender
|
||||
import kr.co.vividnext.sodalive.user.UserRepository
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
@@ -40,8 +42,8 @@ class ProfileUpdateViewModel(private val repository: UserRepository) : BaseViewM
|
||||
val genderLiveData: LiveData<Gender>
|
||||
get() = _genderLiveData
|
||||
|
||||
private val _toastLiveData = MutableLiveData<String?>()
|
||||
val toastLiveData: LiveData<String?>
|
||||
private val _toastLiveData = MutableLiveData<ToastMessage?>()
|
||||
val toastLiveData: LiveData<ToastMessage?>
|
||||
get() = _toastLiveData
|
||||
|
||||
private val _selectedTagLiveData = MutableLiveData<List<String>>()
|
||||
@@ -66,18 +68,16 @@ class ProfileUpdateViewModel(private val repository: UserRepository) : BaseViewM
|
||||
_genderLiveData.postValue(profileResponse.gender)
|
||||
_userInfoLiveData.postValue(profileResponse)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
_toastLiveData.postValue(
|
||||
it.message?.let { message ->
|
||||
ToastMessage(message = message)
|
||||
} ?: ToastMessage(resId = R.string.common_error_unknown)
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
_toastLiveData.postValue(ToastMessage(resId = R.string.common_error_unknown))
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -102,20 +102,20 @@ class ProfileUpdateViewModel(private val repository: UserRepository) : BaseViewM
|
||||
{
|
||||
if (it.success && it.data != null) {
|
||||
onSuccess(it.data)
|
||||
_toastLiveData.postValue("프로필 이미지가 변경되었습니다.")
|
||||
_toastLiveData.postValue(
|
||||
ToastMessage(resId = R.string.msg_profile_update_image_updated)
|
||||
)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
_toastLiveData.postValue(
|
||||
it.message?.let { message ->
|
||||
ToastMessage(message = message)
|
||||
} ?: ToastMessage(resId = R.string.common_error_unknown)
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
_toastLiveData.postValue(ToastMessage(resId = R.string.common_error_unknown))
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -179,17 +179,15 @@ class ProfileUpdateViewModel(private val repository: UserRepository) : BaseViewM
|
||||
{
|
||||
if (it.success) {
|
||||
_toastLiveData.postValue(
|
||||
"프로필이 변경되었습니다."
|
||||
ToastMessage(resId = R.string.msg_profile_update_updated)
|
||||
)
|
||||
onSuccess()
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
_toastLiveData.postValue(
|
||||
it.message?.let { message ->
|
||||
ToastMessage(message = message)
|
||||
} ?: ToastMessage(resId = R.string.common_error_unknown)
|
||||
)
|
||||
}
|
||||
|
||||
_isLoading.value = false
|
||||
@@ -197,7 +195,7 @@ class ProfileUpdateViewModel(private val repository: UserRepository) : BaseViewM
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
_toastLiveData.postValue(ToastMessage(resId = R.string.common_error_unknown))
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -210,17 +208,23 @@ class ProfileUpdateViewModel(private val repository: UserRepository) : BaseViewM
|
||||
val email = SharedPreferenceManager.email
|
||||
|
||||
if (currentPassword.isBlank()) {
|
||||
_toastLiveData.postValue("현재 비밀번호를 입력하세요")
|
||||
_toastLiveData.postValue(
|
||||
ToastMessage(resId = R.string.msg_profile_update_password_current_required)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (newPassword.isBlank()) {
|
||||
_toastLiveData.postValue("변경할 비밀번호를 입력하세요")
|
||||
_toastLiveData.postValue(
|
||||
ToastMessage(resId = R.string.msg_profile_update_password_new_required)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (newPasswordConfirm != newPassword) {
|
||||
_toastLiveData.postValue("비밀번호가 일치하지 않습니다.")
|
||||
_toastLiveData.postValue(
|
||||
ToastMessage(resId = R.string.msg_profile_update_password_mismatch)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -240,17 +244,15 @@ class ProfileUpdateViewModel(private val repository: UserRepository) : BaseViewM
|
||||
{
|
||||
if (it.success) {
|
||||
_toastLiveData.postValue(
|
||||
"비밀번호가 변경되었습니다."
|
||||
ToastMessage(resId = R.string.msg_profile_update_password_updated)
|
||||
)
|
||||
onSuccess()
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
_toastLiveData.postValue(
|
||||
it.message?.let { message ->
|
||||
ToastMessage(message = message)
|
||||
} ?: ToastMessage(resId = R.string.common_error_unknown)
|
||||
)
|
||||
}
|
||||
|
||||
_isLoading.value = false
|
||||
@@ -258,7 +260,7 @@ class ProfileUpdateViewModel(private val repository: UserRepository) : BaseViewM
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
_toastLiveData.postValue(ToastMessage(resId = R.string.common_error_unknown))
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -55,8 +55,9 @@ class ModifyPasswordActivity : BaseActivity<ActivityModifyPasswordBinding>(
|
||||
)
|
||||
|
||||
viewModel.toastLiveData.observe(this) {
|
||||
it?.let {
|
||||
Toast.makeText(applicationContext, it, Toast.LENGTH_LONG).show()
|
||||
val message = it?.resId?.let(::getString) ?: it?.message
|
||||
message?.let { text ->
|
||||
Toast.makeText(applicationContext, text, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user