feat(home): 팔로잉 라이브 카드를 추가한다
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package kr.co.vividnext.sodalive.v2.main.home.ui
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.common.formatUtcRelativeTimeText
|
||||
import kr.co.vividnext.sodalive.extensions.loadUrl
|
||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeFollowingLiveUiItem
|
||||
|
||||
class HomeFollowingLiveAdapter(
|
||||
private val onClickItem: (HomeFollowingLiveUiItem) -> Unit = {}
|
||||
) : RecyclerView.Adapter<HomeFollowingLiveAdapter.LiveViewHolder>() {
|
||||
private var items: List<HomeFollowingLiveUiItem> = emptyList()
|
||||
|
||||
fun submitItems(items: List<HomeFollowingLiveUiItem>) {
|
||||
this.items = items
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LiveViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_home_following_live, parent, false)
|
||||
view.layoutParams = recyclerItemLayoutParams(parent)
|
||||
return LiveViewHolder(view, onClickItem)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: LiveViewHolder, position: Int) {
|
||||
holder.bind(items[position])
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = items.size
|
||||
|
||||
class LiveViewHolder(
|
||||
itemView: View,
|
||||
private val onClickItem: (HomeFollowingLiveUiItem) -> Unit
|
||||
) : RecyclerView.ViewHolder(itemView) {
|
||||
private val thumbnailImage = itemView.findViewById<ImageView>(R.id.iv_home_following_live_thumbnail)
|
||||
private val profileImage = itemView.findViewById<ImageView>(R.id.iv_home_following_live_creator_profile)
|
||||
private val titleText = itemView.findViewById<TextView>(R.id.tv_home_following_live_title)
|
||||
private val nicknameText = itemView.findViewById<TextView>(R.id.tv_home_following_live_creator_nickname)
|
||||
private val startedAtText = itemView.findViewById<TextView>(R.id.tv_home_following_live_started_at)
|
||||
|
||||
fun bind(item: HomeFollowingLiveUiItem) {
|
||||
thumbnailImage.loadUrl(item.creatorProfileImageUrl)
|
||||
profileImage.loadHomeCreatorProfileImage(item.creatorProfileImageUrl)
|
||||
titleText.text = item.title
|
||||
nicknameText.text = item.creatorNickname
|
||||
startedAtText.text = formatUtcRelativeTimeText(itemView.context, item.startedAtUtc)
|
||||
itemView.setOnClickListener { onClickItem(item) }
|
||||
}
|
||||
}
|
||||
}
|
||||
101
app/src/main/res/layout/item_home_following_live.xml
Normal file
101
app/src/main/res/layout/item_home_following_live.xml
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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="244dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_feed_card"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/spacing_14">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="120dp"
|
||||
android:background="@drawable/bg_audio_content_card_thumbnail">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_home_following_live_thumbnail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@null"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/ic_launcher_background" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="18dp"
|
||||
android:layout_gravity="top|start"
|
||||
android:layout_margin="@dimen/spacing_8"
|
||||
android:background="@drawable/bg_live_thumbnail_badge_capsule"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="@dimen/spacing_4">
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/spacing_8"
|
||||
android:layout_height="@dimen/spacing_8"
|
||||
android:background="@drawable/bg_live_thumbnail_dot" />
|
||||
|
||||
<TextView
|
||||
style="@style/Typography.Caption3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/spacing_4"
|
||||
android:includeFontPadding="true"
|
||||
android:text="LIVE"
|
||||
android:textColor="@color/white"
|
||||
tools:ignore="HardcodedText,SmallSp" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_home_following_live_title"
|
||||
style="@style/Typography.Heading4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/spacing_12"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/white"
|
||||
tools:text="라이브 제목" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/spacing_8"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_home_following_live_creator_profile"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:background="@drawable/bg_round_corner_999_263238"
|
||||
android:contentDescription="@null"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/ic_placeholder_profile" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_home_following_live_creator_nickname"
|
||||
style="@style/Typography.Body6"
|
||||
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="1"
|
||||
android:textColor="@color/gray_300"
|
||||
tools:text="크리에이터 이름" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_home_following_live_started_at"
|
||||
style="@style/Typography.Body6"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/spacing_8"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="@color/gray_500"
|
||||
tools:text="2분 전" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user