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

- 전체 개수 추가
This commit is contained in:
klaus 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("page") page: Int,
@Query("size") size: Int, @Query("size") size: Int,
@Header("Authorization") authHeader: String @Header("Authorization") authHeader: String
): Single<ApiResponse<List<GetAudioContentMainItem>>> ): Single<ApiResponse<GetNewContentAllResponse>>
@GET("/v2/audio-content/main/asmr") @GET("/v2/audio-content/main/asmr")
fun getContentMainAsmr( fun getContentMainAsmr(

View File

@ -84,43 +84,43 @@ class AudioContentMainTabAlarmViewModel(
} }
fun getContentMainAlarm(selectedTheme: String) { fun getContentMainAlarm(selectedTheme: String) {
_isLoading.value = true _isLoading.value = true
compositeDisposable.add( compositeDisposable.add(
repository.getContentMainAlarmAll( repository.getContentMainAlarmAll(
theme = if (selectedTheme == "전체") { theme = if (selectedTheme == "전체") {
"" ""
} else { } else {
selectedTheme selectedTheme
}, },
page = 1, page = 1,
size = 10, size = 10,
token = "Bearer ${SharedPreferenceManager.token}" 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("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
}
)
) )
} .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) { viewModel.newContentListLiveData.observe(this) {
newContentAdapter.addItems(it) newContentAdapter.addItems(it)
} }
viewModel.totalCountLiveData.observe(this) {
binding.tvTotalCount.text = "$it"
}
} }
} }

View File

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

View File

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

View File

@ -28,6 +28,46 @@
android:clipToPadding="false" android:clipToPadding="false"
android:paddingHorizontal="13.3dp" /> android:paddingHorizontal="13.3dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="13.3dp"
android:orientation="horizontal"
android:paddingHorizontal="20dp"
android:paddingVertical="6.7dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/gmarket_sans_medium"
android:gravity="center"
android:text="전체"
android:textColor="@color/color_e2e2e2"
android:textSize="13.3sp" />
<TextView
android:id="@+id/tv_total_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:fontFamily="@font/gmarket_sans_medium"
android:gravity="center"
android:text="0"
android:textColor="@color/color_ff5c49"
android:textSize="13.3sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:fontFamily="@font/gmarket_sans_medium"
android:gravity="center"
android:text="개"
android:textColor="@color/color_e2e2e2"
android:textSize="13.3sp" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_content" android:id="@+id/rv_content"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -10,6 +10,7 @@
layout="@layout/detail_toolbar" /> layout="@layout/detail_toolbar" />
<TextView <TextView
android:id="@+id/tv_notice"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="13.3dp" android:layout_marginTop="13.3dp"
@ -20,6 +21,46 @@
android:text="※ 최근 2주간 등록된 새로운 ASMR 입니다." android:text="※ 최근 2주간 등록된 새로운 ASMR 입니다."
android:textSize="14.67sp" /> android:textSize="14.67sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="13.3dp"
android:orientation="horizontal"
android:paddingHorizontal="20dp"
android:paddingVertical="6.7dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/gmarket_sans_medium"
android:gravity="center"
android:text="전체"
android:textColor="@color/color_e2e2e2"
android:textSize="13.3sp" />
<TextView
android:id="@+id/tv_total_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:fontFamily="@font/gmarket_sans_medium"
android:gravity="center"
android:text="0"
android:textColor="@color/color_ff5c49"
android:textSize="13.3sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:fontFamily="@font/gmarket_sans_medium"
android:gravity="center"
android:text="개"
android:textColor="@color/color_e2e2e2"
android:textSize="13.3sp" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_content" android:id="@+id/rv_content"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -35,7 +35,7 @@
android:layout_marginTop="13.3dp" android:layout_marginTop="13.3dp"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingHorizontal="20dp" android:paddingHorizontal="20dp"
android:paddingVertical="13.3dp"> android:paddingVertical="6.7dp">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">