콘텐츠 메인 - 시리즈 탭
- 장르별 추천 시리즈 장르 터치 액션 추가
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user