라이브 생성 화면 문자열 리소스화
라이브 생성 입력/검증/라벨 문자열을 ko/en/ja 리소스로 분리 토스트, 로딩, 태그 제한 문구를 리소스 기반으로 통일
This commit is contained in:
@@ -99,7 +99,7 @@ class LiveRoomCreateActivity : BaseActivity<ActivityLiveRoomCreateBinding>(
|
||||
else -> {
|
||||
Toast.makeText(
|
||||
this,
|
||||
"최대 3개까지 선택 가능합니다.",
|
||||
getString(R.string.msg_live_room_create_tag_limit),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
return@LiveTagFragment false
|
||||
@@ -156,7 +156,12 @@ class LiveRoomCreateActivity : BaseActivity<ActivityLiveRoomCreateBinding>(
|
||||
viewModel.coverImagePath = null
|
||||
},
|
||||
onError = { e ->
|
||||
Toast.makeText(this, "${e.message}", Toast.LENGTH_SHORT).show()
|
||||
val errorMessage = e.message ?: getString(R.string.common_error_unknown)
|
||||
Toast.makeText(
|
||||
this,
|
||||
getString(R.string.msg_live_room_create_cover_pick_error, errorMessage),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
)
|
||||
|
||||
@@ -177,6 +182,15 @@ class LiveRoomCreateActivity : BaseActivity<ActivityLiveRoomCreateBinding>(
|
||||
binding.llTimeNow.setOnClickListener { viewModel.setTimeNow(true) }
|
||||
binding.llTimeReservation.setOnClickListener { viewModel.setTimeNow(false) }
|
||||
|
||||
binding.tvNumberOfCharacters.text =
|
||||
getString(R.string.screen_live_room_create_notice_char_count_placeholder)
|
||||
viewModel.setReservationDate(
|
||||
getString(R.string.screen_live_room_create_reservation_date_placeholder)
|
||||
)
|
||||
viewModel.setReservationTime(
|
||||
getString(R.string.screen_live_room_create_reservation_time_placeholder)
|
||||
)
|
||||
|
||||
binding.tvReservationDate.setOnClickListener {
|
||||
val reservationDate = viewModel.beginDate.split("-")
|
||||
val datePicker: DatePickerDialog
|
||||
@@ -367,7 +381,10 @@ class LiveRoomCreateActivity : BaseActivity<ActivityLiveRoomCreateBinding>(
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
binding.tvNumberOfCharacters.text = "${it.length}자"
|
||||
binding.tvNumberOfCharacters.text = getString(
|
||||
R.string.screen_live_room_create_notice_char_count_format,
|
||||
it.length
|
||||
)
|
||||
viewModel.content = it.toString()
|
||||
}
|
||||
)
|
||||
@@ -411,13 +428,22 @@ class LiveRoomCreateActivity : BaseActivity<ActivityLiveRoomCreateBinding>(
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.toastLiveData.observe(this) {
|
||||
it?.let { Toast.makeText(applicationContext, it, Toast.LENGTH_LONG).show() }
|
||||
viewModel.toastLiveData.observe(this) { uiText ->
|
||||
uiText?.let {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
it.asString(this),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.isLoading.observe(this) {
|
||||
if (it) {
|
||||
loadingDialog.show(screenWidth, "라이브를 생성하는 중입니다.")
|
||||
loadingDialog.show(
|
||||
screenWidth,
|
||||
getString(R.string.dialog_live_room_create_loading)
|
||||
)
|
||||
} else {
|
||||
loadingDialog.dismiss()
|
||||
}
|
||||
|
||||
@@ -9,9 +9,13 @@ 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.SharedPreferenceManager
|
||||
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.live.LiveRepository
|
||||
import kr.co.vividnext.sodalive.live.room.LiveRoomType
|
||||
import kr.co.vividnext.sodalive.live.room.menu.GetMenuPresetResponse
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.MultipartBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
@@ -35,11 +39,11 @@ class LiveRoomCreateViewModel(
|
||||
val timeNowLiveData: LiveData<Boolean>
|
||||
get() = _timeNowLiveData
|
||||
|
||||
private val _reservationDateLiveData = MutableLiveData("날짜를 선택해주세요")
|
||||
private val _reservationDateLiveData = MutableLiveData("")
|
||||
val reservationDateLiveData: LiveData<String>
|
||||
get() = _reservationDateLiveData
|
||||
|
||||
private val _reservationTimeLiveData = MutableLiveData("시간을 설정해주세요")
|
||||
private val _reservationTimeLiveData = MutableLiveData("")
|
||||
val reservationTimeLiveData: LiveData<String>
|
||||
get() = _reservationTimeLiveData
|
||||
|
||||
@@ -47,8 +51,8 @@ class LiveRoomCreateViewModel(
|
||||
val selectedLiveData: LiveData<List<String>>
|
||||
get() = _selectedLiveData
|
||||
|
||||
private val _toastLiveData = MutableLiveData<String?>()
|
||||
val toastLiveData: LiveData<String?>
|
||||
private val _toastLiveData = MutableLiveData<UiText?>()
|
||||
val toastLiveData: LiveData<UiText?>
|
||||
get() = _toastLiveData
|
||||
|
||||
private var _isLoading = MutableLiveData(false)
|
||||
@@ -179,10 +183,10 @@ class LiveRoomCreateViewModel(
|
||||
onSuccess(it.data!!)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
_toastLiveData.postValue(DynamicString(it.message))
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
StringResource(R.string.common_error_unknown)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -191,7 +195,7 @@ class LiveRoomCreateViewModel(
|
||||
{
|
||||
_isLoading.postValue(false)
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
_toastLiveData.postValue(StringResource(R.string.common_error_unknown))
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -210,27 +214,29 @@ class LiveRoomCreateViewModel(
|
||||
|
||||
private fun validateData(): Boolean {
|
||||
if (title.isBlank()) {
|
||||
_toastLiveData.postValue("제목을 입력해주세요.")
|
||||
_toastLiveData.postValue(StringResource(R.string.msg_live_room_create_title_required))
|
||||
return false
|
||||
}
|
||||
|
||||
if (content.isBlank() || content.length < 5) {
|
||||
_toastLiveData.postValue("내용을 5자 이상 입력해주세요.")
|
||||
_toastLiveData.postValue(StringResource(R.string.msg_live_room_create_notice_required))
|
||||
return false
|
||||
}
|
||||
|
||||
if (numberOfPeople < 3 || numberOfPeople > 999) {
|
||||
_toastLiveData.postValue("인원을 3~999명 사이로 입력해주세요.")
|
||||
_toastLiveData.postValue(
|
||||
StringResource(R.string.msg_live_room_create_participants_invalid)
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
if (coverImageFile == null && coverImagePath == null) {
|
||||
_toastLiveData.postValue("커버이미지를 선택해주세요.")
|
||||
_toastLiveData.postValue(StringResource(R.string.msg_live_room_create_cover_required))
|
||||
return false
|
||||
}
|
||||
|
||||
if (!_timeNowLiveData.value!! && (beginDate.isBlank() || beginTime.isBlank())) {
|
||||
_toastLiveData.postValue("예약날짜와 시간을 선택해주세요.")
|
||||
_toastLiveData.postValue(StringResource(R.string.msg_live_room_create_schedule_required))
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -238,12 +244,12 @@ class LiveRoomCreateViewModel(
|
||||
_roomTypeLiveData.value!! == LiveRoomType.PRIVATE &&
|
||||
(password == null || password!!.length != 6)
|
||||
) {
|
||||
_toastLiveData.postValue("방 입장 비밀번호 6자리를 입력해 주세요.")
|
||||
_toastLiveData.postValue(StringResource(R.string.screen_live_room_create_password_hint))
|
||||
return false
|
||||
}
|
||||
|
||||
if (_isActivateMenuLiveData.value!! && menu.isBlank()) {
|
||||
_toastLiveData.postValue("메뉴판은 빈칸일 수 없습니다.")
|
||||
_toastLiveData.postValue(StringResource(R.string.msg_live_room_create_menu_required))
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -275,13 +281,15 @@ class LiveRoomCreateViewModel(
|
||||
coverImagePath = it.data.coverImagePath
|
||||
onSuccess(it.data!!)
|
||||
|
||||
_toastLiveData.postValue("최근데이터를 불러왔습니다.")
|
||||
_toastLiveData.postValue(
|
||||
StringResource(R.string.msg_live_room_create_recent_loaded)
|
||||
)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
_toastLiveData.postValue(DynamicString(it.message))
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"최근데이터를 불러오지 못했습니다.\n다시 시도해 주세요."
|
||||
StringResource(R.string.msg_live_room_create_recent_load_failed)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -291,7 +299,9 @@ class LiveRoomCreateViewModel(
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("최근데이터를 불러오지 못했습니다.\n다시 시도해 주세요.")
|
||||
_toastLiveData.postValue(
|
||||
StringResource(R.string.msg_live_room_create_recent_load_failed)
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -305,12 +315,13 @@ class LiveRoomCreateViewModel(
|
||||
selectedMenuPreset == SelectedMenu.MENU_3
|
||||
)
|
||||
) {
|
||||
_toastLiveData.value = "메뉴 1을 먼저 설정하세요"
|
||||
_toastLiveData.value = StringResource(R.string.screen_live_room_menu_first_required)
|
||||
return
|
||||
}
|
||||
|
||||
if (menuList.size == 1 && selectedMenuPreset == SelectedMenu.MENU_3) {
|
||||
_toastLiveData.value = "메뉴 1과 메뉴 2를 먼저 설정하세요"
|
||||
_toastLiveData.value =
|
||||
StringResource(R.string.screen_live_room_menu_first_second_required)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -355,10 +366,10 @@ class LiveRoomCreateViewModel(
|
||||
selectMenuPreset(SelectedMenu.MENU_1)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
_toastLiveData.postValue(DynamicString(it.message))
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
StringResource(R.string.common_error_unknown)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -367,7 +378,7 @@ class LiveRoomCreateViewModel(
|
||||
{
|
||||
_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