차단 목록 화면 문자열 리소스화
This commit is contained in:
@@ -7,6 +7,7 @@ import android.view.View
|
||||
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.common.LoadingDialog
|
||||
import kr.co.vividnext.sodalive.databinding.ActivityBlockMemberBinding
|
||||
@@ -30,7 +31,7 @@ class BlockMemberActivity : BaseActivity<ActivityBlockMemberBinding>(
|
||||
|
||||
override fun setupView() {
|
||||
loadingDialog = LoadingDialog(this, layoutInflater)
|
||||
binding.toolbar.tvBack.text = "차단 리스트"
|
||||
binding.toolbar.tvBack.text = getString(R.string.screen_block_member_title)
|
||||
binding.toolbar.tvBack.setOnClickListener { finish() }
|
||||
|
||||
adapter = BlockMemberAdapter(
|
||||
@@ -78,7 +79,10 @@ class BlockMemberActivity : BaseActivity<ActivityBlockMemberBinding>(
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun bindData() {
|
||||
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.isLoading.observe(this) {
|
||||
@@ -94,7 +98,12 @@ class BlockMemberActivity : BaseActivity<ActivityBlockMemberBinding>(
|
||||
}
|
||||
|
||||
viewModel.blockedMemberTotalCountLiveData.observe(this) {
|
||||
binding.tvTotalCount.text = " $it "
|
||||
binding.tvTotalCount.text = " ${
|
||||
getString(
|
||||
R.string.screen_block_member_total_count,
|
||||
it
|
||||
)
|
||||
} "
|
||||
|
||||
if (it > 0) {
|
||||
binding.tvNone.visibility = View.GONE
|
||||
|
||||
@@ -26,6 +26,8 @@ class BlockMemberAdapter(
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun bind(item: GetBlockedMemberListItem) {
|
||||
binding.tvNickname.text = item.nickname
|
||||
val blockText = context.getString(R.string.screen_block_member_block)
|
||||
val unBlockText = context.getString(R.string.screen_block_member_unblock)
|
||||
binding.ivProfile.load(item.profileImageUrl) {
|
||||
transformations(CircleCropTransformation())
|
||||
placeholder(R.drawable.bg_placeholder)
|
||||
@@ -34,7 +36,7 @@ class BlockMemberAdapter(
|
||||
|
||||
binding.tvBlock.visibility = View.VISIBLE
|
||||
if (item.isBlocked) {
|
||||
binding.tvBlock.text = "차단해제"
|
||||
binding.tvBlock.text = unBlockText
|
||||
binding.tvBlock.background = ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.bg_round_corner_13_3_333bb9f1_3bb9f1
|
||||
@@ -48,7 +50,7 @@ class BlockMemberAdapter(
|
||||
unBlockMember(item.memberId)
|
||||
}
|
||||
} else {
|
||||
binding.tvBlock.text = "차단"
|
||||
binding.tvBlock.text = blockText
|
||||
binding.tvBlock.background = ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.bg_round_corner_13_3_transparent_3bb9f1
|
||||
|
||||
@@ -6,7 +6,9 @@ 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.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.user.UserRepository
|
||||
|
||||
class BlockMemberViewModel(private val userRepository: UserRepository) : BaseViewModel() {
|
||||
@@ -22,8 +24,8 @@ class BlockMemberViewModel(private val userRepository: UserRepository) : BaseVie
|
||||
val isLoading: LiveData<Boolean>
|
||||
get() = _isLoading
|
||||
|
||||
private val _toastLiveData = MutableLiveData<String?>()
|
||||
val toastLiveData: LiveData<String?>
|
||||
private val _toastLiveData = MutableLiveData<ToastMessage?>()
|
||||
val toastLiveData: LiveData<ToastMessage?>
|
||||
get() = _toastLiveData
|
||||
|
||||
var page = 1
|
||||
@@ -55,21 +57,17 @@ class BlockMemberViewModel(private val userRepository: UserRepository) : BaseVie
|
||||
_blockedMemberListLiveData.value = data.items
|
||||
}
|
||||
} 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)
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
_toastLiveData.postValue(ToastMessage(resId = R.string.common_error_unknown))
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user