라이브 수정 화면 문자열 리소스로 정리

LiveRoomEdit 화면의 타이틀과 안내 문구를 리소스 키로 치환해 다국어를 적용함

유효성 검증 및 토스트 메시지를 UiText 기반 문자열 리소스로 교체함
This commit is contained in:
2025-12-03 11:10:45 +09:00
parent 99bc5f14f7
commit fd6a025de9
6 changed files with 82 additions and 41 deletions

View File

@@ -64,7 +64,11 @@ class LiveRoomEditActivity : BaseActivity<ActivityLiveRoomEditBinding>(
super.onCreate(savedInstanceState)
if (roomDetail == null) {
Toast.makeText(applicationContext, "잘못된 요청입니다.", Toast.LENGTH_LONG).show()
Toast.makeText(
applicationContext,
getString(R.string.msg_live_room_edit_invalid_request),
Toast.LENGTH_LONG
).show()
finish()
}
@@ -73,13 +77,17 @@ class LiveRoomEditActivity : BaseActivity<ActivityLiveRoomEditBinding>(
binding.etContent.setText(roomDetail.notice)
binding.etNumberOfPeople.setText(roomDetail.numberOfParticipantsTotal.toString())
viewModel.setRoomDetail(roomDetail = roomDetail)
binding.tvNumberOfCharacters.text = getString(
R.string.screen_live_room_create_notice_char_count_format,
binding.etContent.length()
)
}
@SuppressLint("ClickableViewAccessibility")
override fun setupView() {
loadingDialog = LoadingDialog(this, layoutInflater)
binding.toolbar.tvBack.text = "라이브 수정"
binding.toolbar.tvBack.setText(R.string.screen_live_room_profile_edit_title)
binding.toolbar.tvBack.setOnClickListener { finish() }
binding.tvReservationDate.setOnClickListener {
@@ -164,7 +172,6 @@ class LiveRoomEditActivity : BaseActivity<ActivityLiveRoomEditBinding>(
}
}
@SuppressLint("SetTextI18n")
private fun bindData() {
compositeDisposable.add(
binding.etTitle.textChanges().skip(1)
@@ -180,7 +187,10 @@ class LiveRoomEditActivity : BaseActivity<ActivityLiveRoomEditBinding>(
.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()
}
)
@@ -198,8 +208,14 @@ class LiveRoomEditActivity : BaseActivity<ActivityLiveRoomEditBinding>(
}
)
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) {

View File

@@ -7,10 +7,14 @@ 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.extensions.convertDateFormat
import kr.co.vividnext.sodalive.live.LiveRepository
import kr.co.vividnext.sodalive.live.room.detail.GetRoomDetailResponse
import kr.co.vividnext.sodalive.R
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.toRequestBody
import java.util.Locale
@@ -20,16 +24,16 @@ class LiveRoomEditViewModel(
private val repository: LiveRepository
) : BaseViewModel() {
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
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)
@@ -86,7 +90,7 @@ class LiveRoomEditViewModel(
request.numberOfPeople == null &&
request.beginDateTimeString == null
) {
_toastLiveData.value = "변경사항이 없습니다."
_toastLiveData.value = StringResource(R.string.msg_live_room_edit_no_changes)
_isLoading.value = false
return
}
@@ -104,14 +108,15 @@ class LiveRoomEditViewModel(
.subscribe(
{
if (it.success && it.data != null) {
_toastLiveData.value = "라이브 정보가 수정 되었습니다."
_toastLiveData.value =
StringResource(R.string.screen_live_room_info_updated)
onSuccess()
} else {
if (it.message != null) {
_toastLiveData.postValue(it.message)
_toastLiveData.postValue(DynamicString(it.message))
} else {
_toastLiveData.postValue(
"라이브 정보를 수정 하지 못했습니다.\n다시 시도해 주세요."
StringResource(R.string.msg_live_room_edit_update_failed)
)
}
}
@@ -121,7 +126,7 @@ class LiveRoomEditViewModel(
_isLoading.postValue(false)
it.message?.let { message -> Logger.e(message) }
_toastLiveData.postValue(
"라이브 정보를 수정 하지 못했습니다.\n다시 시도해 주세요."
StringResource(R.string.msg_live_room_edit_update_failed)
)
}
)
@@ -161,17 +166,23 @@ class LiveRoomEditViewModel(
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명 사이로 입력해주세요.")
if (numberOfPeople !in 3..999) {
_toastLiveData.postValue(
StringResource(R.string.msg_live_room_create_participants_invalid)
)
return false
}