콘텐츠 메인 - 인기 콘텐츠 영역 추가
This commit is contained in:
parent
2f17e04e1e
commit
fe1a1cc3cb
|
@ -1,5 +1,6 @@
|
|||
package kr.co.vividnext.sodalive.audio_content.main
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
|
@ -10,6 +11,7 @@ import android.view.inputmethod.InputMethodManager
|
|||
import android.widget.LinearLayout
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.zhpan.bannerview.BaseBannerAdapter
|
||||
|
@ -47,6 +49,7 @@ class AudioContentMainFragment : BaseFragment<FragmentAudioContentMainBinding>(
|
|||
private lateinit var orderListAdapter: AudioContentMainContentAdapter
|
||||
private lateinit var newContentThemeAdapter: AudioContentMainNewContentThemeAdapter
|
||||
private lateinit var newContentAdapter: AudioContentMainContentAdapter
|
||||
private lateinit var contentRankingAdapter: AudioContentMainRankingAdapter
|
||||
private lateinit var curationAdapter: AudioContentMainCurationAdapter
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
@ -83,6 +86,7 @@ class AudioContentMainFragment : BaseFragment<FragmentAudioContentMainBinding>(
|
|||
setupOrderList()
|
||||
setupNewContentTheme()
|
||||
setupNewContent()
|
||||
setupContentRanking()
|
||||
setupCuration()
|
||||
|
||||
binding.swipeRefreshLayout.setOnRefreshListener {
|
||||
|
@ -362,6 +366,42 @@ class AudioContentMainFragment : BaseFragment<FragmentAudioContentMainBinding>(
|
|||
binding.rvNewContent.adapter = newContentAdapter
|
||||
}
|
||||
|
||||
private fun setupContentRanking() {
|
||||
binding.ivContentRankingAll.setOnClickListener {}
|
||||
|
||||
contentRankingAdapter = AudioContentMainRankingAdapter {
|
||||
startActivity(
|
||||
Intent(requireContext(), AudioContentDetailActivity::class.java).apply {
|
||||
putExtra(Constants.EXTRA_AUDIO_CONTENT_ID, it)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
binding.rvContentRanking.layoutManager = GridLayoutManager(
|
||||
context,
|
||||
3,
|
||||
GridLayoutManager.HORIZONTAL,
|
||||
false
|
||||
)
|
||||
|
||||
binding.rvContentRanking.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
outRect.top = 13.3f.dpToPx().toInt()
|
||||
outRect.bottom = 13.3f.dpToPx().toInt()
|
||||
outRect.left = 13.3f.dpToPx().toInt()
|
||||
outRect.right = 13.3f.dpToPx().toInt()
|
||||
}
|
||||
})
|
||||
|
||||
binding.rvContentRanking.adapter = contentRankingAdapter
|
||||
}
|
||||
|
||||
private fun setupCuration() {
|
||||
curationAdapter = AudioContentMainCurationAdapter(
|
||||
onClickItem = {
|
||||
|
@ -425,6 +465,7 @@ class AudioContentMainFragment : BaseFragment<FragmentAudioContentMainBinding>(
|
|||
binding.rvCuration.adapter = curationAdapter
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun bindData() {
|
||||
viewModel.isLoading.observe(viewLifecycleOwner) {
|
||||
if (it) {
|
||||
|
@ -490,5 +531,11 @@ class AudioContentMainFragment : BaseFragment<FragmentAudioContentMainBinding>(
|
|||
View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.contentRankingLiveData.observe(viewLifecycleOwner) {
|
||||
binding.llContentRanking.visibility = View.VISIBLE
|
||||
binding.tvDate.text = "${it.startDate}~${it.endDate}"
|
||||
contentRankingAdapter.addItems(it.items)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package kr.co.vividnext.sodalive.audio_content.main
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.load
|
||||
import coil.transform.RoundedCornersTransformation
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.databinding.ItemAudioContentMainRankingBinding
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
|
||||
class AudioContentMainRankingAdapter(
|
||||
private val onClickItem: (Long) -> Unit
|
||||
) : RecyclerView.Adapter<AudioContentMainRankingAdapter.AudioContentMainRankingItemViewHolder>() {
|
||||
|
||||
inner class AudioContentMainRankingItemViewHolder(
|
||||
private val binding: ItemAudioContentMainRankingBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun bind(item: GetAudioContentRankingItem, index: Int) {
|
||||
binding.root.setOnClickListener { onClickItem(item.contentId) }
|
||||
binding.tvTitle.text = item.title
|
||||
binding.tvRank.text = "${index + 1}"
|
||||
binding.tvNickname.text = item.creatorNickname
|
||||
|
||||
binding.ivCover.load(item.coverImageUrl) {
|
||||
crossfade(true)
|
||||
placeholder(R.drawable.ic_place_holder)
|
||||
transformations(RoundedCornersTransformation(2.7f.dpToPx()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val items = mutableListOf<GetAudioContentRankingItem>()
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun addItems(items: List<GetAudioContentRankingItem>) {
|
||||
this.items.clear()
|
||||
this.items.addAll(items)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
) = AudioContentMainRankingItemViewHolder(
|
||||
ItemAudioContentMainRankingBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
override fun onBindViewHolder(holder: AudioContentMainRankingItemViewHolder, position: Int) {
|
||||
holder.bind(items[position], index = position)
|
||||
}
|
||||
}
|
|
@ -45,6 +45,10 @@ class AudioContentMainViewModel(
|
|||
val curationListLiveData: LiveData<List<GetAudioContentCurationResponse>>
|
||||
get() = _curationListLiveData
|
||||
|
||||
private var _contentRankingLiveData = MutableLiveData<GetAudioContentRanking>()
|
||||
val contentRankingLiveData: LiveData<GetAudioContentRanking>
|
||||
get() = _contentRankingLiveData
|
||||
|
||||
fun getMain() {
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
|
@ -61,6 +65,7 @@ class AudioContentMainViewModel(
|
|||
_orderListLiveData.value = data.orderList
|
||||
_bannerLiveData.value = data.bannerList
|
||||
_curationListLiveData.value = data.curationList
|
||||
_contentRankingLiveData.value = data.contentRanking
|
||||
|
||||
val themeList = listOf("전체").union(data.themeList).toList()
|
||||
_themeListLiveData.value = themeList
|
||||
|
|
|
@ -10,7 +10,8 @@ data class GetAudioContentMainResponse(
|
|||
@SerializedName("orderList") val orderList: List<GetAudioContentMainItem>,
|
||||
@SerializedName("themeList") val themeList: List<String>,
|
||||
@SerializedName("newContentList") val newContentList: List<GetAudioContentMainItem>,
|
||||
@SerializedName("curationList") val curationList: List<GetAudioContentCurationResponse>
|
||||
@SerializedName("curationList") val curationList: List<GetAudioContentCurationResponse>,
|
||||
@SerializedName("contentRanking") val contentRanking: GetAudioContentRanking
|
||||
)
|
||||
|
||||
data class GetNewContentUploadCreator(
|
||||
|
@ -29,6 +30,23 @@ data class GetAudioContentMainItem(
|
|||
@SerializedName("creatorNickname") val creatorNickname: String
|
||||
)
|
||||
|
||||
data class GetAudioContentRanking(
|
||||
@SerializedName("startDate") val startDate: String,
|
||||
@SerializedName("endDate") val endDate: String,
|
||||
@SerializedName("items") val items: List<GetAudioContentRankingItem>
|
||||
)
|
||||
|
||||
data class GetAudioContentRankingItem(
|
||||
@SerializedName("contentId") val contentId: Long,
|
||||
@SerializedName("title") val title: String,
|
||||
@SerializedName("coverImageUrl") val coverImageUrl: String,
|
||||
@SerializedName("themeStr") val themeStr: String,
|
||||
@SerializedName("price") val price: Int,
|
||||
@SerializedName("duration") val duration: String,
|
||||
@SerializedName("creatorId") val creatorId: Long,
|
||||
@SerializedName("creatorNickname") val creatorNickname: String
|
||||
)
|
||||
|
||||
data class GetAudioContentCurationResponse(
|
||||
@SerializedName("curationId") val curationId: Long,
|
||||
@SerializedName("title") val title: String,
|
||||
|
|
|
@ -158,6 +158,73 @@
|
|||
android:paddingHorizontal="13.3dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_content_ranking"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40dp"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="13.3dp"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:text="인기 콘텐츠"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="18.3sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_content_ranking_all"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:contentDescription="@null"
|
||||
android:paddingHorizontal="13.3dp"
|
||||
android:src="@drawable/ic_forward" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="13.3dp"
|
||||
android:background="@color/color_222222"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="14.7sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:fontFamily="@font/gmarket_sans_light"
|
||||
android:text="※ 인기 콘텐츠의 순위는 매주 업데이트됩니다."
|
||||
android:textColor="@color/color_bbbbbb"
|
||||
android:textSize="13.3sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_content_ranking"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="13.3dp"
|
||||
android:clipToPadding="false"
|
||||
android:paddingHorizontal="6.7dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_curation"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_cover"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:contentDescription="@null" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_rank"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="12dp"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:textColor="@color/color_3bb9f1"
|
||||
android:textSize="16.7sp"
|
||||
tools:text="1" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:textColor="@color/color_d2d2d2"
|
||||
android:textSize="13.3sp"
|
||||
tools:text="라일락 꽃 향기 맡으며" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_nickname"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:textColor="@color/color_777777"
|
||||
android:textSize="11sp"
|
||||
tools:text="J Fla" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue