콘텐츠 메인 - 시리즈 탭

- 장르별 추천 시리즈 장르 터치 액션 추가
This commit is contained in:
klaus 2025-02-14 13:58:12 +09:00
parent e1028ada43
commit 2ff2c2224a
5 changed files with 83 additions and 1 deletions

View File

@ -270,6 +270,12 @@ interface AudioContentApi {
@Header("Authorization") authHeader: String
): Single<ApiResponse<GetSeriesListResponse>>
@GET("/v2/audio-content/main/series/recommend-by-genre")
fun getRecommendSeriesListByGenre(
@Query("genreId") genreId: Long,
@Header("Authorization") authHeader: String
): Single<ApiResponse<List<GetSeriesListResponse.SeriesListItem>>>
@GET("/v2/audio-content/main/content")
fun getContentMainContent(
@Header("Authorization") authHeader: String

View File

@ -272,6 +272,9 @@ class AudioContentMainTabSeriesFragment : BaseFragment<FragmentAudioContentMainT
private fun setupRecommendSeriesGenre() {
seriesGenreAdapter = AudioContentMainRecommendSeriesGenreAdapter {
binding.llNoItemsSeriesByGenre.visibility = View.VISIBLE
binding.rvSeriesByGenre.visibility = View.GONE
viewModel.selectGenre(it)
}
val recyclerView = binding.rvSeriesGenre
@ -378,7 +381,12 @@ class AudioContentMainTabSeriesFragment : BaseFragment<FragmentAudioContentMainT
recyclerView.adapter = recommendSeriesByGenreAdapter
viewModel.recommendSeriesListLiveData.observe(viewLifecycleOwner) {
recommendSeriesByGenreAdapter.addItems(it)
if (it.isNotEmpty()) {
binding.llNoItemsSeriesByGenre.visibility = View.GONE
binding.rvSeriesByGenre.visibility = View.VISIBLE
recommendSeriesByGenreAdapter.clear()
recommendSeriesByGenreAdapter.addItems(it)
}
}
}

View File

@ -4,4 +4,8 @@ import kr.co.vividnext.sodalive.audio_content.AudioContentApi
class AudioContentMainTabSeriesRepository(private val api: AudioContentApi) {
fun getContentMainSeries(token: String) = api.getContentMainSeries(authHeader = token)
fun getRecommendSeriesListByGenre(
genreId: Long,
token: String
) = api.getRecommendSeriesListByGenre(genreId, authHeader = token)
}

View File

@ -115,4 +115,38 @@ class AudioContentMainTabSeriesViewModel(
)
)
}
fun selectGenre(genreId: Long) {
_isLoading.value = true
compositeDisposable.add(
repository.getRecommendSeriesListByGenre(
genreId,
token = "Bearer ${SharedPreferenceManager.token}"
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
if (it.success && it.data != null) {
_recommendSeriesListLiveData.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("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
}
)
)
}
}

View File

@ -123,6 +123,36 @@
android:layout_marginTop="13.3dp"
android:clipToPadding="false"
android:paddingHorizontal="13.3dp" />
<LinearLayout
android:id="@+id/ll_no_items_series_by_genre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="13.3dp"
android:layout_marginTop="28.3dp"
android:background="@drawable/bg_round_corner_4_7_13181b"
android:gravity="center"
android:orientation="vertical"
android:paddingVertical="16.7dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:src="@drawable/ic_no_item" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp"
android:fontFamily="@font/gmarket_sans_medium"
android:gravity="center"
android:lineSpacingExtra="8dp"
android:text="마이페이지에서 본인인증을 해주세요"
android:textColor="@color/color_bbbbbb"
android:textSize="13sp"
tools:ignore="SmallSp" />
</LinearLayout>
</LinearLayout>
<LinearLayout