feat(content): 추천 댓글 오디오 어댑터를 추가한다
This commit is contained in:
@@ -0,0 +1,61 @@
|
|||||||
|
package kr.co.vividnext.sodalive.v2.main.content.ui
|
||||||
|
|
||||||
|
import android.graphics.Outline
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.ViewOutlineProvider
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import kr.co.vividnext.sodalive.R
|
||||||
|
import kr.co.vividnext.sodalive.databinding.ItemContentCommentedAudioBinding
|
||||||
|
import kr.co.vividnext.sodalive.extensions.loadUrl
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.content.model.ContentCommentedAudioUiModel
|
||||||
|
|
||||||
|
class ContentCommentedAudioAdapter(
|
||||||
|
private val onAudioClick: (ContentCommentedAudioUiModel) -> Unit = {}
|
||||||
|
) : RecyclerView.Adapter<ContentCommentedAudioAdapter.ViewHolder>() {
|
||||||
|
|
||||||
|
private var items: List<ContentCommentedAudioUiModel> = emptyList()
|
||||||
|
|
||||||
|
fun submitItems(items: List<ContentCommentedAudioUiModel>) {
|
||||||
|
this.items = items
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
return ViewHolder(
|
||||||
|
ItemContentCommentedAudioBinding.inflate(LayoutInflater.from(parent.context), parent, false),
|
||||||
|
onAudioClick
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
holder.bind(items[position])
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount(): Int = items.size
|
||||||
|
|
||||||
|
class ViewHolder(
|
||||||
|
private val binding: ItemContentCommentedAudioBinding,
|
||||||
|
private val onAudioClick: (ContentCommentedAudioUiModel) -> Unit
|
||||||
|
) : RecyclerView.ViewHolder(binding.root) {
|
||||||
|
init {
|
||||||
|
binding.layoutContentCommentedThumbnail.clipToOutline = true
|
||||||
|
binding.layoutContentCommentedThumbnail.outlineProvider = object : ViewOutlineProvider() {
|
||||||
|
override fun getOutline(view: View, outline: Outline) {
|
||||||
|
outline.setRoundRect(0, 0, view.width, view.height, view.resources.getDimension(R.dimen.radius_14))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bind(item: ContentCommentedAudioUiModel) = with(binding) {
|
||||||
|
ivContentCommentedThumbnail.loadUrl(item.imageUrl)
|
||||||
|
tvContentCommentedTitle.text = item.title
|
||||||
|
tvContentCommentText.text = item.latestComment
|
||||||
|
layoutContentCommentArea.isVisible = item.showLatestComment
|
||||||
|
ivContentCommentProfile.loadUrl(item.latestCommentWriterProfileImageUrl)
|
||||||
|
root.setOnClickListener { onAudioClick(item) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
73
app/src/main/res/layout/item_content_commented_audio.xml
Normal file
73
app/src/main/res/layout/item_content_commented_audio.xml
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?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="310dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="88dp"
|
||||||
|
android:baselineAligned="false"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/layout_content_commented_thumbnail"
|
||||||
|
android:layout_width="88dp"
|
||||||
|
android:layout_height="88dp"
|
||||||
|
android:background="@drawable/bg_audio_content_card_thumbnail">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_content_commented_thumbnail"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:contentDescription="@null"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
tools:src="@drawable/ic_launcher_background" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_content_commented_title"
|
||||||
|
style="@style/Typography.Body1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/spacing_14"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
tools:text="댓글 많은 오디오 제목" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layout_content_comment_area"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/spacing_12"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_content_comment_profile"
|
||||||
|
android:layout_width="28dp"
|
||||||
|
android:layout_height="28dp"
|
||||||
|
android:contentDescription="@null"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
tools:src="@drawable/ic_launcher_background" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_content_comment_text"
|
||||||
|
style="@style/Typography.Body5"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/spacing_8"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textColor="@color/gray_500"
|
||||||
|
tools:text="최근 댓글 내용" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user