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" />