콘텐츠 메인 탭 - 새로운 콘텐츠 전체보기

- 전체 개수 추가
This commit is contained in:
2025-02-17 21:39:04 +09:00
parent 0e70ed2661
commit e46c34558e
10 changed files with 144 additions and 42 deletions

View File

@@ -325,7 +325,7 @@ interface AudioContentApi {
@Query("page") page: Int,
@Query("size") size: Int,
@Header("Authorization") authHeader: String
): Single<ApiResponse<List<GetAudioContentMainItem>>>
): Single<ApiResponse<GetNewContentAllResponse>>
@GET("/v2/audio-content/main/asmr")
fun getContentMainAsmr(

View File

@@ -84,43 +84,43 @@ class AudioContentMainTabAlarmViewModel(
}
fun getContentMainAlarm(selectedTheme: String) {
_isLoading.value = true
_isLoading.value = true
compositeDisposable.add(
repository.getContentMainAlarmAll(
theme = if (selectedTheme == "전체") {
""
} else {
selectedTheme
},
page = 1,
size = 10,
token = "Bearer ${SharedPreferenceManager.token}"
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
if (it.success && it.data != null) {
_newContentListLiveData.value = it.data!!
} else {
if (it.message != null) {
_toastLiveData.postValue(it.message)
} else {
_toastLiveData.postValue(
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
)
}
}
_isLoading.value = false
},
{
_isLoading.value = false
it.message?.let { message -> Logger.e(message) }
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
}
)
compositeDisposable.add(
repository.getContentMainAlarmAll(
theme = if (selectedTheme == "전체") {
""
} else {
selectedTheme
},
page = 1,
size = 10,
token = "Bearer ${SharedPreferenceManager.token}"
)
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
if (it.success && it.data != null) {
_newContentListLiveData.value = it.data.items
} else {
if (it.message != null) {
_toastLiveData.postValue(it.message)
} else {
_toastLiveData.postValue(
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
)
}
}
_isLoading.value = false
},
{
_isLoading.value = false
it.message?.let { message -> Logger.e(message) }
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
}
)
)
}
}

View File

@@ -154,5 +154,9 @@ class AlarmContentAllActivity : BaseActivity<ActivityAlarmContentAllBinding>(
viewModel.newContentListLiveData.observe(this) {
newContentAdapter.addItems(it)
}
viewModel.totalCountLiveData.observe(this) {
binding.tvTotalCount.text = "$it"
}
}
}

View File

@@ -25,6 +25,10 @@ class AlarmContentAllViewModel(
val newContentListLiveData: LiveData<List<GetAudioContentMainItem>>
get() = _newContentListLiveData
private var _totalCountLiveData = MutableLiveData<Int>()
val totalCountLiveData: LiveData<Int>
get() = _totalCountLiveData
private var isLast = false
private var page = 1
private val size = 10
@@ -50,9 +54,11 @@ class AlarmContentAllViewModel(
.subscribe(
{
if (it.success && it.data != null) {
if (it.data.isNotEmpty()) {
val data = it.data
_totalCountLiveData.value = data.totalCount
if (data.items.isNotEmpty()) {
page += 1
_newContentListLiveData.value = it.data!!
_newContentListLiveData.value = data.items
} else {
isLast = true
}

View File

@@ -43,6 +43,8 @@ class AsmrNewContentAllActivity : BaseActivity<ActivityAsmrNewContentAllBinding>
binding.toolbar.tvBack.text = "새로운 ASMR"
binding.toolbar.tvBack.setOnClickListener { finish() }
binding.tvNotice.text = "※ 최근 2주간 등록된 새로운 ASMR 입니다."
setupNewContent()
}
@@ -106,5 +108,9 @@ class AsmrNewContentAllActivity : BaseActivity<ActivityAsmrNewContentAllBinding>
viewModel.newContentListLiveData.observe(this) {
newContentAdapter.addItems(it)
}
viewModel.newContentTotalCountLiveData.observe(this) {
binding.tvTotalCount.text = "$it"
}
}
}

View File

@@ -41,6 +41,8 @@ class ReplayNewContentAllActivity : BaseActivity<ActivityAsmrNewContentAllBindin
binding.toolbar.tvBack.text = "새로운 라이브 다시듣기"
binding.toolbar.tvBack.setOnClickListener { finish() }
binding.tvNotice.text = "※ 최근 2주간 등록된 새로운 라이브 다시보기 입니다."
setupNewContent()
}
@@ -104,5 +106,9 @@ class ReplayNewContentAllActivity : BaseActivity<ActivityAsmrNewContentAllBindin
viewModel.newContentListLiveData.observe(this) {
newContentAdapter.addItems(it)
}
viewModel.newContentTotalCountLiveData.observe(this) {
binding.tvTotalCount.text = "$it"
}
}
}