고객센터 화면 문자열 리소스화

This commit is contained in:
2025-12-02 14:08:56 +09:00
parent b457cf0b4d
commit 7b6d2cd782
8 changed files with 48 additions and 24 deletions

View File

@@ -42,7 +42,11 @@ class FaqCategoryAdapter(
}
val item = items[position]
viewHolder.tvCategory.text = item
viewHolder.tvCategory.text = if (item.isBlank()) {
context.getString(R.string.screen_service_center_faq_category_all)
} else {
item
}
viewHolder.tvCategory.setBackgroundResource(
if (item == selectedCategory) {
R.drawable.bg_round_corner_4_7_3bb9f1

View File

@@ -10,6 +10,7 @@ import android.widget.LinearLayout
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.base.BaseActivity
import kr.co.vividnext.sodalive.databinding.ActivityServiceCenterBinding
import kr.co.vividnext.sodalive.extensions.dpToPx
@@ -30,7 +31,7 @@ class ServiceCenterActivity : BaseActivity<ActivityServiceCenterBinding>(
@SuppressLint("NotifyDataSetChanged")
override fun setupView() {
binding.toolbar.tvBack.text = "고객센터"
binding.toolbar.tvBack.text = getString(R.string.screen_service_center_title)
binding.toolbar.tvBack.setOnClickListener { finish() }
val categoryAdapter = FaqCategoryAdapter(this)
@@ -86,7 +87,10 @@ class ServiceCenterActivity : BaseActivity<ActivityServiceCenterBinding>(
recyclerView.adapter = faqAdapter
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()
}
}
viewModel.categoriesLiveData.observe(this) {

View File

@@ -6,6 +6,8 @@ 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.ToastMessage
import kr.co.vividnext.sodalive.R
class ServiceCenterViewModel(val repository: FaqRepository) : BaseViewModel() {
@@ -17,8 +19,8 @@ class ServiceCenterViewModel(val repository: FaqRepository) : BaseViewModel() {
val faqLiveData: LiveData<List<Faq>>
get() = _faqLiveData
private val _toastLiveData = MutableLiveData<String?>()
val toastLiveData: LiveData<String?>
private val _toastLiveData = MutableLiveData<ToastMessage?>()
val toastLiveData: LiveData<ToastMessage?>
get() = _toastLiveData
fun getFaqCategories() {
@@ -31,18 +33,16 @@ class ServiceCenterViewModel(val repository: FaqRepository) : BaseViewModel() {
if (it.success && it.data != null) {
_categoriesLiveData.postValue(it.data!!)
} 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))
}
)
)
@@ -58,18 +58,16 @@ class ServiceCenterViewModel(val repository: FaqRepository) : BaseViewModel() {
if (it.success && it.data != null) {
_faqLiveData.postValue(it.data!!)
} 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))
}
)
)