From 18618244fad548e95eb1f5ce0d3934a232bd869c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=86=A0=EB=A7=88=EC=8A=A4?= <123928686+ki960213@users.noreply.github.com> Date: Sat, 27 Jan 2024 16:32:22 +0900 Subject: [PATCH] =?UTF-8?q?merge:=20=EC=84=9C=EB=B2=84=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=EC=A3=BC=EB=8A=94=20=ED=98=95=EC=8B=9D=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EA=B2=8C=20Response=20=ED=98=95=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20=EB=B0=8F=20=EB=A7=A4=ED=8D=BC=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD,=20=ED=96=89=EC=82=AC=20=ED=83=9C=EA=B7=B8?= =?UTF-8?q?=EB=A5=BC=20=EC=B9=A9=20=EA=B7=B8=EB=A3=B9=EC=97=90=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=98=EB=8A=94=20=EB=B0=94=EC=9D=B8=EB=94=A9=20?= =?UTF-8?q?=EC=96=B4=EB=8C=91=ED=84=B0=20=EB=B3=80=EA=B2=BD,=20=EB=8C=80?= =?UTF-8?q?=ED=9A=8C=20=EB=AA=A9=EB=A1=9D=EB=8F=84=20=ED=96=89=EC=82=AC=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D,=20=EC=8A=A4=ED=81=AC=EB=9E=A9=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=EC=B2=98=EB=9F=BC=20=EB=B0=94=EC=9D=B8=EB=94=A9=20?= =?UTF-8?q?=EC=96=B4=EB=8C=91=ED=84=B0=EB=A1=9C=20=EC=B9=A9=EC=9D=84=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20(#907)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to: #906 --- .../data/apiModel/response/EventResponse.kt | 2 +- .../java/com/emmsale/data/mapper/EventMapper.kt | 2 +- .../main/java/com/emmsale/data/model/Event.kt | 2 +- .../bindingadapter/ChipGroupBindingAdapter.kt | 9 +++++---- .../recyclerView/CompetitionViewHolder.kt | 16 ---------------- .../app/src/main/res/layout/item_competition.xml | 1 + 6 files changed, 9 insertions(+), 23 deletions(-) diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/apiModel/response/EventResponse.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/apiModel/response/EventResponse.kt index b87e12c05..e2d7c9f92 100644 --- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/apiModel/response/EventResponse.kt +++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/apiModel/response/EventResponse.kt @@ -28,7 +28,7 @@ data class EventResponse( @SerialName("location") val location: String, @SerialName("tags") - val tags: List, + val tags: List, @SerialName("thumbnailUrl") val thumbnailUrl: String?, @SerialName("type") diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/EventMapper.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/EventMapper.kt index beab91506..69a33ffc6 100644 --- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/EventMapper.kt +++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/EventMapper.kt @@ -18,7 +18,7 @@ fun EventResponse.toData(): Event = Event( applyingStartDate = applyStartDate, applyingEndDate = applyEndDate, location = location, - tags = tags, + tags = tags.toData(), posterImageUrl = thumbnailUrl?.let { BuildConfig.IMAGE_URL_PREFIX + it } ?: "", type = type, paymentType = paymentType.toPaymentType(), diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Event.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Event.kt index 3daeb18d7..c6ce3a1e2 100644 --- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Event.kt +++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Event.kt @@ -12,7 +12,7 @@ data class Event( val applyingStartDate: LocalDateTime = DEFAULT_LOCAL_DATE_TIME, val applyingEndDate: LocalDateTime = DEFAULT_LOCAL_DATE_TIME, val location: String = "", - val tags: List = emptyList(), + val tags: List = emptyList(), val posterImageUrl: String? = "", val paymentType: PaymentType = DEFAULT_PAYMENT_TYPE, val onOfflineMode: OnOfflineMode = DEFAULT_ON_OFFLINE_MODE, diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/common/bindingadapter/ChipGroupBindingAdapter.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/common/bindingadapter/ChipGroupBindingAdapter.kt index 661429eda..a964dc27f 100644 --- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/common/bindingadapter/ChipGroupBindingAdapter.kt +++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/common/bindingadapter/ChipGroupBindingAdapter.kt @@ -1,19 +1,20 @@ package com.emmsale.presentation.common.bindingadapter import androidx.databinding.BindingAdapter +import com.emmsale.data.model.EventTag import com.emmsale.presentation.common.views.EventTagChip import com.google.android.material.chip.ChipGroup @BindingAdapter("app:eventChips") -fun ChipGroup.setEventChips(tags: List?) { +fun ChipGroup.setEventChips(tags: List?) { removeAllViews() addEventTags(tags ?: emptyList()) } -private fun ChipGroup.addEventTags(tags: List) { +private fun ChipGroup.addEventTags(tags: List) { tags.forEach { addView(createEventTag(it)) } } -private fun ChipGroup.createEventTag(tag: String) = EventTagChip(this.context).apply { - text = tag +private fun ChipGroup.createEventTag(tag: EventTag) = EventTagChip(this.context).apply { + text = tag.name } diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/competitionList/recyclerView/CompetitionViewHolder.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/competitionList/recyclerView/CompetitionViewHolder.kt index d072648e2..391462630 100644 --- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/competitionList/recyclerView/CompetitionViewHolder.kt +++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/competitionList/recyclerView/CompetitionViewHolder.kt @@ -1,14 +1,11 @@ package com.emmsale.presentation.ui.competitionList.recyclerView -import android.content.Context import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView.ViewHolder import com.emmsale.R import com.emmsale.data.model.Event import com.emmsale.databinding.ItemCompetitionBinding -import com.emmsale.presentation.common.views.EventTagChip -import com.emmsale.presentation.common.views.eventChipOf class CompetitionViewHolder( parent: ViewGroup, @@ -24,18 +21,5 @@ class CompetitionViewHolder( fun bind(event: Event) { binding.event = event - binding.cgEventTags.removeAllViews() - event.tags.forEach(::addEventChip) - } - - private fun addEventChip(tagName: String) { - binding.cgEventTags.addView(createEventChip(itemView.context, tagName)) - } - - private fun createEventChip( - context: Context, - tagName: String, - ): EventTagChip = context.eventChipOf { - text = tagName } } diff --git a/android/2023-emmsale/app/src/main/res/layout/item_competition.xml b/android/2023-emmsale/app/src/main/res/layout/item_competition.xml index d7317884a..005ddda57 100644 --- a/android/2023-emmsale/app/src/main/res/layout/item_competition.xml +++ b/android/2023-emmsale/app/src/main/res/layout/item_competition.xml @@ -141,6 +141,7 @@ android:layout_height="wrap_content" android:layout_marginTop="24dp" android:layout_marginBottom="10dp" + app:eventChips="@{event.tags}" app:layout_constraintEnd_toEndOf="@+id/iv_event_poster" app:layout_constraintStart_toStartOf="@+id/iv_event_poster" app:layout_constraintTop_toBottomOf="@+id/tv_is_online" />