재생목록 생성 화면 문자열 리소스화
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package kr.co.vividnext.sodalive.audio_content.playlist.create
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Service
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
@@ -11,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.jakewharton.rxbinding4.widget.textChanges
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.create.add_content.PlaylistAddContentDialogFragment
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.detail.AudioContentPlaylistContent
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
@@ -70,7 +70,8 @@ class AudioContentPlaylistCreateActivity : BaseActivity<ActivityAudioContentPlay
|
||||
}
|
||||
|
||||
override fun setupView() {
|
||||
binding.tvBack.text = "새 재생목록 만들기"
|
||||
binding.tvBack.text = getString(R.string.audio_content_playlist_create_title)
|
||||
binding.tvSave.text = getString(R.string.audio_content_playlist_create_save)
|
||||
binding.tvBack.setOnClickListener { finish() }
|
||||
|
||||
loadingDialog = LoadingDialog(this, layoutInflater)
|
||||
@@ -153,8 +154,8 @@ class AudioContentPlaylistCreateActivity : BaseActivity<ActivityAudioContentPlay
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
if (it.length > 30) {
|
||||
val truncated = it.take(30)
|
||||
if (it.length > PLAYLIST_TITLE_MAX_LENGTH) {
|
||||
val truncated = it.take(PLAYLIST_TITLE_MAX_LENGTH)
|
||||
binding.etTitle.setText(truncated)
|
||||
binding.etTitle.setSelection(truncated.length)
|
||||
setTitle(truncated)
|
||||
@@ -171,8 +172,8 @@ class AudioContentPlaylistCreateActivity : BaseActivity<ActivityAudioContentPlay
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
if (it.length > 40) {
|
||||
val truncated = it.take(40)
|
||||
if (it.length > PLAYLIST_DESC_MAX_LENGTH) {
|
||||
val truncated = it.take(PLAYLIST_DESC_MAX_LENGTH)
|
||||
binding.etDesc.setText(truncated)
|
||||
binding.etDesc.setSelection(truncated.length)
|
||||
setDesc(truncated)
|
||||
@@ -183,15 +184,26 @@ class AudioContentPlaylistCreateActivity : BaseActivity<ActivityAudioContentPlay
|
||||
)
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun setTitle(title: String) {
|
||||
binding.tvTitleLength.text = "${title.length}/30"
|
||||
binding.tvTitleLength.text = getString(
|
||||
R.string.audio_content_playlist_create_length_format,
|
||||
title.length,
|
||||
PLAYLIST_TITLE_MAX_LENGTH
|
||||
)
|
||||
viewModel.title = title
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun setDesc(desc: String) {
|
||||
binding.tvDescLength.text = "${desc.length}/40"
|
||||
binding.tvDescLength.text = getString(
|
||||
R.string.audio_content_playlist_create_length_format,
|
||||
desc.length,
|
||||
PLAYLIST_DESC_MAX_LENGTH
|
||||
)
|
||||
viewModel.desc = desc
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val PLAYLIST_TITLE_MAX_LENGTH = 30
|
||||
private const val PLAYLIST_DESC_MAX_LENGTH = 40
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,12 @@ import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.AudioContentPlaylistRepository
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.detail.AudioContentPlaylistContent
|
||||
import kr.co.vividnext.sodalive.base.BaseViewModel
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.common.SodaLiveApplicationHolder
|
||||
|
||||
class AudioContentPlaylistCreateViewModel(
|
||||
private val repository: AudioContentPlaylistRepository
|
||||
@@ -41,6 +43,8 @@ class AudioContentPlaylistCreateViewModel(
|
||||
|
||||
fun savePlaylist(onSuccess: () -> Unit) {
|
||||
if (validate()) {
|
||||
val unknownError =
|
||||
SodaLiveApplicationHolder.get().getString(R.string.common_error_unknown)
|
||||
_isLoading.value = true
|
||||
val contentIdAndOrderList = contentList.mapIndexed { index, item ->
|
||||
PlaylistContentIdAndOrder(item.id, index + 1)
|
||||
@@ -66,7 +70,7 @@ class AudioContentPlaylistCreateViewModel(
|
||||
if (it.message != null) {
|
||||
_toastLiveData.value = it.message
|
||||
} else {
|
||||
_toastLiveData.value = "알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
_toastLiveData.value = unknownError
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -75,7 +79,7 @@ class AudioContentPlaylistCreateViewModel(
|
||||
if (it.message != null) {
|
||||
_toastLiveData.value = it.message
|
||||
} else {
|
||||
_toastLiveData.value = "알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
_toastLiveData.value = unknownError
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -84,16 +88,27 @@ class AudioContentPlaylistCreateViewModel(
|
||||
}
|
||||
|
||||
private fun validate(): Boolean {
|
||||
if (title.isBlank() || title.length < 3) {
|
||||
_toastLiveData.value = "제목을 3자 이상 입력하세요"
|
||||
if (title.isBlank() || title.length < MIN_TITLE_LENGTH) {
|
||||
_toastLiveData.value = SodaLiveApplicationHolder.get().getString(
|
||||
R.string.audio_content_playlist_create_title_min_length_error,
|
||||
MIN_TITLE_LENGTH
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
if (contentList.isEmpty()) {
|
||||
_toastLiveData.value = "콘텐츠를 1개 이상 추가하세요"
|
||||
_toastLiveData.value = SodaLiveApplicationHolder.get().getString(
|
||||
R.string.audio_content_playlist_create_content_min_count_error,
|
||||
MIN_CONTENT_COUNT
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val MIN_TITLE_LENGTH = 3
|
||||
private const val MIN_CONTENT_COUNT = 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.audio_content.order.AudioContentOrderListViewModel
|
||||
import kr.co.vividnext.sodalive.audio_content.order.GetAudioContentOrderListItem
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.detail.AudioContentPlaylistContent
|
||||
@@ -148,7 +149,7 @@ class PlaylistAddContentDialogFragment(
|
||||
recyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n", "NotifyDataSetChanged")
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun bindData() {
|
||||
viewModel.toastLiveData.observe(viewLifecycleOwner) {
|
||||
Toast.makeText(requireActivity(), it, Toast.LENGTH_LONG).show()
|
||||
@@ -175,7 +176,10 @@ class PlaylistAddContentDialogFragment(
|
||||
}
|
||||
|
||||
viewModel.totalCount.observe(viewLifecycleOwner) {
|
||||
binding.tvContentCount.text = "${it}개"
|
||||
binding.tvContentCount.text = getString(
|
||||
R.string.audio_content_playlist_total_count,
|
||||
it
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user