시리즈 상세 문자열 리소스화
This commit is contained in:
@@ -38,7 +38,11 @@ class SeriesDetailActivity : BaseActivity<ActivitySeriesDetailBinding>(
|
||||
|
||||
val seriesId = intent.getLongExtra(Constants.EXTRA_SERIES_ID, 0)
|
||||
if (seriesId <= 0) {
|
||||
Toast.makeText(applicationContext, "잘못된 요청입니다.", Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
getString(R.string.screen_audio_content_error_invalid_request),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
finish()
|
||||
}
|
||||
|
||||
@@ -57,8 +61,14 @@ class SeriesDetailActivity : BaseActivity<ActivitySeriesDetailBinding>(
|
||||
|
||||
private fun setupTab() {
|
||||
val tabs = binding.tabs
|
||||
tabs.addTab(tabs.newTab().setText("홈").setTag("home"))
|
||||
tabs.addTab(tabs.newTab().setText("작품소개").setTag("introduction"))
|
||||
tabs.addTab(
|
||||
tabs.newTab().setText(R.string.screen_series_detail_tab_home).setTag("home")
|
||||
)
|
||||
tabs.addTab(
|
||||
tabs.newTab()
|
||||
.setText(R.string.screen_series_detail_tab_introduction)
|
||||
.setTag("introduction")
|
||||
)
|
||||
|
||||
tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
|
||||
override fun onTabSelected(tab: TabLayout.Tab) {
|
||||
@@ -152,7 +162,15 @@ class SeriesDetailActivity : BaseActivity<ActivitySeriesDetailBinding>(
|
||||
|
||||
binding.tvTitle.text = seriesDetail.title
|
||||
binding.tvGenre.text = seriesDetail.genre
|
||||
binding.tvPublishedDaysOfWeek.text = "${seriesDetail.publishedDaysOfWeek} 연재"
|
||||
val publishedDays = if (seriesDetail.publishedDaysOfWeek == getString(R.string.day_random)) {
|
||||
getString(R.string.day_random)
|
||||
} else {
|
||||
seriesDetail.publishedDaysOfWeek
|
||||
}
|
||||
binding.tvPublishedDaysOfWeek.text = getString(
|
||||
R.string.screen_series_detail_published_days_format,
|
||||
publishedDays
|
||||
)
|
||||
|
||||
if (seriesDetail.isAdult) {
|
||||
binding.tvAge19.visibility = View.VISIBLE
|
||||
|
||||
@@ -5,8 +5,11 @@ import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.audio_content.detail.AudioContentDetailActivity
|
||||
import kr.co.vividnext.sodalive.audio_content.series.content.SeriesContentAdapter
|
||||
import kr.co.vividnext.sodalive.audio_content.series.content.SeriesContentAllActivity
|
||||
@@ -44,9 +47,12 @@ class SeriesDetailHomeFragment : BaseFragment<FragmentSeriesDetailHomeBinding>(
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@OptIn(UnstableApi::class)
|
||||
private fun setContent() {
|
||||
binding.tvTotalCount.text = "(${seriesDetailResponse!!.contentCount})"
|
||||
binding.tvTotalCount.text = getString(
|
||||
R.string.screen_series_detail_content_count_format,
|
||||
seriesDetailResponse!!.contentCount
|
||||
)
|
||||
binding.llContentAll.setOnClickListener {
|
||||
startActivity(
|
||||
Intent(requireActivity(), SeriesContentAllActivity::class.java).apply {
|
||||
|
||||
@@ -53,22 +53,36 @@ class SeriesDetailIntroductionFragment : BaseFragment<FragmentSeriesDetailIntrod
|
||||
|
||||
binding.tvRentalPrice.text = if (rentalMinPrice == rentalMaxPrice) {
|
||||
if (rentalMaxPrice == 0) {
|
||||
"무료(5일)"
|
||||
getString(R.string.screen_series_detail_price_rental_free)
|
||||
} else {
|
||||
"$rentalMaxPrice(5일)"
|
||||
getString(R.string.screen_series_detail_price_rental_single, rentalMaxPrice)
|
||||
}
|
||||
} else {
|
||||
"${if (rentalMinPrice == 0) "무료" else rentalMinPrice} ~ ${rentalMaxPrice}캔 (5일)"
|
||||
val minText = if (rentalMinPrice == 0) {
|
||||
getString(R.string.audio_content_price_free)
|
||||
} else {
|
||||
rentalMinPrice.toString()
|
||||
}
|
||||
getString(
|
||||
R.string.screen_series_detail_price_rental_range,
|
||||
minText,
|
||||
rentalMaxPrice
|
||||
)
|
||||
}
|
||||
|
||||
binding.tvPrice.text = if (minPrice == maxPrice) {
|
||||
if (maxPrice == 0) {
|
||||
"무료"
|
||||
getString(R.string.audio_content_price_free)
|
||||
} else {
|
||||
"$maxPrice"
|
||||
getString(R.string.screen_series_detail_price_keep_single, maxPrice)
|
||||
}
|
||||
} else {
|
||||
"${if (minPrice == 0) "무료" else minPrice} ~ ${maxPrice}캔"
|
||||
val minText = if (minPrice == 0) {
|
||||
getString(R.string.audio_content_price_free)
|
||||
} else {
|
||||
minPrice.toString()
|
||||
}
|
||||
getString(R.string.screen_series_detail_price_keep_range, minText, maxPrice)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,18 +90,21 @@ class SeriesDetailIntroductionFragment : BaseFragment<FragmentSeriesDetailIntrod
|
||||
private fun setSeriesInfo() {
|
||||
binding.tvGenre.text = seriesDetailResponse!!.genre
|
||||
binding.tvIsAdult.text = if (seriesDetailResponse!!.isAdult) {
|
||||
"19세 이상"
|
||||
getString(R.string.screen_series_detail_age_19)
|
||||
} else {
|
||||
"전체연령가"
|
||||
getString(R.string.screen_series_detail_age_all)
|
||||
}
|
||||
|
||||
binding.tvPublishedDate.text = seriesDetailResponse!!.publishedDate
|
||||
binding.tvPublishedDaysOfWeek.text =
|
||||
if (seriesDetailResponse!!.publishedDaysOfWeek == "랜덤") {
|
||||
seriesDetailResponse!!.publishedDaysOfWeek
|
||||
} else {
|
||||
seriesDetailResponse!!.publishedDaysOfWeek
|
||||
}
|
||||
val publishedDays = if (seriesDetailResponse!!.publishedDaysOfWeek == getString(R.string.day_random)) {
|
||||
getString(R.string.day_random)
|
||||
} else {
|
||||
seriesDetailResponse!!.publishedDaysOfWeek
|
||||
}
|
||||
binding.tvPublishedDaysOfWeek.text = getString(
|
||||
R.string.screen_series_detail_published_days_format,
|
||||
publishedDays
|
||||
)
|
||||
|
||||
if (seriesDetailResponse!!.writer != null) {
|
||||
binding.tvWriter.visibility = View.VISIBLE
|
||||
|
||||
@@ -5,10 +5,12 @@ import androidx.lifecycle.MutableLiveData
|
||||
import com.orhanobut.logger.Logger
|
||||
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.series.SeriesRepository
|
||||
import kr.co.vividnext.sodalive.base.BaseViewModel
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.user.UserRepository
|
||||
import kr.co.vividnext.sodalive.common.SodaLiveApplicationHolder
|
||||
|
||||
class SeriesDetailViewModel(
|
||||
private val repository: SeriesRepository,
|
||||
@@ -29,6 +31,8 @@ class SeriesDetailViewModel(
|
||||
var seriesId = 0L
|
||||
|
||||
lateinit var seriesDetailResponse: GetSeriesDetailResponse
|
||||
private val unknownErrorMessage: String
|
||||
get() = SodaLiveApplicationHolder.get().getString(R.string.common_error_unknown)
|
||||
|
||||
fun getSeriesDetail() {
|
||||
_isLoading.value = true
|
||||
@@ -46,18 +50,14 @@ class SeriesDetailViewModel(
|
||||
seriesDetailResponse = it.data
|
||||
_seriesDetailLiveData.value = seriesDetailResponse
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.value = it.message
|
||||
} else {
|
||||
_toastLiveData.value = "알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
}
|
||||
_toastLiveData.value = it.message ?: unknownErrorMessage
|
||||
}
|
||||
_isLoading.value = false
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
_toastLiveData.postValue(unknownErrorMessage)
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -84,20 +84,14 @@ class SeriesDetailViewModel(
|
||||
if (it.success && it.data != null) {
|
||||
onSuccess()
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
_toastLiveData.postValue(it.message ?: unknownErrorMessage)
|
||||
}
|
||||
_isLoading.value = false
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
_toastLiveData.postValue(unknownErrorMessage)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user