마이페이지 문자열 리소스화
This commit is contained in:
@@ -234,7 +234,7 @@ class MyPageFragment : BaseFragment<FragmentMyBinding>(FragmentMyBinding::inflat
|
||||
FunctionButtonHelper.setupFunctionButton(
|
||||
buttonView = binding.btnStorage.root,
|
||||
iconRes = R.drawable.ic_my_storage,
|
||||
title = "보관함"
|
||||
title = getString(R.string.screen_my_storage)
|
||||
) {
|
||||
startActivity(
|
||||
Intent(
|
||||
@@ -247,7 +247,7 @@ class MyPageFragment : BaseFragment<FragmentMyBinding>(FragmentMyBinding::inflat
|
||||
FunctionButtonHelper.setupFunctionButton(
|
||||
buttonView = binding.btnBlockList.root,
|
||||
iconRes = R.drawable.ic_my_block,
|
||||
title = "차단목록"
|
||||
title = getString(R.string.screen_my_block_list)
|
||||
) {
|
||||
startActivity(
|
||||
Intent(
|
||||
@@ -260,7 +260,7 @@ class MyPageFragment : BaseFragment<FragmentMyBinding>(FragmentMyBinding::inflat
|
||||
FunctionButtonHelper.setupFunctionButton(
|
||||
buttonView = binding.btnMorningCall.root,
|
||||
iconRes = R.drawable.ic_my_alarm,
|
||||
title = "모닝콜"
|
||||
title = getString(R.string.screen_my_morning_call)
|
||||
) {
|
||||
startActivity(
|
||||
Intent(
|
||||
@@ -273,7 +273,7 @@ class MyPageFragment : BaseFragment<FragmentMyBinding>(FragmentMyBinding::inflat
|
||||
FunctionButtonHelper.setupFunctionButton(
|
||||
buttonView = binding.btnNotice.root,
|
||||
iconRes = R.drawable.ic_my_notice,
|
||||
title = "공지사항"
|
||||
title = getString(R.string.screen_my_notice)
|
||||
) {
|
||||
startActivity(
|
||||
Intent(
|
||||
@@ -286,7 +286,7 @@ class MyPageFragment : BaseFragment<FragmentMyBinding>(FragmentMyBinding::inflat
|
||||
FunctionButtonHelper.setupFunctionButton(
|
||||
buttonView = binding.btnEvent.root,
|
||||
iconRes = R.drawable.ic_my_event,
|
||||
title = "이벤트"
|
||||
title = getString(R.string.screen_my_event)
|
||||
) {
|
||||
startActivity(
|
||||
Intent(
|
||||
@@ -299,7 +299,7 @@ class MyPageFragment : BaseFragment<FragmentMyBinding>(FragmentMyBinding::inflat
|
||||
FunctionButtonHelper.setupFunctionButton(
|
||||
buttonView = binding.btnCustomerService.root,
|
||||
iconRes = R.drawable.ic_my_service_center,
|
||||
title = "고객센터"
|
||||
title = getString(R.string.screen_my_customer_service)
|
||||
) {
|
||||
startActivity(
|
||||
Intent(
|
||||
@@ -310,21 +310,21 @@ class MyPageFragment : BaseFragment<FragmentMyBinding>(FragmentMyBinding::inflat
|
||||
}
|
||||
|
||||
if (SharedPreferenceManager.role == MemberRole.CREATOR.name) {
|
||||
binding.tvMyChannel.visibility = View.VISIBLE
|
||||
binding.tvMyChannel.setOnClickListener {
|
||||
startActivity(
|
||||
Intent(
|
||||
requireContext(),
|
||||
UserProfileActivity::class.java
|
||||
).apply {
|
||||
putExtra(
|
||||
Constants.EXTRA_USER_ID,
|
||||
SharedPreferenceManager.userId
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
} else {
|
||||
binding.tvMyChannel.visibility = View.VISIBLE
|
||||
binding.tvMyChannel.setOnClickListener {
|
||||
startActivity(
|
||||
Intent(
|
||||
requireContext(),
|
||||
UserProfileActivity::class.java
|
||||
).apply {
|
||||
putExtra(
|
||||
Constants.EXTRA_USER_ID,
|
||||
SharedPreferenceManager.userId
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
} else {
|
||||
binding.tvMyChannel.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
@@ -355,7 +355,10 @@ class MyPageFragment : BaseFragment<FragmentMyBinding>(FragmentMyBinding::inflat
|
||||
@SuppressLint("SetTextI18n", "NotifyDataSetChanged")
|
||||
private fun bindData() {
|
||||
viewModel.toastLiveData.observe(viewLifecycleOwner) {
|
||||
it?.let { Toast.makeText(requireContext(), it, Toast.LENGTH_LONG).show() }
|
||||
val text = it?.message ?: it?.resId?.let { resId -> getString(resId) }
|
||||
if (!text.isNullOrBlank()) {
|
||||
Toast.makeText(requireContext(), text, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.isLoading.observe(viewLifecycleOwner) {
|
||||
@@ -371,13 +374,13 @@ class MyPageFragment : BaseFragment<FragmentMyBinding>(FragmentMyBinding::inflat
|
||||
FunctionButtonHelper.setupFunctionButton(
|
||||
buttonView = binding.btnIdentityVerification.root,
|
||||
iconRes = R.drawable.ic_my_auth,
|
||||
title = "인증완료"
|
||||
title = getString(R.string.screen_my_identity_verified)
|
||||
)
|
||||
|
||||
FunctionButtonHelper.setupFunctionButton(
|
||||
buttonView = binding.btnCoupon.root,
|
||||
iconRes = R.drawable.ic_my_coupon,
|
||||
title = "쿠폰등록"
|
||||
title = getString(R.string.screen_my_coupon_register)
|
||||
) {
|
||||
startActivity(
|
||||
Intent(
|
||||
@@ -390,7 +393,7 @@ class MyPageFragment : BaseFragment<FragmentMyBinding>(FragmentMyBinding::inflat
|
||||
FunctionButtonHelper.setupFunctionButton(
|
||||
buttonView = binding.btnIdentityVerification.root,
|
||||
iconRes = R.drawable.ic_my_auth,
|
||||
title = "본인인증"
|
||||
title = getString(R.string.screen_my_identity_verification)
|
||||
) {
|
||||
showAuthDialog()
|
||||
}
|
||||
@@ -398,11 +401,11 @@ class MyPageFragment : BaseFragment<FragmentMyBinding>(FragmentMyBinding::inflat
|
||||
FunctionButtonHelper.setupFunctionButton(
|
||||
buttonView = binding.btnCoupon.root,
|
||||
iconRes = R.drawable.ic_my_coupon,
|
||||
title = "쿠폰등록"
|
||||
title = getString(R.string.screen_my_coupon_register)
|
||||
) {
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
"본인인증 후 사용가능합니다.",
|
||||
getString(R.string.screen_my_auth_required),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package kr.co.vividnext.sodalive.mypage
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.orhanobut.logger.Logger
|
||||
@@ -14,14 +15,15 @@ import kr.co.vividnext.sodalive.settings.ContentType
|
||||
import kr.co.vividnext.sodalive.settings.notice.NoticeItem
|
||||
import kr.co.vividnext.sodalive.settings.notice.NoticeRepository
|
||||
import kr.co.vividnext.sodalive.user.UserRepository
|
||||
import kr.co.vividnext.sodalive.R
|
||||
|
||||
class MyPageViewModel(
|
||||
private val userRepository: UserRepository,
|
||||
private val authRepository: AuthRepository,
|
||||
private val noticeRepository: NoticeRepository
|
||||
) : BaseViewModel() {
|
||||
private val _toastLiveData = MutableLiveData<String?>()
|
||||
val toastLiveData: LiveData<String?>
|
||||
private val _toastLiveData = MutableLiveData<MyPageToastMessage?>()
|
||||
val toastLiveData: LiveData<MyPageToastMessage?>
|
||||
get() = _toastLiveData
|
||||
|
||||
private var _isLoading = MutableLiveData(false)
|
||||
@@ -50,20 +52,22 @@ class MyPageViewModel(
|
||||
if (it.success && it.data != null) {
|
||||
_myPageLiveData.postValue(it.data!!)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
_toastLiveData.postValue(
|
||||
if (it.message != null) {
|
||||
MyPageToastMessage(message = it.message)
|
||||
} else {
|
||||
MyPageToastMessage(resId = R.string.screen_my_error_unknown)
|
||||
}
|
||||
)
|
||||
}
|
||||
_isLoading.value = false
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
_toastLiveData.postValue(
|
||||
MyPageToastMessage(resId = R.string.screen_my_error_unknown)
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -89,13 +93,13 @@ class MyPageViewModel(
|
||||
|
||||
onSuccess()
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
_toastLiveData.postValue(
|
||||
if (it.message != null) {
|
||||
MyPageToastMessage(message = it.message)
|
||||
} else {
|
||||
MyPageToastMessage(resId = R.string.screen_my_error_unknown)
|
||||
}
|
||||
)
|
||||
|
||||
_isLoading.value = false
|
||||
}
|
||||
@@ -103,7 +107,9 @@ class MyPageViewModel(
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
_toastLiveData.postValue(
|
||||
MyPageToastMessage(resId = R.string.screen_my_error_unknown)
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -130,3 +136,8 @@ class MyPageViewModel(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class MyPageToastMessage(
|
||||
@StringRes val resId: Int? = null,
|
||||
val message: String? = null
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user