메뉴 설정 화면 문자열 리소스화
메뉴 선택/저장 UI 텍스트를 문자열 리소스와 다국어 번역으로 교체함 메뉴 프리셋 선택/저장 토스트를 UiText 기반으로 공통 오류 메시지 사용
This commit is contained in:
@@ -40,7 +40,7 @@ class MenuConfigActivity : BaseActivity<ActivityMenuConfigBinding>(
|
||||
}
|
||||
|
||||
override fun setupView() {
|
||||
binding.toolbar.tvBack.text = "메뉴 설정"
|
||||
binding.toolbar.tvBack.setText(R.string.screen_menu_config_title)
|
||||
binding.toolbar.tvBack.setOnClickListener { finish() }
|
||||
|
||||
loadingDialog = LoadingDialog(this, layoutInflater)
|
||||
@@ -71,7 +71,9 @@ class MenuConfigActivity : BaseActivity<ActivityMenuConfigBinding>(
|
||||
}
|
||||
|
||||
private fun bindData() {
|
||||
viewModel.toastLiveData.observe(this) { it?.let { showToast(it) } }
|
||||
viewModel.toastLiveData.observe(this) { uiText ->
|
||||
uiText?.let { showToast(it.asString(this)) }
|
||||
}
|
||||
viewModel.isLoading.observe(this) {
|
||||
if (it) {
|
||||
loadingDialog.show(screenWidth)
|
||||
|
||||
@@ -6,8 +6,12 @@ import com.orhanobut.logger.Logger
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.base.BaseViewModel
|
||||
import kr.co.vividnext.sodalive.common.UiText
|
||||
import kr.co.vividnext.sodalive.common.UiText.DynamicString
|
||||
import kr.co.vividnext.sodalive.common.UiText.StringResource
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.live.room.create.LiveRoomCreateViewModel
|
||||
import kr.co.vividnext.sodalive.R
|
||||
|
||||
class MenuConfigViewModel(private val repository: MenuConfigRepository) : BaseViewModel() {
|
||||
|
||||
@@ -15,8 +19,8 @@ class MenuConfigViewModel(private val repository: MenuConfigRepository) : BaseVi
|
||||
val isLoading: LiveData<Boolean>
|
||||
get() = _isLoading
|
||||
|
||||
private val _toastLiveData = MutableLiveData<String?>()
|
||||
val toastLiveData: LiveData<String?>
|
||||
private val _toastLiveData = MutableLiveData<UiText?>()
|
||||
val toastLiveData: LiveData<UiText?>
|
||||
get() = _toastLiveData
|
||||
|
||||
private val _selectedMenuLiveData = MutableLiveData<LiveRoomCreateViewModel.SelectedMenu>()
|
||||
@@ -51,10 +55,10 @@ class MenuConfigViewModel(private val repository: MenuConfigRepository) : BaseVi
|
||||
selectMenuPreset(selectedMenu)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
_toastLiveData.postValue(DynamicString(it.message))
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
StringResource(R.string.common_error_unknown)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -63,7 +67,9 @@ class MenuConfigViewModel(private val repository: MenuConfigRepository) : BaseVi
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
_toastLiveData.postValue(
|
||||
StringResource(R.string.common_error_unknown)
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -77,12 +83,14 @@ class MenuConfigViewModel(private val repository: MenuConfigRepository) : BaseVi
|
||||
selectedMenuPreset == LiveRoomCreateViewModel.SelectedMenu.MENU_3
|
||||
)
|
||||
) {
|
||||
_toastLiveData.value = "메뉴 1을 먼저 설정하세요"
|
||||
_toastLiveData.value =
|
||||
StringResource(R.string.screen_live_room_menu_first_required)
|
||||
return
|
||||
}
|
||||
|
||||
if (menuList.size == 1 && selectedMenuPreset == LiveRoomCreateViewModel.SelectedMenu.MENU_3) {
|
||||
_toastLiveData.value = "메뉴 1과 메뉴 2를 먼저 설정하세요"
|
||||
_toastLiveData.value =
|
||||
StringResource(R.string.screen_live_room_menu_first_second_required)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -105,7 +113,7 @@ class MenuConfigViewModel(private val repository: MenuConfigRepository) : BaseVi
|
||||
|
||||
fun saveMenu() {
|
||||
if (menuText == _selectedMenuTextLiveData.value) {
|
||||
_toastLiveData.postValue("저장되었습니다.")
|
||||
_toastLiveData.postValue(StringResource(R.string.msg_menu_config_saved))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -121,14 +129,16 @@ class MenuConfigViewModel(private val repository: MenuConfigRepository) : BaseVi
|
||||
.subscribe(
|
||||
{
|
||||
if (it.success) {
|
||||
_toastLiveData.postValue("저장되었습니다.")
|
||||
_toastLiveData.postValue(
|
||||
StringResource(R.string.msg_menu_config_saved)
|
||||
)
|
||||
getAllMenuPreset(selectedMenu = _selectedMenuLiveData.value!!)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
_toastLiveData.postValue(DynamicString(it.message))
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
StringResource(R.string.common_error_unknown)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -137,7 +147,9 @@ class MenuConfigViewModel(private val repository: MenuConfigRepository) : BaseVi
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
_toastLiveData.postValue(
|
||||
StringResource(R.string.common_error_unknown)
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user