Skip to content

Commit

Permalink
[feat/#90] 어뎁터 및 뷰홀더 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Jokwanhee committed Aug 20, 2024
1 parent e325b65 commit d5e03d4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,18 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import com.depromeet.presentation.databinding.ItemSelectSeatBinding
import com.dpm.domain.entity.response.seatreview.ResponseStadiumSection
import com.dpm.domain.entity.response.viewfinder.Section
import com.dpm.presentation.util.ItemDiffCallback
import com.dpm.presentation.viewfinder.viewholder.StadiumSectionViewHolder

data class MockSection(
val id: Int,
val title: String,
val alias: String,
val color: String,
val isActive: Boolean = false
)

val mockSections = listOf(
MockSection(1, "프리미엄석", "켈리존", "#7EAEFF"),
MockSection(2, "테이블석", "", "#D24074"),
MockSection(3, "오렌지석", "응원석", "#FF9900"),
MockSection(4, "블루석", "", "#0E5EAD"),
MockSection(5, "레드석", "", "#D62030"),
MockSection(6, "네이비석", "", "#1B4963"),
MockSection(7, "외야그린석", "", "#80C161"),
MockSection(8, "익사이팅석", "", "#FDCE29"),
MockSection(9, "휠체어석", "", "#212124"),
)

class StadiumSectionAdapter : ListAdapter<MockSection, StadiumSectionViewHolder>(
ItemDiffCallback<MockSection>(
class StadiumSectionAdapter : ListAdapter<Section, StadiumSectionViewHolder>(
ItemDiffCallback<Section>(
onItemsTheSame = { old, new -> old == new },
onContentsTheSame = { old, new -> old == new },
)
) {
interface OnItemSectionClickListener {
fun onItemSectionClick(mockSection: MockSection)
fun onItemSectionClick(mockSection: Section)
}

var itemSectionClickListener: OnItemSectionClickListener? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,19 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import com.depromeet.presentation.databinding.ItemBlockRecommendBinding
import com.dpm.domain.entity.response.seatreview.ResponseStadiumSection
import com.dpm.domain.entity.response.viewfinder.ResponseStadium
import com.dpm.presentation.util.ItemDiffCallback
import com.dpm.presentation.viewfinder.viewholder.StadiumSectionRecommendViewHolder


data class Recommend(
val id: Int,
val title: String,
val blocks: List<String>,
val isActive: Boolean
)

val recommend = listOf(
Recommend(1, "\uD83E\uDD1D 타팀 팬과 함께", listOf("316", "317", "318", "319"), false),
Recommend(
2,
"\uD83D\uDC40 선수들과 가까이",
listOf("107", "108", "109", "114", "115", "116", "exciting1", "exciting3"),
false
),
Recommend(
3,
"\uD83C\uDF54 음식 먹기 편한",
listOf("110", "111", "112", "113", "212", "213", "214", "215"),
false
),
Recommend(
4,
"\uD83D\uDEA9 서서 응원하기",
listOf("205", "206", "207", "208", "219", "220", "221", "222", "306", "307", "328", "329"),
false
),
Recommend(
5,
"\uD83D\uDCE3 응원 배우기",
listOf("205", "206", "207", "208", "219", "220", "221", "222", "306", "307", "328", "329"),
false
),
Recommend(
6,
"\uD83C\uDF24️ 햇빛 피하기",
listOf("205", "206", "207", "208", "219", "220", "221", "222", "306", "307", "328", "329"),
false
),
Recommend(
7,
"\uD83C\uDF1F 추천 외야석",
listOf("205", "206", "207", "208", "219", "220", "221", "222", "306", "307", "328", "329"),
false
),
)

class StadiumSectionRecommendAdapter : ListAdapter<Recommend, StadiumSectionRecommendViewHolder>(
ItemDiffCallback<Recommend>(
class StadiumSectionRecommendAdapter : ListAdapter<ResponseStadium.ResponseBlockTags, StadiumSectionRecommendViewHolder>(
ItemDiffCallback<ResponseStadium.ResponseBlockTags>(
onItemsTheSame = { old, new -> old.id == new.id },
onContentsTheSame = { old, new -> old == new }
)
) {

interface OnItemFilterClickListener {
fun onItemFilterClick(recommend: Recommend)
fun onItemFilterClick(recommend: ResponseStadium.ResponseBlockTags)
}

var itemFilterClickListener: OnItemFilterClickListener? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.depromeet.designsystem.R
import com.depromeet.presentation.databinding.ItemBlockRecommendBinding
import com.dpm.domain.entity.response.viewfinder.ResponseStadium
import com.dpm.presentation.extension.dpToPx
import com.dpm.presentation.extension.setMargins
import com.dpm.presentation.viewfinder.adapter.Recommend

class StadiumSectionRecommendViewHolder(
private val binding: ItemBlockRecommendBinding
) : RecyclerView.ViewHolder(binding.root) {
fun bind(item: Recommend, last: Boolean) {
fun bind(item: ResponseStadium.ResponseBlockTags, last: Boolean) {
if (!last) binding.root.setMargins(
right = 6.dpToPx(binding.root.context),
left = 0,
top = 0,
bottom = 0
)
binding.tvTitle.text = item.title
binding.tvTitle.text = item.name
if (item.isActive) {
binding.root.setBackgroundResource(R.drawable.rect_spot_green_fill_999)
binding.tvTitle.setTextColor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.depromeet.presentation.R
import com.depromeet.presentation.databinding.ItemSelectSeatBinding
import com.dpm.presentation.viewfinder.adapter.MockSection
import com.dpm.domain.entity.response.viewfinder.Section

class StadiumSectionViewHolder(
private val binding: ItemSelectSeatBinding
) : RecyclerView.ViewHolder(binding.root) {
fun bind(item: MockSection) {
binding.tvSeatName.text = item.title
fun bind(item: Section) {
binding.tvSeatName.text = item.name
binding.tvSubName.text = item.alias

if (item.alias.isNullOrEmpty()) {
Expand All @@ -28,13 +28,13 @@ class StadiumSectionViewHolder(
when (item.id) {
1 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.oval_section_premium)
2 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.oval_section_table)
3 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.oval_section_orange)
4 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.oval_section_blue)
5 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.oval_section_red)
6 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.oval_section_navy)
7 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.oval_section_green)
8 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.oval_exciting_blue)
9 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.ic_wheelchair)
5 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.oval_section_orange)
6 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.oval_section_red)
7 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.oval_section_navy)
8 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.oval_section_exciting)
9 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.oval_section_green)
10 -> binding.ivSeatColor.setImageResource(com.depromeet.designsystem.R.drawable.ic_wheelchair)
}
}
}

0 comments on commit d5e03d4

Please sign in to comment.