feat: 메인 홈
- 무료 콘텐츠 UI 추가
This commit is contained in:
@@ -72,6 +72,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(FragmentHomeBinding::infl
|
||||
private lateinit var auditionAdapter: AuditionBannerAdapter
|
||||
private lateinit var seriesDayOfWeekAdapter: HomeSeriesAdapter
|
||||
private lateinit var weelyChartAdapter: HomeWeeklyChartAdapter
|
||||
private lateinit var homeFreeContentAdapter: HomeContentAdapter
|
||||
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
|
||||
@@ -165,6 +166,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(FragmentHomeBinding::infl
|
||||
setupAudition()
|
||||
setupSeriesDayOfWeek()
|
||||
setupWeelyChart()
|
||||
setupFreeContent()
|
||||
}
|
||||
|
||||
private fun setupLiveView() {
|
||||
@@ -856,6 +858,65 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(FragmentHomeBinding::infl
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupFreeContent() {
|
||||
val spSectionTitle = SpannableString(binding.tvFreeContent.text)
|
||||
spSectionTitle.setSpan(
|
||||
ForegroundColorSpan(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
R.color.color_3bb9f1
|
||||
)
|
||||
),
|
||||
0,
|
||||
2,
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
binding.tvFreeContent.text = spSectionTitle
|
||||
|
||||
homeFreeContentAdapter = HomeContentAdapter {
|
||||
startActivity(
|
||||
Intent(requireContext(), AudioContentDetailActivity::class.java).apply {
|
||||
putExtra(Constants.EXTRA_AUDIO_CONTENT_ID, it)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
val rvContent = binding.rvFreeContent
|
||||
rvContent.layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
|
||||
rvContent.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
outRect.top = 8f.dpToPx().toInt()
|
||||
outRect.bottom = 8f.dpToPx().toInt()
|
||||
|
||||
val position = parent.getChildAdapterPosition(view)
|
||||
|
||||
if (position == 0 || position == 1) {
|
||||
outRect.left = 0f.dpToPx().toInt()
|
||||
} else {
|
||||
outRect.left = 8f.dpToPx().toInt()
|
||||
}
|
||||
|
||||
outRect.right = 8f.dpToPx().toInt()
|
||||
}
|
||||
})
|
||||
rvContent.adapter = homeFreeContentAdapter
|
||||
|
||||
viewModel.freeContentListLiveData.observe(viewLifecycleOwner) {
|
||||
if (it.isNotEmpty()) {
|
||||
binding.llFreeContent.visibility = View.VISIBLE
|
||||
homeFreeContentAdapter.addItems(it)
|
||||
} else {
|
||||
binding.llFreeContent.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindData() {
|
||||
viewModel.isLoading.observe(viewLifecycleOwner) {
|
||||
if (it) {
|
||||
|
||||
@@ -100,6 +100,9 @@ class HomeViewModel(private val repository: HomeRepository) : BaseViewModel() {
|
||||
_auditionListLiveData.value = data.auditionList
|
||||
_dayOfWeekSeriesListLiveData.value = data.dayOfWeekSeriesList
|
||||
_contentRankingLiveData.value = data.contentRanking
|
||||
_freeContentListLiveData.value = data.freeContentList
|
||||
_curationListLiveData.value = data.curationList
|
||||
_recommendChannelListLiveData.value = data.recommendChannelList
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
|
||||
Reference in New Issue
Block a user