feat(home): 팔로잉 스케줄 카드를 추가한다
This commit is contained in:
+70
@@ -0,0 +1,70 @@
|
||||
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.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.ui.formatCreatorChannelScheduleDate
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.ui.formatCreatorChannelScheduleDayOfWeek
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.ui.formatCreatorChannelScheduleTime
|
||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeFollowingScheduleUiItem
|
||||
|
||||
class HomeFollowingScheduleAdapter(
|
||||
private val onClickItem: (HomeFollowingScheduleUiItem) -> Unit = {}
|
||||
) : RecyclerView.Adapter<HomeFollowingScheduleAdapter.ScheduleViewHolder>() {
|
||||
private var items: List<HomeFollowingScheduleUiItem> = emptyList()
|
||||
|
||||
fun submitItems(items: List<HomeFollowingScheduleUiItem>) {
|
||||
this.items = items
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ScheduleViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_home_following_schedule, parent, false)
|
||||
view.layoutParams = RecyclerView.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
).apply { bottomMargin = parent.resources.getDimensionPixelSize(R.dimen.spacing_8) }
|
||||
return ScheduleViewHolder(view, onClickItem)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ScheduleViewHolder, position: Int) {
|
||||
holder.bind(items[position])
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = items.size
|
||||
|
||||
class ScheduleViewHolder(
|
||||
itemView: View,
|
||||
private val onClickItem: (HomeFollowingScheduleUiItem) -> Unit
|
||||
) : RecyclerView.ViewHolder(itemView) {
|
||||
private val dayText = itemView.findViewById<TextView>(R.id.tv_home_following_schedule_day)
|
||||
private val weekdayText = itemView.findViewById<TextView>(R.id.tv_home_following_schedule_weekday)
|
||||
private val titleText = itemView.findViewById<TextView>(R.id.tv_home_following_schedule_title)
|
||||
private val profileImage = itemView.findViewById<ImageView>(R.id.iv_home_following_schedule_creator_profile)
|
||||
private val nicknameText = itemView.findViewById<TextView>(R.id.tv_home_following_schedule_creator_nickname)
|
||||
private val typeText = itemView.findViewById<TextView>(R.id.tv_home_following_schedule_type)
|
||||
private val timeText = itemView.findViewById<TextView>(R.id.tv_home_following_schedule_time)
|
||||
|
||||
fun bind(item: HomeFollowingScheduleUiItem) {
|
||||
dayText.text = formatCreatorChannelScheduleDate(item.scheduledAtUtc)
|
||||
weekdayText.text = formatCreatorChannelScheduleDayOfWeek(item.scheduledAtUtc)
|
||||
titleText.text = item.title
|
||||
profileImage.loadHomeCreatorProfileImage(item.creatorProfileImageUrl)
|
||||
nicknameText.text = item.creatorNickname
|
||||
typeText.setText(item.typeLabelResId)
|
||||
if (item.isOnAir) {
|
||||
timeText.setText(R.string.screen_home_following_on_air)
|
||||
timeText.setTextColor(ContextCompat.getColor(itemView.context, R.color.green_400))
|
||||
} else {
|
||||
timeText.text = formatCreatorChannelScheduleTime(item.scheduledAtUtc)
|
||||
timeText.setTextColor(ContextCompat.getColor(itemView.context, R.color.gray_500))
|
||||
}
|
||||
itemView.setOnClickListener { onClickItem(item) }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user